From 24e03825cdaf9ee3b42f130a83535f9d0171730b Mon Sep 17 00:00:00 2001 From: Alex Chau Date: Thu, 22 Aug 2024 17:57:38 +0100 Subject: [PATCH] Fix wrong condition used to calculate clearAllShortTotalTranslation - We now calcualte the first task's start position, and compared against the expected position (mLastComputedTaskSize) to determine if we need extra translation for ClearAllButton - The calculation is done with `mIsRtl = true`, and only only flip +/- when applying translation - http://screen/brM3taew74Z3uZJ shows what happens without clearAllShortTotalTranslation: - Blue area is mLastComputedGridSize, green area is longRowWidth - firstTaskStart is caculated from left of grid size, adding longRowWidth - Red area is mLastComputedTaskSize, where focus task is in the middle (for grid-only-overview it's in top right) - clearAllShortTotalWidthTranslation is the yellow area Fix: 354104098 Test: With normal/largest display size, LTR/RTL, focus task /grid only Overview, swipe up with 1/2/6/7 tasks Flag: EXEMPT BUG_FIX Change-Id: I324eebc0a2b2129a4ba62d4569bc555b74140c21 --- .../src/com/android/quickstep/views/RecentsView.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index e3c52d7909..e30994fe8c 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -3273,12 +3273,12 @@ public abstract class RecentsView< longRowWidth = largeTaskWidthAndSpacing; } - if (longRowWidth < mLastComputedGridSize.width()) { - mClearAllShortTotalWidthTranslation = - (mIsRtl - ? mLastComputedTaskSize.right - : deviceProfile.widthPx - mLastComputedTaskSize.left) - - longRowWidth - deviceProfile.overviewGridSideMargin; + // 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 expectedFirstTaskStart = mLastComputedTaskSize.right; + if (firstTaskStart < expectedFirstTaskStart) { + mClearAllShortTotalWidthTranslation = expectedFirstTaskStart - firstTaskStart; clearAllShortTotalWidthTranslation = mIsRtl ? -mClearAllShortTotalWidthTranslation : mClearAllShortTotalWidthTranslation; if (snappedTaskRowWidth == longRowWidth) {