From fab598746f9d1839c26eacbcec4cdf000ec76faa Mon Sep 17 00:00:00 2001 From: Liran Binyamin Date: Mon, 10 Jul 2023 17:01:46 -0400 Subject: [PATCH] Update the expanded view height when bar is stashed When the expanded view is displayed in WMShell we use the bubble bar position to determine its height. When the bubble bar is expanded from stashed (e.g. when the first bubble is added, or when swiping up on the stashed bubble bar), the position passed into WMShell is the stashed position which results in an inaccurate height. This change passes the bubble bar X and Y offsets from the bottom corner of the screen of where the bubble bar will eventually be positioned after it is unstashed. This allows WMShell to correctly calculate the height of the expanded view so there is no overlap. This change also fixes a bug observed when a bubble is added to an empty bar, which resulted in wrong arrow position and sometimes missing expanded view. Fixes: 290636927 Fixes: 290095535 Test: manual - Reboot device and add bubble - Observe that expanded view shows, and arrow position is correct - Go to Settings -> Bubbles -> toggle off and back on - Add bubble - Observe that expanded view is displayed and arrow position is correct - Add bubbles to bubble bar - Stash bubble bar - Swipe up on the bubble bar to expand - Observe that expanded view is positioned correctly Change-Id: I9a900a2ec4a9ac72550ef94ebc8fa47e51675059 --- .../android/wm/shell/bubbles/BubbleController.java | 10 +++++----- .../android/wm/shell/bubbles/BubblePositioner.java | 13 ++++++++++--- .../src/com/android/wm/shell/bubbles/IBubbles.aidl | 3 +-- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java index 6385fd3fd811d..8def8ff1ab010 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java @@ -1075,9 +1075,9 @@ public class BubbleController implements ConfigurationChangeListener, *

This is used by external callers (launcher). */ @VisibleForTesting - public void expandStackAndSelectBubbleFromLauncher(String key, int bubbleBarXCoordinate, - int bubbleBarYCoordinate) { - mBubblePositioner.setBubbleBarPosition(bubbleBarXCoordinate, bubbleBarYCoordinate); + public void expandStackAndSelectBubbleFromLauncher(String key, int bubbleBarOffsetX, + int bubbleBarOffsetY) { + mBubblePositioner.setBubbleBarPosition(bubbleBarOffsetX, bubbleBarOffsetY); if (BubbleOverflow.KEY.equals(key)) { mBubbleData.setSelectedBubbleFromLauncher(mBubbleData.getOverflow()); @@ -2088,10 +2088,10 @@ public class BubbleController implements ConfigurationChangeListener, } @Override - public void showBubble(String key, int bubbleBarXCoordinate, int bubbleBarYCoordinate) { + public void showBubble(String key, int bubbleBarOffsetX, int bubbleBarOffsetY) { mMainExecutor.execute( () -> mController.expandStackAndSelectBubbleFromLauncher( - key, bubbleBarXCoordinate, bubbleBarYCoordinate)); + key, bubbleBarOffsetX, bubbleBarOffsetY)); } @Override diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubblePositioner.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubblePositioner.java index 6a5e3104fed52..ee6996d3d23d8 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubblePositioner.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubblePositioner.java @@ -718,9 +718,16 @@ public class BubblePositioner { mShowingInBubbleBar = showingInBubbleBar; } - /** Sets the position of the bubble bar in screen coordinates. */ - public void setBubbleBarPosition(int x, int y) { - mBubbleBarPosition.set(x, y); + /** + * Sets the position of the bubble bar in screen coordinates. + * + * @param offsetX the offset of the bubble bar from the edge of the screen on the X axis + * @param offsetY the offset of the bubble bar from the edge of the screen on the Y axis + */ + public void setBubbleBarPosition(int offsetX, int offsetY) { + mBubbleBarPosition.set( + getAvailableRect().width() - offsetX, + getAvailableRect().height() + mInsets.top + mInsets.bottom - offsetY); } /** diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/IBubbles.aidl b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/IBubbles.aidl index 59332f4be6271..351319f5fb5eb 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/IBubbles.aidl +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/IBubbles.aidl @@ -29,8 +29,7 @@ interface IBubbles { oneway void unregisterBubbleListener(in IBubblesListener listener) = 2; - oneway void showBubble(in String key, in int bubbleBarXCoordinate, - in int bubbleBarYCoordinate) = 3; + oneway void showBubble(in String key, in int bubbleBarOffsetX, in int bubbleBarOffsetY) = 3; oneway void removeBubble(in String key, in int reason) = 4;