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
This commit is contained in:
Alex Chau
2024-08-22 17:57:38 +01:00
parent 4609d53ecf
commit 24e03825cd
@@ -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) {