From 21ac8f145106c8618cc689078ac29eb41cf85320 Mon Sep 17 00:00:00 2001 From: Jordan Silva Date: Wed, 25 Sep 2024 15:16:16 -0300 Subject: [PATCH] Fix grid task dismiss animation when desktop large tile is enabled (1/4) - Fix bottom grid row size in createTaskDismissAnimation to subtract all large tiles from bottom row count. This fixes the animation when dismissing a focused and a bottom row task turns into a focused task. - Fix when snapping to last task, snap to focused task page instead of INVALID_PAGE (-1). This prevents snapping to a wrong page (DesktopTask page) when last grid task is dismissed. Bug: 353948136 Bug: 353948182 Flag: com.android.launcher3.enable_large_desktop_windowing_tile Test: OverviewDesktopTaskImageTest Change-Id: Ib4b0453eb6b99855615b22fe842ccbe1205c962d --- .../android/quickstep/util/RecentsViewUtils.kt | 3 +++ .../com/android/quickstep/views/RecentsView.java | 16 ++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/quickstep/src/com/android/quickstep/util/RecentsViewUtils.kt b/quickstep/src/com/android/quickstep/util/RecentsViewUtils.kt index be1af64f02..e70372fb79 100644 --- a/quickstep/src/com/android/quickstep/util/RecentsViewUtils.kt +++ b/quickstep/src/com/android/quickstep/util/RecentsViewUtils.kt @@ -66,6 +66,9 @@ class RecentsViewUtils { fun getLargeTaskViewIds(taskViews: Iterable): List = taskViews.filter { it.isLargeTile }.map { it.taskViewId } + /** Counts [TaskView]s that are large tiles. */ + fun getLargeTileCount(taskViews: Iterable): Int = taskViews.count { it.isLargeTile } + /** * Returns the first TaskView that should be displayed as a large tile. * diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index da68a03c56..891bb4ae4c 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -3672,8 +3672,8 @@ public abstract class RecentsView< float longGridRowWidthDiff = 0; int topGridRowSize = mTopRowIdSet.size(); - int bottomGridRowSize = taskCount - mTopRowIdSet.size() - - (enableGridOnlyOverview() ? 0 : 1); + int numLargeTiles = mUtils.getLargeTileCount(getTaskViews()); + int bottomGridRowSize = taskCount - mTopRowIdSet.size() - numLargeTiles; boolean topRowLonger = topGridRowSize > bottomGridRowSize; boolean bottomRowLonger = bottomGridRowSize > topGridRowSize; boolean dismissedTaskFromTop = mTopRowIdSet.contains(dismissedTaskViewId); @@ -3972,12 +3972,12 @@ public abstract class RecentsView< final boolean finalCloseGapBetweenClearAll = closeGapBetweenClearAll; final boolean finalSnapToLastTask = snapToLastTask; final boolean finalIsFocusedTaskDismissed = isFocusedTaskDismissed; - mPendingAnimation.addEndListener(new Consumer() { + mPendingAnimation.addEndListener(new Consumer<>() { @Override public void accept(Boolean success) { if (mEnableDrawingLiveTile && dismissedTaskView.isRunningTask() && success) { finishRecentsAnimation(true /* toRecents */, false /* shouldPip */, - () -> onEnd(success)); + () -> onEnd(true)); } else { onEnd(success); } @@ -4147,6 +4147,14 @@ public abstract class RecentsView< // If snapping to last task, find the last task after dismissal. pageToSnapTo = indexOfChild( getLastGridTaskView(topRowIdArray, bottomRowIdArray)); + + if (pageToSnapTo == INVALID_PAGE) { + // Snap to latest large tile page after dismissing the + // last grid task. This will prevent snapping to page 0 when + // desktop task is visible as large tile. + pageToSnapTo = indexOfChild( + mUtils.getLastLargeTaskView(getTaskViews())); + } } else if (taskViewIdToSnapTo != -1) { // If snapping to another page due to indices rearranging, find // the new index after dismissal & rearrange using the task view id.