Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 13895f1b authored by Liran Binyamin's avatar Liran Binyamin
Browse files

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
parent b15dce1e
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -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) {
+15 −3
Original line number Diff line number Diff line
@@ -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) {
                    // 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);
    }
+6 −0
Original line number Diff line number Diff line
@@ -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.
     */
+1 −0
Original line number Diff line number Diff line
@@ -153,6 +153,7 @@ public class BubbleDragController {
            @Override
            protected void onDragDismiss() {
                mBubblePinController.onDragEnd();
                mBubbleBarViewController.onBubbleDragDismissed(bubbleView);
                mBubbleBarViewController.onBubbleDragEnd();
            }