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
This commit is contained in:
Mady Mellor
2023-03-09 15:46:25 -08:00
parent 70b6e81102
commit 76f76bae8a
2 changed files with 84 additions and 4 deletions

View File

@@ -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>

View File

@@ -53,12 +53,16 @@ public class BubblePositioner {
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 @@ public class BubblePositioner {
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 @@ public class BubblePositioner {
+ " insets: " + insets
+ " isLargeScreen: " + mIsLargeScreen
+ " isSmallTablet: " + mIsSmallTablet
+ " showingInBubbleBar: " + mShowingInBubbleBar
+ " bounds: " + bounds);
}
updateInternal(mRotation, insets, bounds);
@@ -155,11 +166,17 @@ 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 (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 @@ public class BubblePositioner {
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;
}
}