From df7e471a6feeceb854e4f74448715688f99ce956 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Fri, 18 Sep 2020 16:51:41 -0700 Subject: [PATCH] End current key button animations when the button is hidden - If the ripple animation doesn't finish before the view is hidden and not scheduled to draw, the render node animation will not finish, leaving the ripple visible until it is next touched. Instead, we should just end existing animations whenever the buttons are made invisible Bug: 168422286 Test: Extend ripple duration beyond the dismiss nav bar window duration and verify bug happens without change and is fixed with the change Change-Id: If3a38bcd47cc7665ee42c66f688cf306c7fab44c --- .../buttons/KeyButtonDrawable.java | 18 ++++++++++++++++++ .../navigationbar/buttons/KeyButtonRipple.java | 10 ++++++++++ 2 files changed, 28 insertions(+) diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/buttons/KeyButtonDrawable.java b/packages/SystemUI/src/com/android/systemui/navigationbar/buttons/KeyButtonDrawable.java index fc2016913292c..702be72ff4ed3 100644 --- a/packages/SystemUI/src/com/android/systemui/navigationbar/buttons/KeyButtonDrawable.java +++ b/packages/SystemUI/src/com/android/systemui/navigationbar/buttons/KeyButtonDrawable.java @@ -170,6 +170,24 @@ public class KeyButtonDrawable extends Drawable { } } + @Override + public boolean setVisible(boolean visible, boolean restart) { + boolean changed = super.setVisible(visible, restart); + if (changed) { + // End any existing animations when the visibility changes + jumpToCurrentState(); + } + return changed; + } + + @Override + public void jumpToCurrentState() { + super.jumpToCurrentState(); + if (mAnimatedDrawable != null) { + mAnimatedDrawable.jumpToCurrentState(); + } + } + @Override public void setAlpha(int alpha) { mState.mAlpha = alpha; diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/buttons/KeyButtonRipple.java b/packages/SystemUI/src/com/android/systemui/navigationbar/buttons/KeyButtonRipple.java index 72cd4f1343e6c..cf45f52e3367f 100644 --- a/packages/SystemUI/src/com/android/systemui/navigationbar/buttons/KeyButtonRipple.java +++ b/packages/SystemUI/src/com/android/systemui/navigationbar/buttons/KeyButtonRipple.java @@ -224,6 +224,16 @@ public class KeyButtonRipple extends Drawable { } } + @Override + public boolean setVisible(boolean visible, boolean restart) { + boolean changed = super.setVisible(visible, restart); + if (changed) { + // End any existing animations when the visibility changes + jumpToCurrentState(); + } + return changed; + } + @Override public void jumpToCurrentState() { endAnimations("jumpToCurrentState", false /* cancel */);