From c8fcf08dfd2475dd76c72cbda7bbbd0cd946b261 Mon Sep 17 00:00:00 2001 From: Suhua Lei Date: Tue, 11 Mar 2025 00:50:28 +0000 Subject: [PATCH] Handle visibility of AddDesktopButton for overview/quickswitch This change introduces mDisallowScrollToAddDesk to handle the visibility of AddDesktopButton in overview/quickswitch. In overview, set its scroll as the first task; in quick switch, set its scroll out range of [minScroll, maxScroll]. Bug: 398036110 Flag: com.android.window.flags.enable_multiple_desktops_frontend Flag: com.android.window.flags.enable_multiple_desktops_backend Test: manual quick switch Change-Id: I5fada0c4c5bccc5572b458da9970e3524087508d --- .../fallback/FallbackRecentsView.java | 1 + .../quickstep/views/LauncherRecentsView.java | 4 +++ .../android/quickstep/views/RecentsView.java | 28 ++++++++++++++++++- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java b/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java index f426bf5124..12c043ef82 100644 --- a/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java +++ b/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java @@ -302,6 +302,7 @@ public class FallbackRecentsView= 0 && addDesktopButtonIndex < outPageScrolls.length) { int firstViewIndex = getFirstViewIndex(); if (firstViewIndex >= 0 && firstViewIndex < outPageScrolls.length) { - outPageScrolls[addDesktopButtonIndex] = outPageScrolls[firstViewIndex]; + // If we can scroll to [AddDesktopButton], make its page scroll equal to + // the first [TaskView]. Otherwise, make its page scroll out of range of + // [minScroll, maxScroll]. + if (!mDisallowScrollToAddDesk) { + outPageScrolls[addDesktopButtonIndex] = outPageScrolls[firstViewIndex]; + } else { + outPageScrolls[addDesktopButtonIndex] = + outPageScrolls[firstViewIndex] + (mIsRtl ? 1 : -1); + } + } + + if (DEBUG) { + Log.d(TAG, "getPageScrolls - addDesktopButtonScroll: " + + outPageScrolls[addDesktopButtonIndex]); } } if (DEBUG) {