From 0e66fa854f5db2fb10f1ad014248acf933fe9c44 Mon Sep 17 00:00:00 2001 From: Liran Binyamin Date: Fri, 7 Jul 2023 12:42:59 -0400 Subject: [PATCH] Fix the spacing between bubble bar and expanded view Store the bubble bar screen coordinates directly in BubblePositioner and use that to calculate the bottom position of the expanded view. Screenshot: https://screenshot.googleplex.com/5q9VNWW3TUP9hgy Fixes: 290099589 Test: Manual - Add bubbles to the bubble bar - Expand the bubble bar - Observe that there is space between the bar and the expanded view Change-Id: I6b8f35663bb544cc54b734fd6d34bf5593206fab --- libs/WindowManager/Shell/res/values/dimen.xml | 2 -- .../wm/shell/bubbles/BubbleController.java | 10 +++--- .../wm/shell/bubbles/BubblePositioner.java | 36 ++++--------------- .../android/wm/shell/bubbles/IBubbles.aidl | 3 +- .../bubbles/bar/BubbleBarAnimationHelper.java | 4 +-- .../android/systemui/wmshell/BubblesTest.java | 2 +- 6 files changed, 18 insertions(+), 39 deletions(-) diff --git a/libs/WindowManager/Shell/res/values/dimen.xml b/libs/WindowManager/Shell/res/values/dimen.xml index 3d4b55acee39f..64fed1cacca90 100644 --- a/libs/WindowManager/Shell/res/values/dimen.xml +++ b/libs/WindowManager/Shell/res/values/dimen.xml @@ -226,8 +226,6 @@ 58dp 16dp - - 72dp 32dp 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 6880237370740..6385fd3fd811d 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,8 +1075,9 @@ public class BubbleController implements ConfigurationChangeListener, *

