From 13895f1be23ea838a1ebe2afcba472723ba2aeab Mon Sep 17 00:00:00 2001 From: Liran Binyamin Date: Thu, 27 Jun 2024 16:21:55 -0400 Subject: [PATCH] Don't animate the bubble that was dismissed by drag This change stores the bubble that was dismissed by drag temporarily in BubbleBarView so that when we remove the bubble, we can avoid updating it as part of the animation. This is step 1 in this change. Next I'll look into removing the bubble immediately after dismissing it from the menu, and lastly update sysui to not send the removal event back to launcher. Flag: com.android.wm.shell.enable_bubble_bar Bug: 349826879 Test: manual - have bubbles in the bubble bar and expand it - drag a bubble to dismiss it - observe the bubble does not reappear in the bar during the animation Change-Id: I6628ce779db4aac8d82edd4ecf2a25dedf8feef9 --- .../taskbar/bubbles/BubbleBarController.java | 7 +++++++ .../taskbar/bubbles/BubbleBarView.java | 18 +++++++++++++++--- .../bubbles/BubbleBarViewController.java | 6 ++++++ .../taskbar/bubbles/BubbleDragController.java | 1 + 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java index f6b1328a10..4100e51884 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarController.java @@ -445,6 +445,13 @@ public class BubbleBarController extends IBubblesListener.Stub { } } + /** + * Removes the given bubble from the backing list of bubbles after it was dismissed by the user. + */ + public void onBubbleDismissed(BubbleView bubble) { + mBubbles.remove(bubble.getBubble().getKey()); + } + /** Tells WMShell to show the currently selected bubble. */ public void showSelectedBubble() { if (getSelectedBubbleKey() != null) { diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java index 753237a188..402b0916f6 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java @@ -182,6 +182,8 @@ public class BubbleBarView extends FrameLayout { @Nullable private BubbleView mDraggedBubbleView; + @Nullable + private BubbleView mDismissedByDragBubbleView; private float mAlphaDuringDrag = 1f; private Controller mController; @@ -767,6 +769,10 @@ public class BubbleBarView extends FrameLayout { 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; + } int bubbleCount = getChildCount(); mBubbleAnimator = new BubbleAnimator(mIconSize, mExpandedBarIconsSpacing, bubbleCount, mBubbleBarLocation.isOnLeft(isLayoutRtl())); @@ -786,8 +792,11 @@ public class BubbleBarView extends FrameLayout { @Override public void onAnimationUpdate(float animatedFraction) { - bubble.setScaleX(1 - animatedFraction); - bubble.setScaleY(1 - animatedFraction); + // don't update the scale if this bubble was dismissed by drag + if (!dismissedByDrag) { + bubble.setScaleX(1 - animatedFraction); + bubble.setScaleY(1 - animatedFraction); + } updateBubblesLayoutProperties(mBubbleBarLocation); invalidate(); } @@ -818,6 +827,7 @@ public class BubbleBarView extends FrameLayout { updateWidth(); updateBubbleAccessibilityStates(); updateContentDescription(); + mDismissedByDragBubbleView = null; } private void updateWidth() { @@ -864,7 +874,7 @@ public class BubbleBarView extends FrameLayout { float elevationState = (1 - widthState); for (int i = 0; i < bubbleCount; i++) { BubbleView bv = (BubbleView) getChildAt(i); - if (bv == mDraggedBubbleView) { + if (bv == mDraggedBubbleView || bv == mDismissedByDragBubbleView) { // Skip the dragged bubble. Its translation is managed by the drag controller. continue; } @@ -1048,6 +1058,8 @@ public class BubbleBarView extends FrameLayout { mDraggedBubbleView = view; if (view != null) { view.setZ(mDragElevation); + // we started dragging a bubble. reset the bubble that was previously dismissed by drag + mDismissedByDragBubbleView = null; } setIsDragging(view != null); } diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java index dbc78db8e1..40e5b6435f 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java @@ -526,6 +526,12 @@ public class BubbleBarViewController { mSystemUiProxy.stopBubbleDrag(location, mBarView.getRestingTopPositionOnScreen()); } + /** Notifies {@link BubbleBarView} that the dragged bubble was dismissed. */ + public void onBubbleDragDismissed(BubbleView bubble) { + mBubbleBarController.onBubbleDismissed(bubble); + mBarView.removeBubble(bubble); + } + /** * Notifies {@link BubbleBarView} that drag and all animations are finished. */ diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleDragController.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleDragController.java index efc747c725..8316b5bed3 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleDragController.java +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleDragController.java @@ -153,6 +153,7 @@ public class BubbleDragController { @Override protected void onDragDismiss() { mBubblePinController.onDragEnd(); + mBubbleBarViewController.onBubbleDragDismissed(bubbleView); mBubbleBarViewController.onBubbleDragEnd(); }