Merge "Animate the stash handle for new bubbles" into main

This commit is contained in:
Liran Binyamin
2024-04-05 00:49:39 +00:00
committed by Android (Google) Code Review
5 changed files with 224 additions and 34 deletions
@@ -96,6 +96,8 @@ public class BubbleBarView extends FrameLayout {
private final BubbleBarBackground mBubbleBarBackground;
private boolean mIsAnimatingNewBubble = false;
/**
* The current bounds of all the bubble bar. Note that these bounds may not account for
* translation. The bounds should be retrieved using {@link #getBubbleBarBounds()} which
@@ -457,6 +459,7 @@ public class BubbleBarView extends FrameLayout {
/** Prepares for animating a bubble while being stashed. */
public void prepareForAnimatingBubbleWhileStashed(String bubbleKey) {
mIsAnimatingNewBubble = true;
// we're about to animate the new bubble in. the new bubble has already been added to this
// view, but we're currently stashed, so before we can start the animation we need make
// everything else in the bubble bar invisible, except for the bubble that's being animated.
@@ -477,6 +480,9 @@ public class BubbleBarView extends FrameLayout {
/** Resets the state after the bubble animation completed. */
public void onAnimatingBubbleCompleted() {
mIsAnimatingNewBubble = false;
// setting the background triggers relayout so no need to explicitly invalidate after the
// animation
setBackground(mBubbleBarBackground);
for (int i = 0; i < getChildCount(); i++) {
final BubbleView view = (BubbleView) getChildAt(i);
@@ -521,6 +527,12 @@ public class BubbleBarView extends FrameLayout {
* on the expanded state.
*/
private void updateChildrenRenderNodeProperties() {
if (mIsAnimatingNewBubble) {
// don't update bubbles if a new bubble animation is playing.
// the bubble bar will redraw itself via onLayout after the animation.
return;
}
final float widthState = (float) mWidthAnimator.getAnimatedValue();
final float currentWidth = getWidth();
final float expandedWidth = expandedWidth();