summaryrefslogtreecommitdiff
path: root/src/com/android
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/launcher3/Launcher.java2
-rw-r--r--src/com/android/launcher3/LauncherState.java3
-rw-r--r--src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java6
-rw-r--r--src/com/android/launcher3/celllayout/MulticellReorderAlgorithm.java26
-rw-r--r--src/com/android/launcher3/config/FeatureFlags.java4
-rw-r--r--src/com/android/launcher3/folder/LauncherDelegate.java2
-rw-r--r--src/com/android/launcher3/util/EventLogArray.kt117
7 files changed, 139 insertions, 21 deletions
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 25eb16079f..66690431ec 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -2194,6 +2194,8 @@ public class Launcher extends StatefulActivity<LauncherState>
/**
* Returns the CellLayout of the specified container at the specified screen.
+ *
+ * @param screenId must be presenterPos and not modelPos.
*/
public CellLayout getCellLayout(int container, int screenId) {
return (container == LauncherSettings.Favorites.CONTAINER_HOTSEAT)
diff --git a/src/com/android/launcher3/LauncherState.java b/src/com/android/launcher3/LauncherState.java
index 8b124dc847..6097fb1947 100644
--- a/src/com/android/launcher3/LauncherState.java
+++ b/src/com/android/launcher3/LauncherState.java
@@ -331,8 +331,7 @@ public abstract class LauncherState implements BaseState<LauncherState> {
* Gets the translation provider for workspace pages.
*/
public PageTranslationProvider getWorkspacePageTranslationProvider(Launcher launcher) {
- if (this != SPRING_LOADED
- || this != EDIT_MODE
+ if (!(this == SPRING_LOADED || this == EDIT_MODE)
|| !launcher.getDeviceProfile().isTwoPanels) {
return DEFAULT_PAGE_TRANSLATION_PROVIDER;
}
diff --git a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java
index d4140d851c..1977704588 100644
--- a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java
@@ -43,7 +43,6 @@ import android.util.AttributeSet;
import android.util.FloatProperty;
import android.util.Log;
import android.util.SparseArray;
-import android.util.TypedValue;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
@@ -272,9 +271,8 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
0,
0 // Bottom left
};
- final TypedValue value = new TypedValue();
- getContext().getTheme().resolveAttribute(android.R.attr.colorBackground, value, true);
- mBottomSheetBackgroundColor = value.data;
+ mBottomSheetBackgroundColor =
+ Themes.getAttrColor(getContext(), R.attr.materialColorSurfaceDim);
updateBackgroundVisibility(mActivityContext.getDeviceProfile());
mSearchUiManager.initializeSearch(this);
}
diff --git a/src/com/android/launcher3/celllayout/MulticellReorderAlgorithm.java b/src/com/android/launcher3/celllayout/MulticellReorderAlgorithm.java
index cb1216109a..a2e26b37f3 100644
--- a/src/com/android/launcher3/celllayout/MulticellReorderAlgorithm.java
+++ b/src/com/android/launcher3/celllayout/MulticellReorderAlgorithm.java
@@ -19,8 +19,10 @@ import android.view.View;
import com.android.launcher3.CellLayout;
import com.android.launcher3.MultipageCellLayout;
+import com.android.launcher3.ShortcutAndWidgetContainer;
import com.android.launcher3.util.GridOccupancy;
+import java.util.Arrays;
import java.util.function.Supplier;
/**
@@ -79,7 +81,7 @@ public class MulticellReorderAlgorithm extends ReorderAlgorithm {
lp.canReorder = false;
mcl.setCountX(mcl.getCountX() + 1);
mcl.getShortcutsAndWidgets().addViewInLayout(mSeam, lp);
- mcl.setOccupied(createGridOccupancyWithSeam(mcl.getOccupied()));
+ mcl.setOccupied(createGridOccupancyWithSeam());
mcl.mTmpOccupied = new GridOccupancy(mcl.getCountX(), mcl.getCountY());
}
@@ -93,7 +95,8 @@ public class MulticellReorderAlgorithm extends ReorderAlgorithm {
/**
* The function supplied here will execute while the CellLayout has a simulated seam added.
- * @param f function to run under simulation
+ *
+ * @param f function to run under simulation
* @param <T> return value of the supplied function
* @return Value of supplied function
*/
@@ -110,18 +113,17 @@ public class MulticellReorderAlgorithm extends ReorderAlgorithm {
return res;
}
- GridOccupancy createGridOccupancyWithSeam(GridOccupancy gridOccupancy) {
+ GridOccupancy createGridOccupancyWithSeam() {
+ ShortcutAndWidgetContainer shortcutAndWidgets = mCellLayout.getShortcutsAndWidgets();
GridOccupancy grid = new GridOccupancy(mCellLayout.getCountX(), mCellLayout.getCountY());
- for (int x = 0; x < mCellLayout.getCountX(); x++) {
- for (int y = 0; y < mCellLayout.getCountY(); y++) {
- int offset = x >= mCellLayout.getCountX() / 2 ? 1 : 0;
- if (x == mCellLayout.getCountX() / 2) {
- grid.cells[x][y] = true;
- } else {
- grid.cells[x][y] = gridOccupancy.cells[x - offset][y];
- }
- }
+ for (int i = 0; i < shortcutAndWidgets.getChildCount(); i++) {
+ View view = shortcutAndWidgets.getChildAt(i);
+ CellLayoutLayoutParams lp = (CellLayoutLayoutParams) view.getLayoutParams();
+ int seamOffset = lp.getCellX() >= mCellLayout.getCountX() / 2 && lp.canReorder ? 1 : 0;
+ grid.markCells(lp.getCellX() + seamOffset, lp.getCellY(), lp.cellHSpan, lp.cellVSpan,
+ true);
}
+ Arrays.fill(grid.cells[mCellLayout.getCountX() / 2], true);
return grid;
}
}
diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java
index f5f6769c33..76574b69c7 100644
--- a/src/com/android/launcher3/config/FeatureFlags.java
+++ b/src/com/android/launcher3/config/FeatureFlags.java
@@ -194,7 +194,7 @@ public final class FeatureFlags {
"In foldables, when reordering the icons and widgets, is now going to use both sides");
public static final BooleanFlag FOLDABLE_SINGLE_PAGE = getDebugFlag(270395274,
- "FOLDABLE_SINGLE_PAGE", ENABLED, "Use a single page for the workspace");
+ "FOLDABLE_SINGLE_PAGE", DISABLED, "Use a single page for the workspace");
// TODO(Block 12): Clean up flags
public static final BooleanFlag ENABLE_MULTI_INSTANCE = getDebugFlag(270396680,
@@ -302,7 +302,7 @@ public final class FeatureFlags {
"Enable widget transition animation when resizing the widgets");
public static final BooleanFlag PREEMPTIVE_UNFOLD_ANIMATION_START = getDebugFlag(270397209,
- "PREEMPTIVE_UNFOLD_ANIMATION_START", DISABLED,
+ "PREEMPTIVE_UNFOLD_ANIMATION_START", ENABLED,
"Enables starting the unfold animation preemptively when unfolding, without"
+ "waiting for SystemUI and then merging the SystemUI progress whenever we "
+ "start receiving the events");
diff --git a/src/com/android/launcher3/folder/LauncherDelegate.java b/src/com/android/launcher3/folder/LauncherDelegate.java
index f15dc83387..7ac2472319 100644
--- a/src/com/android/launcher3/folder/LauncherDelegate.java
+++ b/src/com/android/launcher3/folder/LauncherDelegate.java
@@ -93,7 +93,7 @@ public class LauncherDelegate {
// Move the item from the folder to the workspace, in the position of the
// folder
CellLayout cellLayout = mLauncher.getCellLayout(info.container,
- info.screenId);
+ mLauncher.getCellPosMapper().mapModelToPresenter(info).screenId);
if (cellLayout == null) {
return;
}
diff --git a/src/com/android/launcher3/util/EventLogArray.kt b/src/com/android/launcher3/util/EventLogArray.kt
new file mode 100644
index 0000000000..a17d6509e3
--- /dev/null
+++ b/src/com/android/launcher3/util/EventLogArray.kt
@@ -0,0 +1,117 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.launcher3.util
+
+import java.io.PrintWriter
+import java.text.SimpleDateFormat
+import java.util.Date
+import java.util.Locale
+
+/**
+ * A utility class to record and log events. Events are stored in a fixed size array and old logs
+ * are purged as new events come.
+ */
+class EventLogArray(private val name: String, size: Int) {
+
+ companion object {
+ private const val TYPE_ONE_OFF = 0
+ private const val TYPE_FLOAT = 1
+ private const val TYPE_INTEGER = 2
+ private const val TYPE_BOOL_TRUE = 3
+ private const val TYPE_BOOL_FALSE = 4
+ private fun isEntrySame(entry: EventEntry?, type: Int, event: String): Boolean {
+ return entry != null && entry.type == type && entry.event == event
+ }
+ }
+
+ private val logs: Array<EventEntry?>
+ private var nextIndex = 0
+
+ init {
+ logs = arrayOfNulls(size)
+ }
+
+ fun addLog(event: String) {
+ addLog(TYPE_ONE_OFF, event, 0f)
+ }
+
+ fun addLog(event: String, extras: Int) {
+ addLog(TYPE_INTEGER, event, extras.toFloat())
+ }
+
+ fun addLog(event: String, extras: Float) {
+ addLog(TYPE_FLOAT, event, extras)
+ }
+
+ fun addLog(event: String, extras: Boolean) {
+ addLog(if (extras) TYPE_BOOL_TRUE else TYPE_BOOL_FALSE, event, 0f)
+ }
+
+ private fun addLog(type: Int, event: String, extras: Float) {
+ // Merge the logs if it's a duplicate
+ val last = (nextIndex + logs.size - 1) % logs.size
+ val secondLast = (nextIndex + logs.size - 2) % logs.size
+ if (isEntrySame(logs[last], type, event) && isEntrySame(logs[secondLast], type, event)) {
+ logs[last]!!.update(type, event, extras)
+ logs[secondLast]!!.duplicateCount++
+ return
+ }
+ if (logs[nextIndex] == null) {
+ logs[nextIndex] = EventEntry()
+ }
+ logs[nextIndex]!!.update(type, event, extras)
+ nextIndex = (nextIndex + 1) % logs.size
+ }
+
+ fun dump(prefix: String, writer: PrintWriter) {
+ writer.println("$prefix$name event history:")
+ val sdf = SimpleDateFormat(" HH:mm:ss.SSSZ ", Locale.US)
+ val date = Date()
+ for (i in logs.indices) {
+ val log = logs[(nextIndex + logs.size - i - 1) % logs.size] ?: continue
+ date.time = log.time
+ val msg = StringBuilder(prefix).append(sdf.format(date)).append(log.event)
+ when (log.type) {
+ TYPE_BOOL_FALSE -> msg.append(": false")
+ TYPE_BOOL_TRUE -> msg.append(": true")
+ TYPE_FLOAT -> msg.append(": ").append(log.extras)
+ TYPE_INTEGER -> msg.append(": ").append(log.extras.toInt())
+ else -> {}
+ }
+ if (log.duplicateCount > 0) {
+ msg.append(" & ").append(log.duplicateCount).append(" similar events")
+ }
+ writer.println(msg)
+ }
+ }
+
+ /** A single event entry. */
+ private class EventEntry {
+ var type = 0
+ var event: String? = null
+ var extras = 0f
+ var time: Long = 0
+ var duplicateCount = 0
+ fun update(type: Int, event: String, extras: Float) {
+ this.type = type
+ this.event = event
+ this.extras = extras
+ time = System.currentTimeMillis()
+ duplicateCount = 0
+ }
+ }
+}