From ee082ce6e895637f3637ef69232c4a9103106c8c Mon Sep 17 00:00:00 2001 From: Alex Chau Date: Tue, 4 Feb 2025 18:11:36 +0000 Subject: [PATCH] Fix Home->Overview grid task not in top-right - Use expectedCurrentTaskView's position to calculate if we should add extra gap between clear all button, instead of using the right most task's position; this fixed the case where current task is not the right most task e.g. grid task and desktop task - The accumulated row width to expectedCurrentTaskView is tracked in the udpateGridProperties loop, and used to calculate the position of the expected position of expectedCurrentTaskView from ClearAllButton - With this new calculation we no longer needs to adjust longRowWidth when there are onlg large tile tasks Fix: 391306182 Test: With and without grid-only Overview, test both home and app to Overview with 0-5 tasks with a desktop task; repeat for RTL Flag: EXEMPT BUG_FIX Change-Id: I324208c7e063c8b043815291cc0fef7beec884b6 --- .../android/quickstep/views/RecentsView.java | 36 ++++++++++++------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index a8f9dd4fe3..72ddbdae30 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -241,8 +241,8 @@ import com.android.wm.shell.shared.desktopmode.DesktopModeTransitionSource; import kotlin.Unit; import kotlin.collections.CollectionsKt; - import kotlin.jvm.functions.Function0; + import kotlinx.coroutines.CoroutineScope; import java.util.ArrayList; @@ -3220,6 +3220,7 @@ public abstract class RecentsView< int topRowWidth = 0; int bottomRowWidth = 0; + int largeTileRowWidth = 0; float topAccumulatedTranslationX = 0; float bottomAccumulatedTranslationX = 0; @@ -3230,9 +3231,12 @@ public abstract class RecentsView< int focusedTaskViewShift = 0; int largeTaskWidthAndSpacing = 0; int snappedTaskRowWidth = 0; + int expectedCurrentTaskRowWidth = 0; int snappedPage = isKeyboardTaskFocusPending() ? mKeyboardTaskFocusIndex : getNextPage(); TaskView snappedTaskView = getTaskViewAt(snappedPage); TaskView homeTaskView = getHomeTaskView(); + TaskView expectedCurrentTaskView = mUtils.getExpectedCurrentTask(getFocusedTaskView(), + getRunningTaskView()); TaskView nextFocusedTaskView = null; // Don't clear the top row, if the user has dismissed a task, to maintain the task order. @@ -3271,6 +3275,7 @@ public abstract class RecentsView< if (!(taskView instanceof DesktopTaskView && isSplitSelectionActive())) { topRowWidth += taskWidthAndSpacing; bottomRowWidth += taskWidthAndSpacing; + largeTileRowWidth += taskWidthAndSpacing; } gridTranslation += focusedTaskViewShift; gridTranslation += mIsRtl ? taskWidthAndSpacing : -taskWidthAndSpacing; @@ -3282,8 +3287,10 @@ public abstract class RecentsView< largeTaskWidthAndSpacing = taskWidthAndSpacing; if (taskView == snappedTaskView) { - // If focused task is snapped, the row width is just task width and spacing. - snappedTaskRowWidth = taskWidthAndSpacing; + snappedTaskRowWidth = largeTileRowWidth; + } + if (taskView == expectedCurrentTaskView) { + expectedCurrentTaskRowWidth = largeTileRowWidth; } } else { if (encounteredLastLargeTaskView) { @@ -3352,8 +3359,12 @@ public abstract class RecentsView< lastBottomTaskViews.add(taskView); lastTopTaskViews.clear(); } + int taskViewRowWidth = isTopRow ? topRowWidth : bottomRowWidth; if (taskView == snappedTaskView) { - snappedTaskRowWidth = isTopRow ? topRowWidth : bottomRowWidth; + snappedTaskRowWidth = taskViewRowWidth; + } + if (taskView == expectedCurrentTaskView) { + expectedCurrentTaskRowWidth = taskViewRowWidth; } } gridTranslations.put(taskView, gridTranslation); @@ -3394,17 +3405,16 @@ public abstract class RecentsView< float clearAllShortTotalWidthTranslation = 0; int longRowWidth = Math.max(topRowWidth, bottomRowWidth); - // If Recents contains only large task sizes, it should only consider 1 large size - // for ClearAllButton translation. The space at the left side of the large task will be - // empty and it should be move ClearAllButton further away as well. - // TODO(b/359573248): Validate the translation for ClearAllButton for grid only. - if (enableLargeDesktopWindowingTile() && largeTasksCount == getTaskViewCount()) { - longRowWidth = largeTaskWidthAndSpacing; - } - // If first task is not in the expected position (mLastComputedTaskSize) and being too close // to ClearAllButton, then apply extra translation to ClearAllButton. - int firstTaskStart = mLastComputedGridSize.left + longRowWidth; + int rowWidthAfterExpectedCurrentTask = longRowWidth - expectedCurrentTaskRowWidth; + int expectedCurrentTaskWidthAndSpacing = + (expectedCurrentTaskView != null + ? expectedCurrentTaskView.getLayoutParams().width + : 0 + ) + mPageSpacing; + int firstTaskStart = mLastComputedGridSize.left + rowWidthAfterExpectedCurrentTask + + expectedCurrentTaskWidthAndSpacing; int expectedFirstTaskStart = mLastComputedTaskSize.right; if (firstTaskStart < expectedFirstTaskStart) { mClearAllShortTotalWidthTranslation = expectedFirstTaskStart - firstTaskStart;