diff options
| author | 2022-11-09 21:37:23 +0000 | |
|---|---|---|
| committer | 2022-11-09 21:37:23 +0000 | |
| commit | 23b6eea5961cac16b0cf1b588be4139d5e426f0c (patch) | |
| tree | d628a8deb6a57b5843e6bba6a6872721e323fa4f | |
| parent | 82021121804e4c5c22d99e4b431b4b63c04b05bc (diff) | |
| parent | 887d4bb67f255bf90bb5863e8178854d3dd01c2f (diff) | |
Merge "Fix not animating icons" into tm-qpr-dev am: 887d4bb67f
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20412473
Change-Id: I42e22065ca0616244ed8f6167eaa84d951c97e23
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSIconViewImpl.java | 21 | ||||
| -rw-r--r-- | packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSIconViewImplTest.java | 8 |
2 files changed, 19 insertions, 10 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSIconViewImpl.java b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSIconViewImpl.java index 1f92b12c1a83..cd69f4edff63 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSIconViewImpl.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSIconViewImpl.java @@ -140,16 +140,21 @@ public class QSIconViewImpl extends QSIconView { iv.setTag(R.id.qs_icon_tag, icon); iv.setTag(R.id.qs_slash_tag, state.slash); iv.setPadding(0, padding, 0, padding); - if (shouldAnimate && d instanceof Animatable2) { + if (d instanceof Animatable2) { Animatable2 a = (Animatable2) d; a.start(); - if (state.isTransient) { - a.registerAnimationCallback(new AnimationCallback() { - @Override - public void onAnimationEnd(Drawable drawable) { - a.start(); - } - }); + if (shouldAnimate) { + if (state.isTransient) { + a.registerAnimationCallback(new AnimationCallback() { + @Override + public void onAnimationEnd(Drawable drawable) { + a.start(); + } + }); + } + } else { + // Sends animator to end of animation. Needs to be called after calling start. + a.stop(); } } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSIconViewImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSIconViewImplTest.java index b067ee76f3b3..f55d262cfc0d 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSIconViewImplTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSIconViewImplTest.java @@ -40,6 +40,8 @@ import com.android.systemui.plugins.qs.QSTile.State; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.InOrder; +import org.mockito.Mockito; @RunWith(AndroidTestingRunner.class) @UiThreadTest @@ -138,7 +140,7 @@ public class QSIconViewImplTest extends SysuiTestCase { } @Test - public void testIconNotAnimatedWhenAllowAnimationsFalse() { + public void testIconStartedAndStoppedWhenAllowAnimationsFalse() { ImageView iv = new ImageView(mContext); AnimatedVectorDrawable d = mock(AnimatedVectorDrawable.class); State s = new State(); @@ -148,7 +150,9 @@ public class QSIconViewImplTest extends SysuiTestCase { mIconView.updateIcon(iv, s, false); - verify(d, never()).start(); + InOrder inOrder = Mockito.inOrder(d); + inOrder.verify(d).start(); + inOrder.verify(d).stop(); } private static Drawable.ConstantState fakeConstantState(Drawable otherDrawable) { |