diff options
author | 2023-07-28 15:59:46 +0000 | |
---|---|---|
committer | 2023-07-28 15:59:46 +0000 | |
commit | ff27ed486991a8fa48a4e10ab7409f85d92ea74f (patch) | |
tree | 18df378195b32be56cf3cfba06156fb36e81e154 | |
parent | 391ca5800b8f807eb8af02489fcf483358dc17b8 (diff) | |
parent | 6999144fca17847a0094544e874855fba83c9bbf (diff) |
Merge "Reset HUN roundness after cancellation of disappearing animation" into udc-qpr-dev
2 files changed, 54 insertions, 5 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java index 36a8e9833d39..5e7e4be60104 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java @@ -426,16 +426,21 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView updateAppearAnimationAlpha(); updateAppearRect(); mAppearAnimator.addListener(new AnimatorListenerAdapter() { - private boolean mWasCancelled; + private boolean mRunWithoutInterruptions; @Override public void onAnimationEnd(Animator animation) { if (onFinishedRunnable != null) { onFinishedRunnable.run(); } - if (!mWasCancelled) { + if (mRunWithoutInterruptions) { enableAppearDrawing(false); - onAppearAnimationFinished(isAppearing); + } + + // We need to reset the View state, even if the animation was cancelled + onAppearAnimationFinished(isAppearing); + + if (mRunWithoutInterruptions) { InteractionJankMonitor.getInstance().end(getCujType(isAppearing)); } else { InteractionJankMonitor.getInstance().cancel(getCujType(isAppearing)); @@ -444,7 +449,7 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView @Override public void onAnimationStart(Animator animation) { - mWasCancelled = false; + mRunWithoutInterruptions = true; Configuration.Builder builder = Configuration.Builder .withView(getCujType(isAppearing), ActivatableNotificationView.this); InteractionJankMonitor.getInstance().begin(builder); @@ -452,7 +457,7 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView @Override public void onAnimationCancel(Animator animation) { - mWasCancelled = true; + mRunWithoutInterruptions = false; } }); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java index 1dc8453a90ec..ac8b42afd4b2 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java @@ -789,6 +789,50 @@ public class ExpandableNotificationRowTest extends SysuiTestCase { 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, Drawable rightIconDrawable) { ImageView iconView = mock(ImageView.class); |