diff --git a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java index bbcc8487ce..1686aaa017 100644 --- a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java @@ -511,6 +511,13 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT navButtonController.onButtonClick(BUTTON_RECENTS, v); mHitboxExtender.onRecentsButtonClicked(); }); + mRecentsButton.addOnLayoutChangeListener( + (v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> { + int[] location = v.getLocationOnScreen(); + Rect bounds = new Rect(location[0], location[1], location[0] + v.getWidth(), + location[1] + v.getHeight()); + navButtonController.onRecentsButtonLayoutChanged(bounds); + }); mPropertyHolders.add(new StatePropertyHolder(mRecentsButton, flags -> (flags & FLAG_KEYGUARD_VISIBLE) == 0 && (flags & FLAG_DISABLE_RECENTS) == 0 && !mContext.isNavBarKidsModeActive() && !mContext.isGestureNav())); diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarNavButtonController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarNavButtonController.java index 597e8b9213..786b8eae31 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarNavButtonController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarNavButtonController.java @@ -37,6 +37,7 @@ import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_S import static com.android.window.flags.Flags.predictiveBackThreeButtonNav; import android.content.Context; +import android.graphics.Rect; import android.os.Bundle; import android.os.Handler; import android.os.SystemClock; @@ -258,6 +259,13 @@ public class TaskbarNavButtonController implements TaskbarControllers.LoggableTa } } + /** + * Notifies SystemUI of the new bounds of the recents button in screen coordinates. + */ + public void onRecentsButtonLayoutChanged(Rect bounds) { + mSystemUiProxy.notifyRecentsButtonPositionChanged(bounds); + } + private boolean backRecentsLongpress(@TaskbarButton int buttonType) { mLongPressedButtons |= buttonType; return determineScreenUnpin(); diff --git a/quickstep/src/com/android/quickstep/SystemUiProxy.kt b/quickstep/src/com/android/quickstep/SystemUiProxy.kt index 9493eaba5a..b90862d2c9 100644 --- a/quickstep/src/com/android/quickstep/SystemUiProxy.kt +++ b/quickstep/src/com/android/quickstep/SystemUiProxy.kt @@ -425,6 +425,14 @@ class SystemUiProxy @Inject constructor(@ApplicationContext private val context: systemUiProxy?.notifyTaskbarAutohideSuspend(suspend) } + fun notifyRecentsButtonPositionChanged(bounds: Rect) { + executeWithErrorLog({ + "Failed call notifyRecentsButtonPositionChanged with arg: $bounds" + }) { + systemUiProxy?.notifyRecentsButtonPositionChanged(bounds) + } + } + fun takeScreenshot(request: ScreenshotRequest) = executeWithErrorLog({ "Failed call takeScreenshot" }) { systemUiProxy?.takeScreenshot(request) diff --git a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarNavButtonControllerTest.java b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarNavButtonControllerTest.java index d2e144850c..a1b341d763 100644 --- a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarNavButtonControllerTest.java +++ b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarNavButtonControllerTest.java @@ -29,6 +29,7 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import android.graphics.Rect; import android.os.Handler; import android.platform.test.annotations.RequiresFlagsEnabled; import android.platform.test.flag.junit.CheckFlagsRule; @@ -381,6 +382,14 @@ public class TaskbarNavButtonControllerTest { verify(mockSystemUiProxy, never()).onImeSwitcherPressed(); } + @Test + public void testOnRecentsButtonLayoutChanged() { + Rect rect = new Rect(10, 20, 30, 40); + mNavButtonController.init(mockTaskbarControllers); + mNavButtonController.onRecentsButtonLayoutChanged(rect); + verify(mockSystemUiProxy).notifyRecentsButtonPositionChanged(eq(rect)); + } + private void verifyKeyEvent(KeyEvent keyEvent, int action, boolean isCancelled) { assertEquals(isCancelled, keyEvent.isCanceled()); assertEquals(action, KeyEvent.ACTION_DOWN, keyEvent.getAction());