diff options
| author | 2023-04-21 12:42:17 -0700 | |
|---|---|---|
| committer | 2023-04-21 16:35:34 -0700 | |
| commit | 8890156dfd70cb8e24f6a81469f531596eeca551 (patch) | |
| tree | 108f5be330d57e0c16ab05d3180fc649e9ae794c | |
| parent | b466506595803b7440bbe72b2326bca51aa9a65e (diff) | |
Animate the scrim and properly remove the expanded view
When the last bubble icon view is removed from mBubbleContainer a
callback notifies BubbleController to remove the bubble window. This
resulted in all of the bubble views being immediately removed from
the screen rather than properly animating out. This also results
in a weird animation where the task transitions off the screen.
To fix this, when the last bubble is removed while bubbles are
expanded, move the view removal code to the end of the scrim
animation. We also need to set a flag that this is happening so
that the 'collapse' animation that happens (which also triggers the
scrim animation) doesn't clobber the first scrim animation.
Bubble removals always happen before the expansion changes, so the
order here is guaranteed.
Test: manual - have 1 bubble, expand it, drag it to remove
=> observe that the scrim fades out and the expanded
view animates away during the drag & doesn't come
back and animates off screen horizontally
Bug: 279074302
Change-Id: I9492481bbb30d60515c68077de9d6911e7dea93c
| -rw-r--r-- | libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java index 2f10acbf44b6..52ebf0429131 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java @@ -282,6 +282,11 @@ public class BubbleStackView extends FrameLayout /** Whether the expanded view has been hidden, because we are dragging out a bubble. */ private boolean mExpandedViewTemporarilyHidden = false; + /** + * Whether the last bubble is being removed when expanded, which impacts the collapse animation. + */ + private boolean mRemovingLastBubbleWhileExpanded = false; + /** Animator for animating the expanded view's alpha (including the TaskView inside it). */ private final ValueAnimator mExpandedViewAlphaAnimator = ValueAnimator.ofFloat(0f, 1f); @@ -765,7 +770,7 @@ public class BubbleStackView extends FrameLayout // Update scrim if (!mScrimAnimating) { - showScrim(true); + showScrim(true, null /* runnable */); } } } @@ -1772,6 +1777,20 @@ public class BubbleStackView extends FrameLayout if (DEBUG_BUBBLE_STACK_VIEW) { Log.d(TAG, "removeBubble: " + bubble); } + if (isExpanded() && getBubbleCount() == 1) { + mRemovingLastBubbleWhileExpanded = true; + // We're expanded while the last bubble is being removed. Let the scrim animate away + // and then remove our views (removing the icon view triggers the removal of the + // bubble window so do that at the end of the animation so we see the scrim animate). + showScrim(false, () -> { + mRemovingLastBubbleWhileExpanded = false; + bubble.cleanupExpandedView(); + mBubbleContainer.removeView(bubble.getIconView()); + bubble.cleanupViews(); // cleans up the icon view + updateExpandedView(); // resets state for no expanded bubble + }); + return; + } // Remove it from the views for (int i = 0; i < getBubbleCount(); i++) { View v = mBubbleContainer.getChildAt(i); @@ -2142,7 +2161,7 @@ public class BubbleStackView extends FrameLayout mExpandedViewAlphaAnimator.start(); } - private void showScrim(boolean show) { + private void showScrim(boolean show, Runnable after) { AnimatorListenerAdapter listener = new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { @@ -2152,6 +2171,9 @@ public class BubbleStackView extends FrameLayout @Override public void onAnimationEnd(Animator animation) { mScrimAnimating = false; + if (after != null) { + after.run(); + } } }; if (show) { @@ -2178,7 +2200,7 @@ public class BubbleStackView extends FrameLayout } beforeExpandedViewAnimation(); - showScrim(true); + showScrim(true, null /* runnable */); updateZOrder(); updateBadges(false /* setBadgeForCollapsedStack */); mBubbleContainer.setActiveController(mExpandedAnimationController); @@ -2302,7 +2324,10 @@ public class BubbleStackView extends FrameLayout mIsExpanded = false; mIsExpansionAnimating = true; - showScrim(false); + if (!mRemovingLastBubbleWhileExpanded) { + // When we remove the last bubble it animates the scrim. + showScrim(false, null /* runnable */); + } mBubbleContainer.cancelAllAnimations(); |