This is used by external callers (launcher). */ @VisibleForTesting - public void expandStackAndSelectBubbleFromLauncher(String key, boolean onLauncherHome) { - mBubblePositioner.setShowingInBubbleBar(onLauncherHome); + public void expandStackAndSelectBubbleFromLauncher(String key, int bubbleBarXCoordinate, + int bubbleBarYCoordinate) { + mBubblePositioner.setBubbleBarPosition(bubbleBarXCoordinate, bubbleBarYCoordinate); if (BubbleOverflow.KEY.equals(key)) { mBubbleData.setSelectedBubbleFromLauncher(mBubbleData.getOverflow()); @@ -2087,9 +2088,10 @@ public class BubbleController implements ConfigurationChangeListener, } @Override - public void showBubble(String key, boolean onLauncherHome) { + public void showBubble(String key, int bubbleBarXCoordinate, int bubbleBarYCoordinate) { mMainExecutor.execute( - () -> mController.expandStackAndSelectBubbleFromLauncher(key, onLauncherHome)); + () -> mController.expandStackAndSelectBubbleFromLauncher( + key, bubbleBarXCoordinate, bubbleBarYCoordinate)); } @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 cb08f93a9efa8..6a5e3104fed52 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 @@ -22,6 +22,7 @@ import android.content.Context; import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.Insets; +import android.graphics.Point; import android.graphics.PointF; import android.graphics.Rect; import android.graphics.RectF; @@ -102,10 +103,7 @@ public class BubblePositioner { private int[] mPaddings = new int[4]; private boolean mShowingInBubbleBar; - private boolean mBubblesOnHome; - private int mBubbleBarSize; - private int mBubbleBarHomeAdjustment; - private final PointF mBubbleBarPosition = new PointF(); + private final Point mBubbleBarPosition = new Point(); public BubblePositioner(Context context, WindowManager windowManager) { mContext = context; @@ -166,11 +164,9 @@ public class BubblePositioner { mSpacingBetweenBubbles = res.getDimensionPixelSize(R.dimen.bubble_spacing); mDefaultMaxBubbles = res.getInteger(R.integer.bubbles_max_rendered); mExpandedViewPadding = res.getDimensionPixelSize(R.dimen.bubble_expanded_view_padding); - mBubbleBarHomeAdjustment = mExpandedViewPadding / 2; mBubblePaddingTop = res.getDimensionPixelSize(R.dimen.bubble_padding_top); mBubbleOffscreenAmount = res.getDimensionPixelSize(R.dimen.bubble_stack_offscreen); mStackOffset = res.getDimensionPixelSize(R.dimen.bubble_stack_offset); - mBubbleBarSize = res.getDimensionPixelSize(R.dimen.bubblebar_size); if (mShowingInBubbleBar) { mExpandedViewLargeScreenWidth = isLandscape() @@ -722,11 +718,9 @@ public class BubblePositioner { mShowingInBubbleBar = showingInBubbleBar; } - /** - * Sets whether bubbles are showing on launcher home, in which case positions are different. - */ - public void setBubblesOnHome(boolean bubblesOnHome) { - mBubblesOnHome = bubblesOnHome; + /** Sets the position of the bubble bar in screen coordinates. */ + public void setBubbleBarPosition(int x, int y) { + mBubbleBarPosition.set(x, y); } /** @@ -747,11 +741,7 @@ public class BubblePositioner { /** The bottom position of the expanded view when showing above the bubble bar. */ public int getExpandedViewBottomForBubbleBar() { - return getAvailableRect().height() - + mInsets.top - - mBubbleBarSize - - mExpandedViewPadding - - getBubbleBarHomeAdjustment(); + return mBubbleBarPosition.y - mExpandedViewPadding; } /** @@ -764,19 +754,7 @@ public class BubblePositioner { /** * Returns the on screen co-ordinates of the bubble bar. */ - public PointF getBubbleBarPosition() { - mBubbleBarPosition.set(getAvailableRect().width() - mBubbleBarSize, - getAvailableRect().height() - mBubbleBarSize - - mExpandedViewPadding - getBubbleBarHomeAdjustment()); + public Point getBubbleBarPosition() { return mBubbleBarPosition; } - - /** - * When bubbles are shown on launcher home, there's an extra bit of padding that needs to - * be applied between the expanded view and the bubble bar. This returns the adjustment value - * if bubbles are showing on home. - */ - private int getBubbleBarHomeAdjustment() { - return mBubblesOnHome ? mBubbleBarHomeAdjustment : 0; - } } 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 20ae8469f431c..59332f4be6271 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,7 +29,8 @@ interface IBubbles { oneway void unregisterBubbleListener(in IBubblesListener listener) = 2; - oneway void showBubble(in String key, in boolean onLauncherHome) = 3; + oneway void showBubble(in String key, in int bubbleBarXCoordinate, + in int bubbleBarYCoordinate) = 3; oneway void removeBubble(in String key, in int reason) = 4; diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarAnimationHelper.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarAnimationHelper.java index e97390d3a86e3..b3602b30072d7 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarAnimationHelper.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarAnimationHelper.java @@ -21,7 +21,7 @@ import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ValueAnimator; import android.content.Context; -import android.graphics.PointF; +import android.graphics.Point; import android.util.Log; import android.widget.FrameLayout; @@ -136,7 +136,7 @@ public class BubbleBarAnimationHelper { bev.setVisibility(VISIBLE); // Set the pivot point for the scale, so the view animates out from the bubble bar. - PointF bubbleBarPosition = mPositioner.getBubbleBarPosition(); + Point bubbleBarPosition = mPositioner.getBubbleBarPosition(); mExpandedViewContainerMatrix.setScale( 1f - EXPANDED_VIEW_ANIMATE_SCALE_AMOUNT, 1f - EXPANDED_VIEW_ANIMATE_SCALE_AMOUNT, diff --git a/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java b/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java index ef12b2af3a663..4839eeba21247 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java @@ -1996,7 +1996,7 @@ public class BubblesTest extends SysuiTestCase { FakeBubbleStateListener bubbleStateListener = new FakeBubbleStateListener(); mBubbleController.registerBubbleStateListener(bubbleStateListener); - mBubbleController.expandStackAndSelectBubbleFromLauncher(mBubbleEntry.getKey(), true); + mBubbleController.expandStackAndSelectBubbleFromLauncher(mBubbleEntry.getKey(), 500, 1000); assertThat(mBubbleController.getLayerView().isExpanded()).isTrue();