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

Commit 19e22e42 authored by Joshua Tsuji's avatar Joshua Tsuji Committed by Mady Mellor
Browse files

Fix start position issues and related flyout flickering.

- Cancel animations when explicitly moving the stack to the start position, so that the new translation doesn't get animated away.
- Set the flyout to 0 alpha before posting the animation, so it's invisible from the start.
- Tell the stack if the drag finished with a dismiss intent, so we can reset the drag flags.

Bug: 130441552
Test: atest SystemUITests
Change-Id: I31d753a6fb76468c4e2b68563f9c5f06fbd782a1
parent eaf1f8fd
Loading
Loading
Loading
Loading
+8 −4
Original line number Original line Diff line number Diff line
@@ -787,6 +787,10 @@ public class BubbleStackView extends FrameLayout {
                StatsLog.BUBBLE_UICHANGED__ACTION__STACK_MOVED);
                StatsLog.BUBBLE_UICHANGED__ACTION__STACK_MOVED);
    }
    }


    void onDragFinishAsDismiss() {
        mIsDragging = false;
    }

    /**
    /**
     * Calculates how large the expanded view of the bubble can be. This takes into account the
     * Calculates how large the expanded view of the bubble can be. This takes into account the
     * y position when the bubbles are expanded as well as the bounds of the dismiss target.
     * y position when the bubbles are expanded as well as the bounds of the dismiss target.
@@ -826,9 +830,12 @@ public class BubbleStackView extends FrameLayout {
        if (updateMessage != null && !isExpanded() && !mIsExpansionAnimating && !mIsDragging) {
        if (updateMessage != null && !isExpanded() && !mIsExpansionAnimating && !mIsDragging) {
            final PointF stackPos = mStackAnimationController.getStackPosition();
            final PointF stackPos = mStackAnimationController.getStackPosition();


            mFlyout.setAlpha(0f);
            mFlyout.setVisibility(VISIBLE);

            mFlyoutText.setText(updateMessage);
            mFlyoutText.setText(updateMessage);
            mFlyout.measure(WRAP_CONTENT, WRAP_CONTENT);
            mFlyout.measure(WRAP_CONTENT, WRAP_CONTENT);
            mFlyout.post(() -> {
            post(() -> {
                final boolean onLeft = mStackAnimationController.isStackOnLeftSide();
                final boolean onLeft = mStackAnimationController.isStackOnLeftSide();
                final float destinationX = onLeft
                final float destinationX = onLeft
                        ? stackPos.x + mBubbleSize + mBubblePadding
                        ? stackPos.x + mBubbleSize + mBubblePadding
@@ -837,9 +844,6 @@ public class BubbleStackView extends FrameLayout {
                // Translate towards the stack slightly, then spring out from the stack.
                // Translate towards the stack slightly, then spring out from the stack.
                mFlyout.setTranslationX(destinationX + (onLeft ? -mBubblePadding : mBubblePadding));
                mFlyout.setTranslationX(destinationX + (onLeft ? -mBubblePadding : mBubblePadding));
                mFlyout.setTranslationY(stackPos.y);
                mFlyout.setTranslationY(stackPos.y);
                mFlyout.setAlpha(0f);

                mFlyout.setVisibility(VISIBLE);


                mFlyout.animate().alpha(1f);
                mFlyout.animate().alpha(1f);
                mFlyoutSpring.animateToFinalPosition(destinationX);
                mFlyoutSpring.animateToFinalPosition(destinationX);
+1 −0
Original line number Original line Diff line number Diff line
@@ -148,6 +148,7 @@ class BubbleTouchHandler implements View.OnTouchListener {
                trackMovement(event);
                trackMovement(event);
                if (mInDismissTarget && isStack) {
                if (mInDismissTarget && isStack) {
                    mController.dismissStack(BubbleController.DISMISS_USER_GESTURE);
                    mController.dismissStack(BubbleController.DISMISS_USER_GESTURE);
                    mStack.onDragFinishAsDismiss();
                } else if (isFlyout) {
                } else if (isFlyout) {
                    // TODO(b/129768381): Expand if tapped, dismiss if swiped away.
                    // TODO(b/129768381): Expand if tapped, dismiss if swiped away.
                    if (!mStack.isExpanded() && !mMovedEnough) {
                    if (!mStack.isExpanded() && !mMovedEnough) {
+1 −0
Original line number Original line Diff line number Diff line
@@ -538,6 +538,7 @@ public class StackAnimationController extends
        Log.d(TAG, String.format("Setting position to (%f, %f).", pos.x, pos.y));
        Log.d(TAG, String.format("Setting position to (%f, %f).", pos.x, pos.y));
        mStackPosition.set(pos.x, pos.y);
        mStackPosition.set(pos.x, pos.y);


        mLayout.cancelAllAnimations();
        cancelStackPositionAnimations();
        cancelStackPositionAnimations();


        // Since we're not using the chained animations, apply the offsets manually.
        // Since we're not using the chained animations, apply the offsets manually.
+1 −13
Original line number Original line Diff line number Diff line
@@ -22,7 +22,6 @@ import static org.mockito.Mockito.when;


import android.testing.AndroidTestingRunner;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.testing.TestableLooper;
import android.view.View;
import android.widget.TextView;
import android.widget.TextView;


import androidx.test.filters.SmallTest;
import androidx.test.filters.SmallTest;
@@ -53,22 +52,11 @@ public class BubbleStackViewTest extends SysuiTestCase {
    }
    }


    @Test
    @Test
    public void testAnimateInFlyoutForBubble() throws InterruptedException {
    public void testAnimateInFlyoutForBubble() {
        when(mNotifEntry.getUpdateMessage(any())).thenReturn("Test Flyout Message.");
        when(mNotifEntry.getUpdateMessage(any())).thenReturn("Test Flyout Message.");
        mStackView.animateInFlyoutForBubble(mBubble);
        mStackView.animateInFlyoutForBubble(mBubble);


        // Wait for the fade in.
        Thread.sleep(200);

        // Flyout should be visible and showing our text.
        assertEquals(1f, mStackView.findViewById(R.id.bubble_flyout).getAlpha(), .01f);
        assertEquals("Test Flyout Message.",
        assertEquals("Test Flyout Message.",
                ((TextView) mStackView.findViewById(R.id.bubble_flyout_text)).getText());
                ((TextView) mStackView.findViewById(R.id.bubble_flyout_text)).getText());

        // Wait until it should have gone away.
        Thread.sleep(BubbleStackView.FLYOUT_HIDE_AFTER + 200);

        // Flyout should be gone.
        assertEquals(View.GONE, mStackView.findViewById(R.id.bubble_flyout).getVisibility());
    }
    }
}
}