Animate the bubble bar on dismiss

When the last remaining bubble is dismissed by drag or from the menu
we now fade out the bubble bar.

Flag: com.android.wm.shell.enable_bubble_bar
Fixes: 347062801
Test: manual
       - create a single bubble in the bar
       - expand
       - dismiss by drag or from menu
       - observe animation
Change-Id: I86fcaf04c6f5949126744b81e0042b0e58318a13
This commit is contained in:
Liran Binyamin committed 2024-11-27 16:23:26 -05:00
1 parent c48b4ed025
commit 7e387fa505
5 files changed
+88 -34

No files matched your search

@@ -81,6 +81,7 @@ public class BubbleBarView extends FrameLayout {
public static final long FADE_OUT_ANIM_POSITION_DURATION_MS = 100L;
public static final long FADE_IN_ANIM_ALPHA_DURATION_MS = 100L;
public static final long FADE_OUT_BUBBLE_BAR_DURATION_MS = 150L;
private static final String TAG = "BubbleBarView";
// TODO: (b/273594744) calculate the amount of space we have and base the max on that
// if it's smaller than 5.
@@ -146,6 +147,9 @@ public class BubbleBarView extends FrameLayout {
// collapsed state and 1 to the fully expanded state.
private ValueAnimator mWidthAnimator = createExpansionAnimator(/* expanding = */ false);
@Nullable
private ValueAnimator mDismissAnimator = null;
/** An animator used for animating individual bubbles in the bubble bar while expanded. */
@Nullable
private BubbleAnimator mBubbleAnimator = null;
@@ -799,11 +803,11 @@ public class BubbleBarView extends FrameLayout {
/** Removes the given bubble from the bubble bar. */
public void removeBubble(View bubble) {
if (isExpanded()) {
// TODO b/347062801 - animate the bubble bar if the last bubble is removed
final boolean dismissedByDrag = mDraggedBubbleView == bubble;
if (dismissedByDrag) {
mDismissedByDragBubbleView = mDraggedBubbleView;
}
boolean removingLastRemainingBubble = getBubbleChildCount() == 1;
int bubbleCount = getChildCount();
mBubbleAnimator = new BubbleAnimator(mIconSize, mExpandedBarIconsSpacing,
bubbleCount, mBubbleBarLocation.isOnLeft(isLayoutRtl()));
@@ -841,7 +845,10 @@ public class BubbleBarView extends FrameLayout {
: bubbleIndex == bubbleCount - 1;
mBubbleAnimator.animateRemovedBubble(
indexOfChild(bubble), indexOfChild(mSelectedBubbleView), removingLastBubble,
listener);
removingLastRemainingBubble, listener);
if (removingLastRemainingBubble && mDismissAnimator == null) {
createDismissAnimator().start();
}
} else {
removeView(bubble);
}
@@ -862,6 +869,28 @@ public class BubbleBarView extends FrameLayout {
updateDotsAndBadgesIfCollapsed();
}
private ValueAnimator createDismissAnimator() {
ValueAnimator animator =
ValueAnimator.ofFloat(0, 1).setDuration(FADE_OUT_BUBBLE_BAR_DURATION_MS);
animator.setInterpolator(Interpolators.EMPHASIZED);
Runnable onEnd = () -> {
mDismissAnimator = null;
setAlpha(0);
};
addAnimationCallBacks(animator, /* onStart= */ null, onEnd,
/* onUpdate= */ anim -> setAlpha(1 - anim.getAnimatedFraction()));
mDismissAnimator = animator;
return animator;
}
/** Dismisses the bubble bar */
public void dismiss(Runnable onDismissed) {
if (mDismissAnimator == null) {
createDismissAnimator().start();
}
addAnimationCallBacks(mDismissAnimator, null, onDismissed, null);
}
/**
* Return child views in the order which they are shown on the screen.
* <p>