From 1c028b7ccb10e5083440b0ad3dbc6138cda45133 Mon Sep 17 00:00:00 2001 From: minch Date: Fri, 21 Feb 2025 16:51:43 +0000 Subject: [PATCH] Correct the page scrolls of the AddDesktopButton Do not apply the button's grid translation to its page scrolls if it is not showing as a grid,otherwise the `mCurrentPage` may not be set correctly while checking `ensureWithinScrollBounds`. Bug: 396146789 Flag: com.android.window.flags.enable_multiple_desktops_frontend Flag: com.android.window.flags.enable_multiple_desktops_backend Test: m Change-Id: Ia1378a997e681abda60fa1cb3c125660916df4c5 --- quickstep/src/com/android/quickstep/views/AddDesktopButton.kt | 3 +++ quickstep/src/com/android/quickstep/views/RecentsView.java | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/quickstep/src/com/android/quickstep/views/AddDesktopButton.kt b/quickstep/src/com/android/quickstep/views/AddDesktopButton.kt index 9f3c017fbe..99437709de 100644 --- a/quickstep/src/com/android/quickstep/views/AddDesktopButton.kt +++ b/quickstep/src/com/android/quickstep/views/AddDesktopButton.kt @@ -91,6 +91,9 @@ class AddDesktopButton @JvmOverloads constructor(context: Context, attrs: Attrib } } + protected fun getScrollAdjustment(showAsGrid: Boolean): Int = + if (showAsGrid) gridTranslationX.toInt() else 0 + private fun getBorderBounds(bounds: Rect) { bounds.set(0, 0, width, height) val outlinePadding = diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index c5a76cb067..11e65722f1 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -6243,8 +6243,8 @@ public abstract class RecentsView< int addDesktopButtonIndex = indexOfChild(mAddDesktopButton); if (addDesktopButtonIndex != -1 && addDesktopButtonIndex < outPageScrolls.length) { outPageScrolls[addDesktopButtonIndex] = - newPageScrolls[addDesktopButtonIndex] + Math.round( - mAddDesktopButton.getGridTranslationX()); + newPageScrolls[addDesktopButtonIndex] + mAddDesktopButton.getScrollAdjustment( + showAsGrid); } int lastTaskScroll = getLastTaskScroll(clearAllScroll, clearAllWidth);