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

Commit ff27ed48 authored by Omar Miatello's avatar Omar Miatello Committed by Android (Google) Code Review
Browse files

Merge "Reset HUN roundness after cancellation of disappearing animation" into udc-qpr-dev

parents 391ca580 6999144f
Loading
Loading
Loading
Loading
+10 −5
Original line number Original line Diff line number Diff line
@@ -426,16 +426,21 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
        updateAppearAnimationAlpha();
        updateAppearAnimationAlpha();
        updateAppearRect();
        updateAppearRect();
        mAppearAnimator.addListener(new AnimatorListenerAdapter() {
        mAppearAnimator.addListener(new AnimatorListenerAdapter() {
            private boolean mWasCancelled;
            private boolean mRunWithoutInterruptions;


            @Override
            @Override
            public void onAnimationEnd(Animator animation) {
            public void onAnimationEnd(Animator animation) {
                if (onFinishedRunnable != null) {
                if (onFinishedRunnable != null) {
                    onFinishedRunnable.run();
                    onFinishedRunnable.run();
                }
                }
                if (!mWasCancelled) {
                if (mRunWithoutInterruptions) {
                    enableAppearDrawing(false);
                    enableAppearDrawing(false);
                }

                // We need to reset the View state, even if the animation was cancelled
                onAppearAnimationFinished(isAppearing);
                onAppearAnimationFinished(isAppearing);

                if (mRunWithoutInterruptions) {
                    InteractionJankMonitor.getInstance().end(getCujType(isAppearing));
                    InteractionJankMonitor.getInstance().end(getCujType(isAppearing));
                } else {
                } else {
                    InteractionJankMonitor.getInstance().cancel(getCujType(isAppearing));
                    InteractionJankMonitor.getInstance().cancel(getCujType(isAppearing));
@@ -444,7 +449,7 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView


            @Override
            @Override
            public void onAnimationStart(Animator animation) {
            public void onAnimationStart(Animator animation) {
                mWasCancelled = false;
                mRunWithoutInterruptions = true;
                Configuration.Builder builder = Configuration.Builder
                Configuration.Builder builder = Configuration.Builder
                        .withView(getCujType(isAppearing), ActivatableNotificationView.this);
                        .withView(getCujType(isAppearing), ActivatableNotificationView.this);
                InteractionJankMonitor.getInstance().begin(builder);
                InteractionJankMonitor.getInstance().begin(builder);
@@ -452,7 +457,7 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView


            @Override
            @Override
            public void onAnimationCancel(Animator animation) {
            public void onAnimationCancel(Animator animation) {
                mWasCancelled = true;
                mRunWithoutInterruptions = false;
            }
            }
        });
        });


+44 −0
Original line number Original line Diff line number Diff line
@@ -789,6 +789,50 @@ public class ExpandableNotificationRowTest extends SysuiTestCase {
        assertThat(row.isExpanded()).isTrue();
        assertThat(row.isExpanded()).isTrue();
    }
    }


    @Test
    public void onDisappearAnimationFinished_shouldSetFalse_headsUpAnimatingAway()
            throws Exception {
        final ExpandableNotificationRow row = mNotificationTestHelper.createRow();

        // Initial state: suppose heads up animation in progress
        row.setHeadsUpAnimatingAway(true);
        assertThat(row.isHeadsUpAnimatingAway()).isTrue();

        // on disappear animation ends
        row.onAppearAnimationFinished(/* wasAppearing = */ false);
        assertThat(row.isHeadsUpAnimatingAway()).isFalse();
    }

    @Test
    public void onHUNAppear_cancelAppearDrawing_shouldResetAnimationState() throws Exception {
        final ExpandableNotificationRow row = mNotificationTestHelper.createRow();

        row.performAddAnimation(/* delay */ 0, /* duration */ 1000, /* isHeadsUpAppear */ true);

        waitForIdleSync();
        assertThat(row.isDrawingAppearAnimation()).isTrue();

        row.cancelAppearDrawing();

        waitForIdleSync();
        assertThat(row.isDrawingAppearAnimation()).isFalse();
    }

    @Test
    public void onHUNDisappear_cancelAppearDrawing_shouldResetAnimationState() throws Exception {
        final ExpandableNotificationRow row = mNotificationTestHelper.createRow();

        row.performAddAnimation(/* delay */ 0, /* duration */ 1000, /* isHeadsUpAppear */ false);

        waitForIdleSync();
        assertThat(row.isDrawingAppearAnimation()).isTrue();

        row.cancelAppearDrawing();

        waitForIdleSync();
        assertThat(row.isDrawingAppearAnimation()).isFalse();
    }

    private void setDrawableIconsInImageView(CachingIconView icon, Drawable iconDrawable,
    private void setDrawableIconsInImageView(CachingIconView icon, Drawable iconDrawable,
            Drawable rightIconDrawable) {
            Drawable rightIconDrawable) {
        ImageView iconView = mock(ImageView.class);
        ImageView iconView = mock(ImageView.class);