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

Commit 6dcf1c05 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Don't animate reorder/add when we're about to collapse." into rvc-dev...

Merge "Don't animate reorder/add when we're about to collapse." into rvc-dev am: f083c156 am: 3cb62293

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11852403

Change-Id: I6d95f05ba30be964af7298372d2a96cdbc2aee69
parents 7afe8b73 3cb62293
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -1822,6 +1822,10 @@ public class BubbleStackView extends FrameLayout
            mExpandedBubble.getExpandedView().hideImeIfVisible();
        }

        // Let the expanded animation controller know that it shouldn't animate child adds/reorders
        // since we're about to animate collapsed.
        mExpandedAnimationController.notifyPreparingToCollapse();

        final long startDelay =
                (long) (ExpandedAnimationController.EXPAND_COLLAPSE_TARGET_ANIM_DURATION * 0.6f);
        postDelayed(() -> mExpandedAnimationController.collapseBackToStack(
+43 −9
Original line number Diff line number Diff line
@@ -92,6 +92,14 @@ public class ExpandedAnimationController
    private int mScreenOrientation;

    private boolean mAnimatingExpand = false;

    /**
     * Whether we are animating other Bubbles UI elements out in preparation for a call to
     * {@link #collapseBackToStack}. If true, we won't animate bubbles in response to adds or
     * reorders.
     */
    private boolean mPreparingToCollapse = false;

    private boolean mAnimatingCollapse = false;
    private @Nullable Runnable mAfterExpand;
    private Runnable mAfterCollapse;
@@ -150,6 +158,7 @@ public class ExpandedAnimationController
     */
    public void expandFromStack(
            @Nullable Runnable after, @Nullable Runnable leadBubbleEndAction) {
        mPreparingToCollapse = false;
        mAnimatingCollapse = false;
        mAnimatingExpand = true;
        mAfterExpand = after;
@@ -165,9 +174,20 @@ public class ExpandedAnimationController
        expandFromStack(after, null /* leadBubbleEndAction */);
    }

    /**
     * Sets that we're animating the stack collapsed, but haven't yet called
     * {@link #collapseBackToStack}. This will temporarily suspend animations for bubbles that are
     * added or re-ordered, since the upcoming collapse animation will handle positioning those
     * bubbles in the collapsed stack.
     */
    public void notifyPreparingToCollapse() {
        mPreparingToCollapse = true;
    }

    /** Animate collapsing the bubbles back to their stacked position. */
    public void collapseBackToStack(PointF collapsePoint, Runnable after) {
        mAnimatingExpand = false;
        mPreparingToCollapse = false;
        mAnimatingCollapse = true;
        mAfterCollapse = after;
        mCollapsePoint = collapsePoint;
@@ -501,14 +521,20 @@ public class ExpandedAnimationController
            startOrUpdatePathAnimation(false /* expanding */);
        } else {
            child.setTranslationX(getBubbleLeft(index));

            // If we're preparing to collapse, don't start animations since the collapse animation
            // will take over and animate the new bubble into the correct (stacked) position.
            if (!mPreparingToCollapse) {
                animationForChild(child)
                        .translationY(
                            getExpandedY() - mBubbleSizePx * ANIMATE_TRANSLATION_FACTOR, /* from */
                                getExpandedY()
                                        - mBubbleSizePx * ANIMATE_TRANSLATION_FACTOR, /* from */
                                getExpandedY() /* to */)
                        .start();
                updateBubblePositions();
            }
        }
    }

    @Override
    void onChildRemoved(View child, int index, Runnable finishRemoval) {
@@ -532,12 +558,20 @@ public class ExpandedAnimationController

    @Override
    void onChildReordered(View child, int oldIndex, int newIndex) {
        updateBubblePositions();
        if (mPreparingToCollapse) {
            // If a re-order is received while we're preparing to collapse, ignore it. Once started,
            // the collapse animation will animate all of the bubbles to their correct (stacked)
            // position.
            return;
        }

        // We expect reordering during collapse, since we'll put the last selected bubble on top.
        // Update the collapse animation so they end up in the right stacked positions.
        if (mAnimatingCollapse) {
            // If a re-order is received during collapse, update the animation so that the bubbles
            // end up in the correct (stacked) position.
            startOrUpdatePathAnimation(false /* expanding */);
        } else {
            // Otherwise, animate the bubbles around to reflect their new order.
            updateBubblePositions();
        }
    }