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(); }