From 51a6c921744ca18cbe9e6dd34711089d418522c2 Mon Sep 17 00:00:00 2001 From: Vinit Nayak Date: Tue, 27 Jul 2021 18:28:10 -0700 Subject: [PATCH] Migrate from using taskIDs to taskViewIDs in RecentsView * Follow up CL coming to introduce a TaskView that can have multiple Tasks, so a taskID won't be particularly useful in that scenario. Bug: 192292305 Test: Manual, w/ and w/o live tile Change-Id: I1900b999ac51aa99923239f2af400c90c71c3dae --- .../quickstep/LauncherActivityInterface.java | 2 +- .../com/android/quickstep/TaskViewUtils.java | 2 +- .../fallback/FallbackRecentsView.java | 14 +- .../android/quickstep/views/RecentsView.java | 216 ++++++++++++------ .../com/android/quickstep/views/TaskView.java | 23 +- .../quickstep/AbstractQuickStepTest.java | 2 +- 6 files changed, 183 insertions(+), 76 deletions(-) diff --git a/quickstep/src/com/android/quickstep/LauncherActivityInterface.java b/quickstep/src/com/android/quickstep/LauncherActivityInterface.java index 5deb75eaec..d91d5b06f9 100644 --- a/quickstep/src/com/android/quickstep/LauncherActivityInterface.java +++ b/quickstep/src/com/android/quickstep/LauncherActivityInterface.java @@ -189,7 +189,7 @@ public final class LauncherActivityInterface extends 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/TaskViewUtils.java b/quickstep/src/com/android/quickstep/TaskViewUtils.java index 07d221c2d0..b5da097c31 100644 --- a/quickstep/src/com/android/quickstep/TaskViewUtils.java +++ b/quickstep/src/com/android/quickstep/TaskViewUtils.java @@ -139,7 +139,7 @@ public final class TaskViewUtils { // 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/fallback/FallbackRecentsView.java b/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java index 540a9cafc0..64a428faf6 100644 --- a/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java +++ b/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java @@ -95,7 +95,7 @@ public class FallbackRecentsView extends RecentsView mTaskViewPool; private final TaskOverlayFactory mTaskOverlayFactory; @@ -441,7 +444,7 @@ public abstract class RecentsView requiredTaskCount) { removeView(getChildAt(getChildCount() - 1)); @@ -1205,6 +1217,12 @@ public abstract class RecentsView= 0; i--) { final int pageIndex = requiredTaskCount - i - 1 + mTaskViewStartIndex; @@ -1213,28 +1231,40 @@ public abstract class RecentsView 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 abstract class RecentsView= 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 @@ public abstract class RecentsView 0 ? getTaskViewAt(0).getTaskId() : -1; + mFocusedTaskViewId = getTaskViewCount() > 0 ? getTaskViewAt(0).getTaskViewId() : -1; if (mRecentsAnimationController != null) { if (ENABLE_QUICKSTEP_LIVE_TILE.get() && mEnableDrawingLiveTile) { @@ -1693,32 +1723,77 @@ public abstract class RecentsView 0 && mTopRowIdSet.size() >= (taskCount - 1) / 2f; @@ -2369,7 +2453,7 @@ public abstract class RecentsView= 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 @@ public abstract class RecentsView