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

Commit b35f5918 authored by Joshua Tsuji's avatar Joshua Tsuji
Browse files

Fix resting stack position + dot position issues.

The resting stack position issue was due to the position being set when the 'following' spring animations end. When there's one bubble, there's no following animations so this was not called. This is fixed by setting it in the fling animation end listener instead, which is called when the first bubble's fling ends.

The dot position just needed to be set when the first child is added.

Test: atest SystemUITests
Fixes: 138301618
Fixes: 134064116
Change-Id: I5360f09bfda95a45ada534101cb058c26f7c37f5
parent 15c02d9a
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -692,10 +692,20 @@ public class BubbleStackView extends FrameLayout {
        if (DEBUG_BUBBLE_STACK_VIEW) {
            Log.d(TAG, "addBubble: " + bubble);
        }

        if (mBubbleContainer.getChildCount() == 0) {
            mStackOnLeftOrWillBe = mStackAnimationController.isStackOnLeftSide();
        }

        bubble.inflate(mInflater, this);
        bubble.getIconView().setBubbleIconFactory(mBubbleIconFactory);
        bubble.getIconView().updateViews();

        // Set the dot position to the opposite of the side the stack is resting on, since the stack
        // resting slightly off-screen would result in the dot also being off-screen.
        bubble.getIconView().setDotPosition(
                !mStackOnLeftOrWillBe /* onLeft */, false /* animate */);

        mBubbleContainer.addView(bubble.getIconView(), 0,
                new FrameLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
        ViewClippingUtil.setClippingDeactivated(bubble.getIconView(), true, mClippingParameters);
+3 −13
Original line number Diff line number Diff line
@@ -271,15 +271,6 @@ public class StackAnimationController extends
                        .setDampingRatio(SPRING_AFTER_FLING_DAMPING_RATIO),
                /* destination */ null);

        setEndActionForMultipleProperties(
                () -> {
                    mRestingStackPosition = new PointF();
                    mRestingStackPosition.set(mStackPosition);
                    removeEndActionForProperty(DynamicAnimation.TRANSLATION_X);
                    removeEndActionForProperty(DynamicAnimation.TRANSLATION_Y);
                },
                DynamicAnimation.TRANSLATION_X, DynamicAnimation.TRANSLATION_Y);

        // If we're flinging now, there's no more touch event to catch up to.
        mFirstBubbleSpringingToTouch = false;
        mIsMovingFromFlinging = true;
@@ -368,6 +359,9 @@ public class StackAnimationController extends

                .addEndListener((animation, canceled, endValue, endVelocity) -> {
                    if (!canceled) {
                        mRestingStackPosition = new PointF();
                        mRestingStackPosition.set(mStackPosition);

                        springFirstBubbleWithStackFollowing(property, spring, endVelocity,
                                finalPosition != null
                                        ? finalPosition
@@ -664,10 +658,6 @@ public class StackAnimationController extends

        if (mLayout.getChildCount() > 0) {
            animationForChildAtIndex(0).translationX(mStackPosition.x).start();
        } else {
            // Set the start position back to the default since we're out of bubbles. New bubbles
            // will then animate in from the start position.
            mStackPosition = getDefaultStartPosition();
        }
    }