Update BubblePositioner to have some things for bubble bar
- whether bubbles are showing in the bubble bar
- whether bubbles are showing on launcher home in the bubble bar
- the size of the bubble bar (needs to be in sync with launcher)
- the sizing for the expanded view when bubbles are in the bubble bar
Currently everything is unused but will be used in future CLs.
Test: treehugger
Bug: 253318833
Change-Id: I33240a61548d20e7052bdba3badb7dc79987a8de
diff --git a/libs/WindowManager/Shell/res/values/dimen.xml b/libs/WindowManager/Shell/res/values/dimen.xml
index 680ad51..156d9f4 100644
--- a/libs/WindowManager/Shell/res/values/dimen.xml
+++ b/libs/WindowManager/Shell/res/values/dimen.xml
@@ -226,6 +226,8 @@
<dimen name="bubble_user_education_padding_end">58dp</dimen>
<!-- Padding between the bubble and the user education text. -->
<dimen name="bubble_user_education_stack_padding">16dp</dimen>
+ <!-- Size of the bubble bar (height), should match transient_taskbar_size in Launcher. -->
+ <dimen name="bubblebar_size">72dp</dimen>
<!-- Bottom and end margin for compat buttons. -->
<dimen name="compat_button_margin">24dp</dimen>
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 5ea2450..d101b0c 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
@@ -53,12 +53,16 @@
public static final float FLYOUT_MAX_WIDTH_PERCENT_LARGE_SCREEN = 0.3f;
/** The max percent of screen width to use for the flyout on phone. */
public static final float FLYOUT_MAX_WIDTH_PERCENT = 0.6f;
- /** The percent of screen width that should be used for the expanded view on a large screen. **/
+ /** The percent of screen width for the expanded view on a large screen. **/
private static final float EXPANDED_VIEW_LARGE_SCREEN_LANDSCAPE_WIDTH_PERCENT = 0.48f;
- /** The percent of screen width that should be used for the expanded view on a large screen. **/
+ /** The percent of screen width for the expanded view on a large screen. **/
private static final float EXPANDED_VIEW_LARGE_SCREEN_PORTRAIT_WIDTH_PERCENT = 0.70f;
- /** The percent of screen width that should be used for the expanded view on a small tablet. **/
+ /** The percent of screen width for the expanded view on a small tablet. **/
private static final float EXPANDED_VIEW_SMALL_TABLET_WIDTH_PERCENT = 0.72f;
+ /** The percent of screen width for the expanded view when shown in the bubble bar. **/
+ private static final float EXPANDED_VIEW_BUBBLE_BAR_PORTRAIT_WIDTH_PERCENT = 0.7f;
+ /** The percent of screen width for the expanded view when shown in the bubble bar. **/
+ private static final float EXPANDED_VIEW_BUBBLE_BAR_LANDSCAPE_WIDTH_PERCENT = 0.4f;
private Context mContext;
private WindowManager mWindowManager;
@@ -97,6 +101,12 @@
private PointF mRestingStackPosition;
private int[] mPaddings = new int[4];
+ private boolean mShowingInBubbleBar;
+ private boolean mBubblesOnHome;
+ private int mBubbleBarSize;
+ private int mBubbleBarHomeAdjustment;
+ private final PointF mBubbleBarPosition = new PointF();
+
public BubblePositioner(Context context, WindowManager windowManager) {
mContext = context;
mWindowManager = windowManager;
@@ -133,6 +143,7 @@
+ " insets: " + insets
+ " isLargeScreen: " + mIsLargeScreen
+ " isSmallTablet: " + mIsSmallTablet
+ + " showingInBubbleBar: " + mShowingInBubbleBar
+ " bounds: " + bounds);
}
updateInternal(mRotation, insets, bounds);
@@ -155,11 +166,17 @@
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 (mIsSmallTablet) {
+ if (mShowingInBubbleBar) {
+ mExpandedViewLargeScreenWidth = isLandscape()
+ ? (int) (bounds.width() * EXPANDED_VIEW_BUBBLE_BAR_LANDSCAPE_WIDTH_PERCENT)
+ : (int) (bounds.width() * EXPANDED_VIEW_BUBBLE_BAR_PORTRAIT_WIDTH_PERCENT);
+ } else if (mIsSmallTablet) {
mExpandedViewLargeScreenWidth = (int) (bounds.width()
* EXPANDED_VIEW_SMALL_TABLET_WIDTH_PERCENT);
} else {
@@ -693,4 +710,65 @@
screen.right,
screen.bottom);
}
+
+ //
+ // Bubble bar specific sizes below.
+ //
+
+ /**
+ * Sets whether bubbles are showing in the bubble bar from launcher.
+ */
+ public void setShowingInBubbleBar(boolean showingInBubbleBar) {
+ mShowingInBubbleBar = showingInBubbleBar;
+ }
+
+ /**
+ * Sets whether bubbles are showing on launcher home, in which case positions are different.
+ */
+ public void setBubblesOnHome(boolean bubblesOnHome) {
+ mBubblesOnHome = bubblesOnHome;
+ }
+
+ /**
+ * How wide the expanded view should be when showing from the bubble bar.
+ */
+ public int getExpandedViewWidthForBubbleBar() {
+ return mExpandedViewLargeScreenWidth;
+ }
+
+ /**
+ * How tall the expanded view should be when showing from the bubble bar.
+ */
+ public int getExpandedViewHeightForBubbleBar() {
+ return getAvailableRect().height()
+ - mBubbleBarSize
+ - mExpandedViewPadding * 2
+ - getBubbleBarHomeAdjustment();
+ }
+
+ /**
+ * The amount of padding from the edge of the screen to the expanded view when in bubble bar.
+ */
+ public int getBubbleBarExpandedViewPadding() {
+ return mExpandedViewPadding;
+ }
+
+ /**
+ * Returns the on screen co-ordinates of the bubble bar.
+ */
+ public PointF getBubbleBarPosition() {
+ mBubbleBarPosition.set(getAvailableRect().width() - mBubbleBarSize,
+ getAvailableRect().height() - mBubbleBarSize
+ - mExpandedViewPadding - getBubbleBarHomeAdjustment());
+ 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;
+ }
}