Merge "Fix the spacing between bubble bar and expanded view" into udc-qpr-dev

This commit is contained in:
Liran Binyamin
2023-07-10 15:44:35 +00:00
committed by Android (Google) Code Review
6 changed files with 18 additions and 39 deletions

View File

@@ -226,8 +226,6 @@
<dimen name="bubble_user_education_padding_end">58dp</dimen> <dimen name="bubble_user_education_padding_end">58dp</dimen>
<!-- Padding between the bubble and the user education text. --> <!-- Padding between the bubble and the user education text. -->
<dimen name="bubble_user_education_stack_padding">16dp</dimen> <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>
<!-- The size of the caption bar inset at the top of bubble bar expanded view. --> <!-- The size of the caption bar inset at the top of bubble bar expanded view. -->
<dimen name="bubble_bar_expanded_view_caption_height">32dp</dimen> <dimen name="bubble_bar_expanded_view_caption_height">32dp</dimen>
<!-- The height of the dots shown for the caption menu in the bubble bar expanded view.. --> <!-- The height of the dots shown for the caption menu in the bubble bar expanded view.. -->

View File

@@ -1075,8 +1075,9 @@ public class BubbleController implements ConfigurationChangeListener,
* <p>This is used by external callers (launcher). * <p>This is used by external callers (launcher).
*/ */
@VisibleForTesting @VisibleForTesting
public void expandStackAndSelectBubbleFromLauncher(String key, boolean onLauncherHome) { public void expandStackAndSelectBubbleFromLauncher(String key, int bubbleBarXCoordinate,
mBubblePositioner.setShowingInBubbleBar(onLauncherHome); int bubbleBarYCoordinate) {
mBubblePositioner.setBubbleBarPosition(bubbleBarXCoordinate, bubbleBarYCoordinate);
if (BubbleOverflow.KEY.equals(key)) { if (BubbleOverflow.KEY.equals(key)) {
mBubbleData.setSelectedBubbleFromLauncher(mBubbleData.getOverflow()); mBubbleData.setSelectedBubbleFromLauncher(mBubbleData.getOverflow());
@@ -2087,9 +2088,10 @@ public class BubbleController implements ConfigurationChangeListener,
} }
@Override @Override
public void showBubble(String key, boolean onLauncherHome) { public void showBubble(String key, int bubbleBarXCoordinate, int bubbleBarYCoordinate) {
mMainExecutor.execute( mMainExecutor.execute(
() -> mController.expandStackAndSelectBubbleFromLauncher(key, onLauncherHome)); () -> mController.expandStackAndSelectBubbleFromLauncher(
key, bubbleBarXCoordinate, bubbleBarYCoordinate));
} }
@Override @Override

View File

@@ -22,6 +22,7 @@ import android.content.Context;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.content.res.Resources; import android.content.res.Resources;
import android.graphics.Insets; import android.graphics.Insets;
import android.graphics.Point;
import android.graphics.PointF; import android.graphics.PointF;
import android.graphics.Rect; import android.graphics.Rect;
import android.graphics.RectF; import android.graphics.RectF;
@@ -102,10 +103,7 @@ public class BubblePositioner {
private int[] mPaddings = new int[4]; private int[] mPaddings = new int[4];
private boolean mShowingInBubbleBar; private boolean mShowingInBubbleBar;
private boolean mBubblesOnHome; private final Point mBubbleBarPosition = new Point();
private int mBubbleBarSize;
private int mBubbleBarHomeAdjustment;
private final PointF mBubbleBarPosition = new PointF();
public BubblePositioner(Context context, WindowManager windowManager) { public BubblePositioner(Context context, WindowManager windowManager) {
mContext = context; mContext = context;
@@ -166,11 +164,9 @@ public class BubblePositioner {
mSpacingBetweenBubbles = res.getDimensionPixelSize(R.dimen.bubble_spacing); mSpacingBetweenBubbles = res.getDimensionPixelSize(R.dimen.bubble_spacing);
mDefaultMaxBubbles = res.getInteger(R.integer.bubbles_max_rendered); mDefaultMaxBubbles = res.getInteger(R.integer.bubbles_max_rendered);
mExpandedViewPadding = res.getDimensionPixelSize(R.dimen.bubble_expanded_view_padding); mExpandedViewPadding = res.getDimensionPixelSize(R.dimen.bubble_expanded_view_padding);
mBubbleBarHomeAdjustment = mExpandedViewPadding / 2;
mBubblePaddingTop = res.getDimensionPixelSize(R.dimen.bubble_padding_top); mBubblePaddingTop = res.getDimensionPixelSize(R.dimen.bubble_padding_top);
mBubbleOffscreenAmount = res.getDimensionPixelSize(R.dimen.bubble_stack_offscreen); mBubbleOffscreenAmount = res.getDimensionPixelSize(R.dimen.bubble_stack_offscreen);
mStackOffset = res.getDimensionPixelSize(R.dimen.bubble_stack_offset); mStackOffset = res.getDimensionPixelSize(R.dimen.bubble_stack_offset);
mBubbleBarSize = res.getDimensionPixelSize(R.dimen.bubblebar_size);
if (mShowingInBubbleBar) { if (mShowingInBubbleBar) {
mExpandedViewLargeScreenWidth = isLandscape() mExpandedViewLargeScreenWidth = isLandscape()
@@ -722,11 +718,9 @@ public class BubblePositioner {
mShowingInBubbleBar = showingInBubbleBar; mShowingInBubbleBar = showingInBubbleBar;
} }
/** /** Sets the position of the bubble bar in screen coordinates. */
* Sets whether bubbles are showing on launcher home, in which case positions are different. public void setBubbleBarPosition(int x, int y) {
*/ mBubbleBarPosition.set(x, y);
public void setBubblesOnHome(boolean bubblesOnHome) {
mBubblesOnHome = bubblesOnHome;
} }
/** /**
@@ -747,11 +741,7 @@ public class BubblePositioner {
/** The bottom position of the expanded view when showing above the bubble bar. */ /** The bottom position of the expanded view when showing above the bubble bar. */
public int getExpandedViewBottomForBubbleBar() { public int getExpandedViewBottomForBubbleBar() {
return getAvailableRect().height() return mBubbleBarPosition.y - mExpandedViewPadding;
+ mInsets.top
- mBubbleBarSize
- mExpandedViewPadding
- getBubbleBarHomeAdjustment();
} }
/** /**
@@ -764,19 +754,7 @@ public class BubblePositioner {
/** /**
* Returns the on screen co-ordinates of the bubble bar. * Returns the on screen co-ordinates of the bubble bar.
*/ */
public PointF getBubbleBarPosition() { public Point getBubbleBarPosition() {
mBubbleBarPosition.set(getAvailableRect().width() - mBubbleBarSize,
getAvailableRect().height() - mBubbleBarSize
- mExpandedViewPadding - getBubbleBarHomeAdjustment());
return mBubbleBarPosition; 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;
}
} }

View File

@@ -29,7 +29,8 @@ interface IBubbles {
oneway void unregisterBubbleListener(in IBubblesListener listener) = 2; 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; oneway void removeBubble(in String key, in int reason) = 4;

View File

@@ -21,7 +21,7 @@ import android.animation.Animator;
import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator; import android.animation.ValueAnimator;
import android.content.Context; import android.content.Context;
import android.graphics.PointF; import android.graphics.Point;
import android.util.Log; import android.util.Log;
import android.widget.FrameLayout; import android.widget.FrameLayout;
@@ -136,7 +136,7 @@ public class BubbleBarAnimationHelper {
bev.setVisibility(VISIBLE); bev.setVisibility(VISIBLE);
// Set the pivot point for the scale, so the view animates out from the bubble bar. // 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( mExpandedViewContainerMatrix.setScale(
1f - EXPANDED_VIEW_ANIMATE_SCALE_AMOUNT, 1f - EXPANDED_VIEW_ANIMATE_SCALE_AMOUNT,
1f - EXPANDED_VIEW_ANIMATE_SCALE_AMOUNT, 1f - EXPANDED_VIEW_ANIMATE_SCALE_AMOUNT,

View File

@@ -1996,7 +1996,7 @@ public class BubblesTest extends SysuiTestCase {
FakeBubbleStateListener bubbleStateListener = new FakeBubbleStateListener(); FakeBubbleStateListener bubbleStateListener = new FakeBubbleStateListener();
mBubbleController.registerBubbleStateListener(bubbleStateListener); mBubbleController.registerBubbleStateListener(bubbleStateListener);
mBubbleController.expandStackAndSelectBubbleFromLauncher(mBubbleEntry.getKey(), true); mBubbleController.expandStackAndSelectBubbleFromLauncher(mBubbleEntry.getKey(), 500, 1000);
assertThat(mBubbleController.getLayerView().isExpanded()).isTrue(); assertThat(mBubbleController.getLayerView().isExpanded()).isTrue();