Merge "Using themed icons in taskbar" into sc-v2-dev
diff --git a/quickstep/src/com/android/quickstep/FallbackSwipeHandler.java b/quickstep/src/com/android/quickstep/FallbackSwipeHandler.java
index fd44e02..e2f198c 100644
--- a/quickstep/src/com/android/quickstep/FallbackSwipeHandler.java
+++ b/quickstep/src/com/android/quickstep/FallbackSwipeHandler.java
@@ -173,7 +173,9 @@
@Override
protected void notifyGestureAnimationStartToRecents() {
if (mRunningOverHome) {
- mRecentsView.onGestureAnimationStartOnHome(mGestureState.getRunningTask());
+ if (SysUINavigationMode.getMode(mContext).hasGestures) {
+ mRecentsView.onGestureAnimationStartOnHome(mGestureState.getRunningTask());
+ }
} else {
super.notifyGestureAnimationStartToRecents();
}
diff --git a/quickstep/src/com/android/quickstep/LauncherActivityInterface.java b/quickstep/src/com/android/quickstep/LauncherActivityInterface.java
index 5deb75e..d91d5b0 100644
--- a/quickstep/src/com/android/quickstep/LauncherActivityInterface.java
+++ b/quickstep/src/com/android/quickstep/LauncherActivityInterface.java
@@ -189,7 +189,7 @@
launcher != null && launcher.getStateManager().getState().overviewUi
? launcher.getOverviewPanel() : null;
if (recentsView == null || (!launcher.hasBeenResumed()
- && recentsView.getRunningTaskId() == -1)) {
+ && recentsView.getRunningTaskViewId() == -1)) {
// If live tile has ended, return null.
return null;
}
diff --git a/quickstep/src/com/android/quickstep/OverviewComponentObserver.java b/quickstep/src/com/android/quickstep/OverviewComponentObserver.java
index 0efe666..780032e 100644
--- a/quickstep/src/com/android/quickstep/OverviewComponentObserver.java
+++ b/quickstep/src/com/android/quickstep/OverviewComponentObserver.java
@@ -33,8 +33,11 @@
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
+import android.os.SystemClock;
+import android.util.Log;
import android.util.SparseIntArray;
+import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.tracing.OverviewComponentObserverProto;
import com.android.launcher3.tracing.TouchInteractionServiceProto;
import com.android.launcher3.util.SimpleBroadcastReceiver;
@@ -129,6 +132,16 @@
private void updateOverviewTargets() {
ComponentName defaultHome = PackageManagerWrapper.getInstance()
.getHomeActivities(new ArrayList<>());
+ if (TestProtocol.sDebugTracing && defaultHome == null) {
+ Log.d(TestProtocol.THIRD_PARTY_LAUNCHER_NOT_SET, "getHomeActivities returned null");
+ while ((defaultHome =
+ PackageManagerWrapper.getInstance().getHomeActivities(new ArrayList<>()))
+ == null) {
+ SystemClock.sleep(10);
+ }
+ Log.d(TestProtocol.THIRD_PARTY_LAUNCHER_NOT_SET,
+ "getHomeActivities returned non-null: " + defaultHome);
+ }
mIsHomeDisabled = mDeviceState.isHomeDisabled();
mIsDefaultHome = Objects.equals(mMyHomeIntent.getComponent(), defaultHome);
diff --git a/quickstep/src/com/android/quickstep/TaskViewUtils.java b/quickstep/src/com/android/quickstep/TaskViewUtils.java
index 07d221c..b5da097 100644
--- a/quickstep/src/com/android/quickstep/TaskViewUtils.java
+++ b/quickstep/src/com/android/quickstep/TaskViewUtils.java
@@ -139,7 +139,7 @@
// If the opening task id is not currently visible in overview, then fall back to normal app
// icon launch animation
- TaskView taskView = recentsView.getTaskView(openingTaskId);
+ TaskView taskView = recentsView.getTaskViewByTaskId(openingTaskId);
if (taskView == null || !recentsView.isTaskViewVisible(taskView)) {
return null;
}
diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java
index 61622ee..8155244 100644
--- a/quickstep/src/com/android/quickstep/TouchInteractionService.java
+++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java
@@ -144,7 +144,7 @@
private static final int SYSTEM_ACTION_ID_ALL_APPS = 14;
public static final boolean ENABLE_PER_WINDOW_INPUT_ROTATION =
- SystemProperties.getBoolean("persist.debug.per_window_input_rotation", false);
+ SystemProperties.getBoolean("persist.debug.per_window_input_rotation", true);
private int mBackGestureNotificationCounter = -1;
@Nullable
diff --git a/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java b/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java
index 540a9ca..64a428f 100644
--- a/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java
+++ b/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java
@@ -95,7 +95,7 @@
TaskViewSimulator taskViewSimulator) {
super.onPrepareGestureEndAnimation(animatorSet, endTarget, taskViewSimulator);
if (mHomeTaskInfo != null && endTarget == RECENTS && animatorSet != null) {
- TaskView tv = getTaskView(mHomeTaskInfo.taskId);
+ TaskView tv = getTaskViewByTaskId(mHomeTaskInfo.taskId);
if (tv != null) {
PendingAnimation pa = createTaskDismissAnimation(tv, true, false, 150,
false /* dismissingForSplitSelection*/);
@@ -117,8 +117,9 @@
}
@Override
- public void setCurrentTask(int runningTaskId) {
- super.setCurrentTask(runningTaskId);
+ public void setCurrentTask(int runningTaskViewId) {
+ super.setCurrentTask(runningTaskViewId);
+ int runningTaskId = getTaskIdsForRunningTaskView()[0];
if (mHomeTaskInfo != null && mHomeTaskInfo.taskId != runningTaskId) {
mHomeTaskInfo = null;
setRunningTaskHidden(false);
@@ -128,7 +129,7 @@
@Nullable
@Override
protected TaskView getHomeTaskView() {
- return mHomeTaskInfo != null ? getTaskView(mHomeTaskInfo.taskId) : null;
+ return mHomeTaskInfo != null ? getTaskViewByTaskId(mHomeTaskInfo.taskId) : null;
}
@Override
@@ -148,11 +149,12 @@
// When quick-switching on 3p-launcher, we add a "stub" tile corresponding to Launcher
// as well. This tile is never shown as we have setCurrentTaskHidden, but allows use to
// track the index of the next task appropriately, as if we are switching on any other app.
- if (mHomeTaskInfo != null && mHomeTaskInfo.taskId == mRunningTaskId && !tasks.isEmpty()) {
+ int runningTaskId = getTaskIdsForRunningTaskView()[0];
+ if (mHomeTaskInfo != null && mHomeTaskInfo.taskId == runningTaskId && !tasks.isEmpty()) {
// Check if the task list has running task
boolean found = false;
for (Task t : tasks) {
- if (t.key.id == mRunningTaskId) {
+ if (t.key.id == runningTaskId) {
found = true;
break;
}
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index d00db2d..b077ca6 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -398,6 +398,9 @@
private final InvariantDeviceProfile mIdp;
+ /**
+ * Getting views should be done via {@link #getTaskViewFromPool()}
+ */
private final ViewPool<TaskView> mTaskViewPool;
private final TaskOverlayFactory mTaskOverlayFactory;
@@ -441,7 +444,7 @@
}
// Remove the task immediately from the task list
- TaskView taskView = getTaskView(taskId);
+ TaskView taskView = getTaskViewByTaskId(taskId);
if (taskView != null) {
removeView(taskView);
}
@@ -463,7 +466,7 @@
return;
}
- TaskView taskView = getTaskView(taskId);
+ TaskView taskView = getTaskViewByTaskId(taskId);
if (taskView == null) {
return;
}
@@ -496,10 +499,16 @@
private int mTaskListChangeId = -1;
// Only valid until the launcher state changes to NORMAL
- protected int mRunningTaskId = -1;
+ /**
+ * ID for the current running TaskView view, unique amongst TaskView instances. ID's are set
+ * through {@link #getTaskViewFromPool()} and incremented by {@link #mTaskViewIdCount}
+ */
+ protected int mRunningTaskViewId = -1;
+ private int mTaskViewIdCount;
+ private final int[] INVALID_TASK_IDS = new int[]{-1, -1};
protected boolean mRunningTaskTileHidden;
private Task mTmpRunningTask;
- protected int mFocusedTaskId = -1;
+ protected int mFocusedTaskViewId = -1;
private boolean mTaskIconScaledDown = false;
private boolean mRunningTaskShowScreenshot = false;
@@ -734,7 +743,7 @@
@Override
public Task onTaskThumbnailChanged(int taskId, ThumbnailData thumbnailData) {
if (mHandleTaskStackChanges) {
- TaskView taskView = getTaskView(taskId);
+ TaskView taskView = getTaskViewByTaskId(taskId);
if (taskView != null) {
Task task = taskView.getTask();
taskView.getThumbnail().setThumbnail(task, thumbnailData);
@@ -764,7 +773,7 @@
* @param refreshNow Refresh immediately if it's true.
*/
public TaskView updateThumbnail(int taskId, ThumbnailData thumbnailData, boolean refreshNow) {
- TaskView taskView = getTaskView(taskId);
+ TaskView taskView = getTaskViewByTaskId(taskId);
if (taskView != null) {
taskView.getThumbnail().setThumbnail(taskView.getTask(), thumbnailData, refreshNow);
}
@@ -838,7 +847,8 @@
if (child instanceof TaskView && child != mSplitHiddenTaskView
&& child != mMovingTaskView) {
TaskView taskView = (TaskView) child;
- mHasVisibleTaskData.delete(taskView.getTaskId());
+ mHasVisibleTaskData.delete(taskView.getTaskIds()[0]);
+ taskView.setTaskViewId(-1);
mTaskViewPool.recycle(taskView);
mActionsView.updateHiddenFlags(HIDDEN_NO_TASKS, getTaskViewCount() == 0);
}
@@ -878,7 +888,8 @@
}
public void launchSideTaskInLiveTileModeForRestartedApp(int taskId) {
- if (mRunningTaskId != -1 && mRunningTaskId == taskId) {
+ int runningTaskViewId = getTaskViewIdFromTaskId(taskId);
+ if (mRunningTaskViewId != -1 && mRunningTaskViewId == runningTaskViewId) {
RemoteAnimationTargets targets = getLiveTileParams().getTargetSet();
if (targets != null && targets.findTask(taskId) != null) {
launchSideTaskInLiveTileMode(taskId, targets.apps, targets.wallpapers,
@@ -890,7 +901,7 @@
public void launchSideTaskInLiveTileMode(int taskId, RemoteAnimationTargetCompat[] apps,
RemoteAnimationTargetCompat[] wallpaper, RemoteAnimationTargetCompat[] nonApps) {
AnimatorSet anim = new AnimatorSet();
- TaskView taskView = getTaskView(taskId);
+ TaskView taskView = getTaskViewByTaskId(taskId);
if (taskView == null || !isTaskViewVisible(taskView)) {
// TODO: Refine this animation.
SurfaceTransactionApplier surfaceApplier =
@@ -967,10 +978,11 @@
== getPagedOrientationHandler().getPrimaryScroll(this);
}
- public TaskView getTaskView(int taskId) {
+ public TaskView getTaskViewByTaskId(int taskId) {
for (int i = 0; i < getTaskViewCount(); i++) {
TaskView taskView = getTaskViewAt(i);
- if (taskView.getTaskId() == taskId) {
+ int[] taskIds = taskView.getTaskIds();
+ if (taskIds[0] == taskId || taskIds[1] == taskId) {
return taskView;
}
}
@@ -1187,7 +1199,7 @@
unloadVisibleTaskData(TaskView.FLAG_UPDATE_ALL);
TaskView ignoreResetTaskView =
- mIgnoreResetTaskId == -1 ? null : getTaskView(mIgnoreResetTaskId);
+ mIgnoreResetTaskId == -1 ? null : getTaskViewByTaskId(mIgnoreResetTaskId);
final int requiredTaskCount = tasks.size();
if (getTaskViewCount() != requiredTaskCount) {
@@ -1195,7 +1207,7 @@
removeView(mClearAllButton);
}
for (int i = getTaskViewCount(); i < requiredTaskCount; i++) {
- addView(mTaskViewPool.getView());
+ addView(getTaskViewFromPool());
}
while (getTaskViewCount() > requiredTaskCount) {
removeView(getChildAt(getChildCount() - 1));
@@ -1205,6 +1217,12 @@
}
}
+ // Save running task ID if it exists before rebinding all taskViews, otherwise the task from
+ // the runningTaskView currently bound could get assigned to another TaskView
+ // TODO set these type to array and check all taskIDs? Maybe we can get away w/ only one
+ int runningTaskId = getTaskIdsForTaskViewId(mRunningTaskViewId)[0];
+ int focusedTaskId = getTaskIdsForTaskViewId(mFocusedTaskViewId)[0];
+
// Rebind and reset all task views
for (int i = requiredTaskCount - 1; i >= 0; i--) {
final int pageIndex = requiredTaskCount - i - 1 + mTaskViewStartIndex;
@@ -1213,28 +1231,40 @@
taskView.bind(task, mOrientationState);
}
+ // Keep same previous focused task
+ TaskView newFocusedTaskView = getTaskViewByTaskId(focusedTaskId);
// If the list changed, maybe the focused task doesn't exist anymore
- if (getFocusedTaskView() == null && getTaskViewCount() > 0) {
- mFocusedTaskId = getTaskViewAt(0).getTaskId();
+ if (newFocusedTaskView == null && getTaskViewCount() > 0) {
+ newFocusedTaskView = getTaskViewAt(0);
}
+ mFocusedTaskViewId = newFocusedTaskView != null ?
+ newFocusedTaskView.getTaskViewId() : -1;
updateTaskSize();
+ TaskView newRunningTaskView = null;
+ if (runningTaskId != -1) {
+ // Update mRunningTaskViewId to be the new TaskView that was assigned by binding
+ // the full list of tasks to taskViews
+ newRunningTaskView = getTaskViewByTaskId(runningTaskId);
+ mRunningTaskViewId = newRunningTaskView.getTaskViewId();
+ }
+
if (mNextPage == INVALID_PAGE) {
// Set the current page to the running task, but not if settling on new task.
- TaskView runningTaskView = getRunningTaskView();
- if (runningTaskView != null) {
- setCurrentPage(indexOfChild(runningTaskView));
+ if (runningTaskId != -1) {
+ setCurrentPage(indexOfChild(newRunningTaskView));
} else if (getTaskViewCount() > 0) {
setCurrentPage(indexOfChild(getTaskViewAt(0)));
}
} else if (currentTaskId != -1) {
- currentTaskView = getTaskView(currentTaskId);
+ currentTaskView = getTaskViewByTaskId(currentTaskId);
if (currentTaskView != null) {
setCurrentPage(indexOfChild(currentTaskView));
}
}
- if (mIgnoreResetTaskId != -1 && getTaskView(mIgnoreResetTaskId) != ignoreResetTaskView) {
+ if (mIgnoreResetTaskId != -1 &&
+ getTaskViewByTaskId(mIgnoreResetTaskId) != ignoreResetTaskView) {
// If the taskView mapping is changing, do not preserve the visuals. Since we are
// mostly preserving the first task, and new taskViews are added to the end, it should
// generally map to the same task.
@@ -1278,7 +1308,7 @@
public void resetTaskVisuals() {
for (int i = getTaskViewCount() - 1; i >= 0; i--) {
TaskView taskView = getTaskViewAt(i);
- if (mIgnoreResetTaskId != taskView.getTaskId()) {
+ if (mIgnoreResetTaskId != taskView.getTaskIds()[0]) {
taskView.resetViewTransforms();
taskView.setIconScaleAndDim(mTaskIconScaledDown ? 0 : 1);
taskView.setStableAlpha(mContentAlpha);
@@ -1632,7 +1662,7 @@
private void unloadVisibleTaskData(@TaskView.TaskDataChanges int dataChanges) {
for (int i = 0; i < mHasVisibleTaskData.size(); i++) {
if (mHasVisibleTaskData.valueAt(i)) {
- TaskView taskView = getTaskView(mHasVisibleTaskData.keyAt(i));
+ TaskView taskView = getTaskViewByTaskId(mHasVisibleTaskData.keyAt(i));
if (taskView != null) {
taskView.onTaskListVisibilityChanged(false /* visible */, dataChanges);
}
@@ -1647,7 +1677,7 @@
// they want to updated their thumbnail state
for (int i = 0; i < mHasVisibleTaskData.size(); i++) {
if (mHasVisibleTaskData.valueAt(i)) {
- TaskView taskView = getTaskView(mHasVisibleTaskData.keyAt(i));
+ TaskView taskView = getTaskViewByTaskId(mHasVisibleTaskData.keyAt(i));
if (taskView != null) {
// Poke the view again, which will trigger it to load high res if the state
// is enabled
@@ -1668,7 +1698,7 @@
setCurrentTask(-1);
mIgnoreResetTaskId = -1;
mTaskListChangeId = -1;
- mFocusedTaskId = getTaskViewCount() > 0 ? getTaskViewAt(0).getTaskId() : -1;
+ mFocusedTaskViewId = getTaskViewCount() > 0 ? getTaskViewAt(0).getTaskViewId() : -1;
if (mRecentsAnimationController != null) {
if (ENABLE_QUICKSTEP_LIVE_TILE.get() && mEnableDrawingLiveTile) {
@@ -1693,20 +1723,49 @@
});
}
- public int getRunningTaskId() {
- return mRunningTaskId;
+ public int getRunningTaskViewId() {
+ return mRunningTaskViewId;
+ }
+
+ protected int[] getTaskIdsForRunningTaskView() {
+ return getTaskIdsForTaskViewId(mRunningTaskViewId);
+ }
+
+ private int[] getTaskIdsForTaskViewId(int taskViewId) {
+ // For now 2 distinct task IDs is max for split screen
+ TaskView runningTaskView = getTaskViewFromTaskViewId(taskViewId);
+ if (runningTaskView == null) {
+ return INVALID_TASK_IDS;
+ }
+
+ return runningTaskView.getTaskIds();
}
public @Nullable TaskView getRunningTaskView() {
- return getTaskView(mRunningTaskId);
- }
-
- public int getRunningTaskIndex() {
- return getTaskIndexForId(mRunningTaskId);
+ return getTaskViewFromTaskViewId(mRunningTaskViewId);
}
public @Nullable TaskView getFocusedTaskView() {
- return getTaskView(mFocusedTaskId);
+ return getTaskViewFromTaskViewId(mFocusedTaskViewId);
+ }
+
+ private TaskView getTaskViewFromTaskViewId(int taskViewId) {
+ if (taskViewId == -1) {
+ return null;
+ }
+
+ for (int i = 0; i < getTaskViewCount(); i++) {
+ TaskView taskView = getTaskViewAt(i);
+ if (taskView.getTaskViewId() == taskViewId) {
+ return taskView;
+ }
+ }
+ return null;
+ }
+
+ public int getRunningTaskIndex() {
+ TaskView taskView = getRunningTaskView();
+ return taskView == null ? -1 : indexOfChild(taskView);
}
protected @Nullable TaskView getHomeTaskView() {
@@ -1714,11 +1773,27 @@
}
/**
+ * Handle the edge case where Recents could increment task count very high over long
+ * period of device usage. Probably will never happen, but meh.
+ */
+ private TaskView getTaskViewFromPool() {
+ TaskView taskView = mTaskViewPool.getView();
+ taskView.setTaskViewId(mTaskViewIdCount);
+ if (mTaskViewIdCount == Integer.MAX_VALUE) {
+ mTaskViewIdCount = 0;
+ } else {
+ mTaskViewIdCount++;
+ }
+
+ return taskView;
+ }
+
+ /**
* Get the index of the task view whose id matches {@param taskId}.
* @return -1 if there is no task view for the task id, else the index of the task view.
*/
public int getTaskIndexForId(int taskId) {
- TaskView tv = getTaskView(taskId);
+ TaskView tv = getTaskViewByTaskId(taskId);
return tv == null ? -1 : indexOfChild(tv);
}
@@ -1858,7 +1933,7 @@
* Returns true if we should add a stub taskView for the running task id
*/
protected boolean shouldAddStubTaskView(RunningTaskInfo runningTaskInfo) {
- return runningTaskInfo != null && getTaskView(runningTaskInfo.taskId) == null;
+ return runningTaskInfo != null && getTaskViewByTaskId(runningTaskInfo.taskId) == null;
}
/**
@@ -1868,10 +1943,12 @@
* is called. Also scrolls the view to this task.
*/
public void showCurrentTask(RunningTaskInfo runningTaskInfo) {
+ int runningTaskViewId = -1;
if (shouldAddStubTaskView(runningTaskInfo)) {
boolean wasEmpty = getChildCount() == 0;
// Add an empty view for now until the task plan is loaded and applied
- final TaskView taskView = mTaskViewPool.getView();
+ final TaskView taskView = getTaskViewFromPool();
+ runningTaskViewId = taskView.getTaskViewId();
addView(taskView, mTaskViewStartIndex);
if (wasEmpty) {
addView(mClearAllButton);
@@ -1886,12 +1963,13 @@
measure(makeMeasureSpec(getMeasuredWidth(), EXACTLY),
makeMeasureSpec(getMeasuredHeight(), EXACTLY));
layout(getLeft(), getTop(), getRight(), getBottom());
+ } else if (getTaskViewByTaskId(runningTaskInfo.taskId) != null) {
+ runningTaskViewId = getTaskViewByTaskId(runningTaskInfo.taskId).getTaskViewId();
}
boolean runningTaskTileHidden = mRunningTaskTileHidden;
- int runningTaskId = runningTaskInfo == null ? -1 : runningTaskInfo.taskId;
- setCurrentTask(runningTaskId);
- mFocusedTaskId = runningTaskId;
+ setCurrentTask(runningTaskViewId);
+ mFocusedTaskViewId = runningTaskViewId;
setCurrentPage(getRunningTaskIndex());
setRunningTaskViewShowScreenshot(false);
setRunningTaskHidden(runningTaskTileHidden);
@@ -1905,22 +1983,27 @@
/**
* Sets the running task id, cleaning up the old running task if necessary.
*/
- public void setCurrentTask(int runningTaskId) {
- if (mRunningTaskId == runningTaskId) {
+ public void setCurrentTask(int runningTaskViewId) {
+ if (mRunningTaskViewId == runningTaskViewId) {
return;
}
- if (mRunningTaskId != -1) {
+ if (mRunningTaskViewId != -1) {
// Reset the state on the old running task view
setTaskIconScaledDown(false);
setRunningTaskViewShowScreenshot(true);
setRunningTaskHidden(false);
}
- mRunningTaskId = runningTaskId;
+ mRunningTaskViewId = runningTaskViewId;
+ }
+
+ private int getTaskViewIdFromTaskId(int taskId) {
+ TaskView taskView = getTaskViewByTaskId(taskId);
+ return taskView != null ? taskView.getTaskViewId() : -1;
}
/**
- * Hides the tile associated with {@link #mRunningTaskId}
+ * Hides the tile associated with {@link #mRunningTaskViewId}
*/
public void setRunningTaskHidden(boolean isHidden) {
mRunningTaskTileHidden = isHidden;
@@ -2001,7 +2084,7 @@
float bottomAccumulatedTranslationX = 0;
// Contains whether the child index is in top or bottom of grid (for non-focused task)
- // Different from mTopRowIdSet, which contains the taskId of what task is in top row
+ // Different from mTopRowIdSet, which contains the taskViewId of what task is in top row
IntSet topSet = new IntSet();
IntSet bottomSet = new IntSet();
@@ -2053,8 +2136,8 @@
// calculate the distance focused task need to shift.
focusedTaskShift += mIsRtl ? taskWidthAndSpacing : -taskWidthAndSpacing;
}
- int taskId = taskView.getTaskId();
- boolean isTopRow = isTaskDismissal ? mTopRowIdSet.contains(taskId)
+ int taskViewId = taskView.getTaskViewId();
+ boolean isTopRow = isTaskDismissal ? mTopRowIdSet.contains(taskViewId)
: topRowWidth <= bottomRowWidth;
if (isTopRow) {
if (homeTaskView != null && nextFocusedTaskView == null) {
@@ -2064,7 +2147,7 @@
topRowWidth += taskWidthAndSpacing;
}
topSet.add(i);
- mTopRowIdSet.add(taskId);
+ mTopRowIdSet.add(taskViewId);
taskView.setGridTranslationY(mTaskGridVerticalDiff);
@@ -2189,13 +2272,13 @@
if (taskView1 == null || taskView2 == null) {
return false;
}
- int taskId1 = taskView1.getTaskId();
- int taskId2 = taskView2.getTaskId();
- if (taskId1 == mFocusedTaskId || taskId2 == mFocusedTaskId) {
+ int taskViewId1 = taskView1.getTaskViewId();
+ int taskViewId2 = taskView2.getTaskViewId();
+ if (taskViewId1 == mFocusedTaskViewId || taskViewId2 == mFocusedTaskViewId) {
return false;
}
- return (mTopRowIdSet.contains(taskId1) && mTopRowIdSet.contains(taskId2)) || (
- !mTopRowIdSet.contains(taskId1) && !mTopRowIdSet.contains(taskId2));
+ return (mTopRowIdSet.contains(taskViewId1) && mTopRowIdSet.contains(taskViewId2)) || (
+ !mTopRowIdSet.contains(taskViewId1) && !mTopRowIdSet.contains(taskViewId2));
}
/**
@@ -2342,7 +2425,8 @@
boolean showAsGrid = showAsGrid();
int taskCount = getTaskViewCount();
int dismissedIndex = indexOfChild(dismissedTaskView);
- int dismissedTaskId = dismissedTaskView.getTaskId();
+ int dismissedTaskId = dismissedTaskView.getTaskIds()[0];
+ int dismissedTaskViewId = dismissedTaskView.getTaskViewId();
// Grid specific properties.
boolean isFocusedTaskDismissed = false;
@@ -2359,7 +2443,7 @@
if (showAsGrid) {
dismissedTaskWidth = dismissedTaskView.getLayoutParams().width + mPageSpacing;
- isFocusedTaskDismissed = dismissedTaskId == mFocusedTaskId;
+ isFocusedTaskDismissed = dismissedTaskViewId == mFocusedTaskViewId;
if (isFocusedTaskDismissed) {
nextFocusedTaskFromTop =
mTopRowIdSet.size() > 0 && mTopRowIdSet.size() >= (taskCount - 1) / 2f;
@@ -2369,7 +2453,7 @@
if (taskView == dismissedTaskView) {
continue;
}
- boolean isTopRow = mTopRowIdSet.contains(taskView.getTaskId());
+ boolean isTopRow = mTopRowIdSet.contains(taskView.getTaskViewId());
if ((nextFocusedTaskFromTop && isTopRow
|| (!nextFocusedTaskFromTop && !isTopRow))) {
nextFocusedTaskView = taskView;
@@ -2548,7 +2632,7 @@
mCurrentPageScrollDiff = primaryScroll - currentPageScroll;
}
removeViewInLayout(dismissedTaskView);
- mTopRowIdSet.remove(dismissedTaskId);
+ mTopRowIdSet.remove(dismissedTaskViewId);
if (taskCount == 1) {
removeViewInLayout(mClearAllButton);
@@ -2556,8 +2640,8 @@
} else {
// Update focus task and its size.
if (finalNextFocusedTaskView != null) {
- mFocusedTaskId = finalNextFocusedTaskView.getTaskId();
- mTopRowIdSet.remove(mFocusedTaskId);
+ mFocusedTaskViewId = finalNextFocusedTaskView.getTaskViewId();
+ mTopRowIdSet.remove(mFocusedTaskViewId);
finalNextFocusedTaskView.animateIconScaleAndDimIntoView();
}
updateTaskSize(true);
@@ -2676,7 +2760,7 @@
@UiThread
private void dismissTask(int taskId) {
- TaskView taskView = getTaskView(taskId);
+ TaskView taskView = getTaskViewByTaskId(taskId);
if (taskView == null) {
return;
}
@@ -2755,9 +2839,12 @@
}
alpha = Utilities.boundToRange(alpha, 0, 1);
mContentAlpha = alpha;
+ int runningTaskId = getTaskIdsForRunningTaskView()[0];
for (int i = getTaskViewCount() - 1; i >= 0; i--) {
TaskView child = getTaskViewAt(i);
- if (!mRunningTaskTileHidden || child.getTaskId() != mRunningTaskId) {
+ int[] childTaskIds = child.getTaskIds();
+ if (!mRunningTaskTileHidden ||
+ (childTaskIds[0] != runningTaskId && childTaskIds[1] != runningTaskId)) {
child.setStableAlpha(alpha);
}
}
@@ -2916,8 +3003,8 @@
float modalOffset = ACCEL_0_75.getInterpolation(mTaskModalness);
int count = getChildCount();
- TaskView runningTask = mRunningTaskId == -1 || !mRunningTaskTileHidden
- ? null : getTaskView(mRunningTaskId);
+ TaskView runningTask = mRunningTaskViewId == -1 || !mRunningTaskTileHidden
+ ? null : getRunningTaskView();
int midpoint = runningTask == null ? -1 : indexOfChild(runningTask);
int modalMidpoint = getCurrentPage();
@@ -3884,8 +3971,9 @@
}
return;
}
- switchToScreenshot(mRunningTaskId == -1 ? null
- : mRecentsAnimationController.screenshotTask(mRunningTaskId), onFinishRunnable);
+ int runningTaskId = getTaskIdsForRunningTaskView()[0];
+ switchToScreenshot(mRunningTaskViewId == -1 ? null
+ : mRecentsAnimationController.screenshotTask(runningTaskId), onFinishRunnable);
}
/**
diff --git a/quickstep/src/com/android/quickstep/views/TaskView.java b/quickstep/src/com/android/quickstep/views/TaskView.java
index 5608fc7..ec08280 100644
--- a/quickstep/src/com/android/quickstep/views/TaskView.java
+++ b/quickstep/src/com/android/quickstep/views/TaskView.java
@@ -366,6 +366,9 @@
private float mModalness = 0;
private float mStableAlpha = 1;
+ private int mTaskViewId = -1;
+ private final int[] mTaskIdContainer = new int[]{-1, -1};
+
private boolean mShowScreenshot;
// The current background requests to load the task thumbnail and icon
@@ -401,6 +404,14 @@
setOutlineProvider(mOutlineProvider);
}
+ public void setTaskViewId(int id) {
+ this.mTaskViewId = id;
+ }
+
+ public int getTaskViewId() {
+ return mTaskViewId;
+ }
+
/**
* Builds proto for logging
*/
@@ -506,6 +517,7 @@
public void bind(Task task, RecentsOrientedState orientedState) {
cancelPendingLoadTasks();
mTask = task;
+ mTaskIdContainer[0] = mTask.key.id;
mSnapshotView.bind(task);
setOrientationState(orientedState);
}
@@ -514,8 +526,12 @@
return mTask;
}
- public int getTaskId() {
- return mTask != null && mTask.key != null ? mTask.key.id : -1;
+ /**
+ * @return integer array of two elements to be size consistent with max number of tasks possible
+ * index 0 will contain the taskId, index 1 will be -1 indicating a null taskID value
+ */
+ public int[] getTaskIds() {
+ return mTaskIdContainer;
}
public TaskThumbnailView getThumbnail() {
@@ -598,7 +614,8 @@
ActivityOptionsWrapper opts = mActivity.getActivityLaunchOptions(this, null);
if (ActivityManagerWrapper.getInstance()
.startActivityFromRecents(mTask.key, opts.options)) {
- if (ENABLE_QUICKSTEP_LIVE_TILE.get() && getRecentsView().getRunningTaskId() != -1) {
+ if (ENABLE_QUICKSTEP_LIVE_TILE.get() &&
+ getRecentsView().getRunningTaskViewId() != -1) {
// Return a fresh callback in the live tile case, so that it's not accidentally
// triggered by QuickstepTransitionManager.AppLaunchAnimationRunner.
RunnableList callbackList = new RunnableList();
diff --git a/quickstep/tests/src/com/android/quickstep/AbstractQuickStepTest.java b/quickstep/tests/src/com/android/quickstep/AbstractQuickStepTest.java
index dc73a9a..ca47de3 100644
--- a/quickstep/tests/src/com/android/quickstep/AbstractQuickStepTest.java
+++ b/quickstep/tests/src/com/android/quickstep/AbstractQuickStepTest.java
@@ -82,6 +82,6 @@
RecentsView recentsView = launcher.getOverviewPanel();
return recentsView.getSizeStrategy().isInLiveTileMode()
- && recentsView.getRunningTaskId() != -1;
+ && recentsView.getRunningTaskViewId() != -1;
}
}
diff --git a/quickstep/tests/src/com/android/quickstep/FallbackRecentsTest.java b/quickstep/tests/src/com/android/quickstep/FallbackRecentsTest.java
index b36baf8..e4f5a19 100644
--- a/quickstep/tests/src/com/android/quickstep/FallbackRecentsTest.java
+++ b/quickstep/tests/src/com/android/quickstep/FallbackRecentsTest.java
@@ -99,6 +99,7 @@
mDevice = UiDevice.getInstance(instrumentation);
mDevice.setOrientationNatural();
mLauncher = new LauncherInstrumentation();
+ mLauncher.enableDebugTracing();
// b/143488140
//mLauncher.enableCheckEventsForSuccessfulGestures();
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index 242e3e3..eb3f94c 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -353,7 +353,7 @@
} else if (focus == View.FOCUS_RIGHT) {
nextPage = currentPage + panelCount;
} else {
- // no neighbours to those direction
+ // no neighbours to other directions
return new IntSet();
}
nextPage = validateNewPage(nextPage);
@@ -362,12 +362,7 @@
return new IntSet();
}
- int pageCount = getPageCount();
- IntSet neighbourIndices = new IntSet();
- for (int page = nextPage; page < nextPage + panelCount && page < pageCount; page++) {
- neighbourIndices.add(page);
- }
- return neighbourIndices;
+ return getPageIndices(nextPage);
}
/**
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 9a8b80d..83ca08d 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -325,6 +325,11 @@
setPageSpacing(Math.max(maxInsets, maxPadding));
}
+ updateWorkspaceScreensPadding();
+ }
+
+ private void updateWorkspaceScreensPadding() {
+ DeviceProfile grid = mLauncher.getDeviceProfile();
int paddingLeftRight = grid.cellLayoutPaddingLeftRightPx;
int paddingBottom = grid.cellLayoutBottomPaddingPx;
@@ -621,10 +626,6 @@
// created CellLayout.
CellLayout newScreen = (CellLayout) LayoutInflater.from(getContext()).inflate(
R.layout.workspace_screen, this, false /* attachToRoot */);
- DeviceProfile grid = mLauncher.getDeviceProfile();
- int paddingLeftRight = grid.cellLayoutPaddingLeftRightPx;
- int paddingBottom = grid.cellLayoutBottomPaddingPx;
- newScreen.setPadding(paddingLeftRight, 0, paddingLeftRight, paddingBottom);
mWorkspaceScreens.put(screenId, newScreen);
mScreenOrder.add(insertIndex, screenId);
@@ -633,6 +634,7 @@
mLauncher.getStateManager().getState(), newScreen, insertIndex);
updatePageScrollValues();
+ updateWorkspaceScreensPadding();
return newScreen;
}
@@ -1775,7 +1777,7 @@
boolean droppedOnOriginalCell = false;
- int snapScreen = -1;
+ boolean snappedToNewPage = false;
boolean resizeOnDrop = false;
Runnable onCompleteRunnable = null;
if (d.dragSource != this || mDragInfo == null) {
@@ -1857,11 +1859,14 @@
}
if (foundCell) {
- if (getScreenIdForPageIndex(mCurrentPage) != screenId && !hasMovedIntoHotseat) {
- snapScreen = getPageIndexForScreenId(screenId);
+ int targetScreenIndex = getPageIndexForScreenId(screenId);
+ int snapScreen = getLeftmostVisiblePageForIndex(targetScreenIndex);
+ // On large screen devices two pages can be shown at the same time, and snap
+ // isn't needed if the source and target screens appear at the same time
+ if (snapScreen != mCurrentPage && !hasMovedIntoHotseat) {
snapToPage(snapScreen);
+ snappedToNewPage = true;
}
-
final ItemInfo info = (ItemInfo) cell.getTag();
if (hasMovedLayouts) {
// Reparent the view
@@ -1953,7 +1958,7 @@
ANIMATE_INTO_POSITION_AND_DISAPPEAR;
animateWidgetDrop(info, parent, d.dragView, null, animationType, cell, false);
} else {
- int duration = snapScreen < 0 ? -1 : ADJACENT_SCREEN_DROP_DURATION;
+ int duration = snappedToNewPage ? ADJACENT_SCREEN_DROP_DURATION : -1;
mLauncher.getDragLayer().animateViewIntoPosition(d.dragView, cell, duration,
this);
}
diff --git a/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java b/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java
index 9faac5b..0fb5e77 100644
--- a/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java
+++ b/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java
@@ -188,7 +188,8 @@
private boolean itemSupportsAccessibleDrag(ItemInfo item) {
if (item instanceof WorkspaceItemInfo) {
// Support the action unless the item is in a context menu.
- return item.screenId >= 0 && item.container != Favorites.CONTAINER_HOTSEAT_PREDICTION;
+ return (item.screenId >= 0 || item.screenId == Workspace.LEFT_PANEL_ID)
+ && item.container != Favorites.CONTAINER_HOTSEAT_PREDICTION;
}
return (item instanceof LauncherAppWidgetInfo)
|| (item instanceof FolderInfo);
diff --git a/src/com/android/launcher3/testing/TestProtocol.java b/src/com/android/launcher3/testing/TestProtocol.java
index 65bec25..75c0d03 100644
--- a/src/com/android/launcher3/testing/TestProtocol.java
+++ b/src/com/android/launcher3/testing/TestProtocol.java
@@ -112,4 +112,5 @@
public static final String PERMANENT_DIAG_TAG = "TaplTarget";
public static final String WORK_PROFILE_REMOVED = "b/159671700";
public static final String FALLBACK_ACTIVITY_NO_SET = "b/181019015";
+ public static final String THIRD_PARTY_LAUNCHER_NOT_SET = "b/187080582";
}
diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
index bf4eba0..dcb6dc1 100644
--- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
+++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
@@ -153,6 +153,8 @@
public static String dumpHprofData() {
String result;
if (sDumpWasGenerated) {
+ Log.d("b/195319692", "dump has already been generated by another test",
+ new Exception());
result = "dump has already been generated by another test";
} else {
try {
@@ -167,6 +169,7 @@
"am dumpheap " + device.getLauncherPackageName() + " " + fileName);
}
sDumpWasGenerated = true;
+ Log.d("b/195319692", "sDumpWasGenerated := true", new Exception());
result = "memory dump filename: " + fileName;
} catch (Throwable e) {
Log.e(TAG, "dumpHprofData failed", e);