diff options
| author | 2017-07-05 17:10:04 -0400 | |
|---|---|---|
| committer | 2017-07-05 17:10:04 -0400 | |
| commit | bdcd1cc85bdeaeb3b025073c995107d02a97caf7 (patch) | |
| tree | 92ac0bccdf3dbdadee2cb91792485e98d9e0e34d | |
| parent | 5c5f1f641934d16d5bebb11ac19c9bd868964f12 (diff) | |
Don't animate grayscale if animations are off
Just set the final color instantly on QS icons if animations are off
(battery save mode).
Change-Id: I55a5bd6bab412b9b6a62d32b21adbf7d39cc9e72
Fixes: 62508363
Test: visual
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSIconViewImpl.java | 36 |
1 files changed, 20 insertions, 16 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 cdd0ebc57d5c..6659650601a6 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSIconViewImpl.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSIconViewImpl.java @@ -144,22 +144,26 @@ public class QSIconViewImpl extends QSIconView { } public static void animateGrayScale(int fromColor, int toColor, ImageView iv) { - final float fromAlpha = Color.alpha(fromColor); - final float toAlpha = Color.alpha(toColor); - final float fromChannel = Color.red(fromColor); - final float toChannel = Color.red(toColor); - - ValueAnimator anim = ValueAnimator.ofFloat(0, 1); - anim.setDuration(QS_ANIM_LENGTH); - - anim.addUpdateListener(animation -> { - float fraction = animation.getAnimatedFraction(); - int alpha = (int) (fromAlpha + (toAlpha - fromAlpha) * fraction); - int channel = (int) (fromChannel + (toChannel - fromChannel) * fraction); - - setTint(iv, Color.argb(alpha, channel, channel, channel)); - }); - anim.start(); + if (ValueAnimator.areAnimatorsEnabled()) { + final float fromAlpha = Color.alpha(fromColor); + final float toAlpha = Color.alpha(toColor); + final float fromChannel = Color.red(fromColor); + final float toChannel = Color.red(toColor); + + ValueAnimator anim = ValueAnimator.ofFloat(0, 1); + anim.setDuration(QS_ANIM_LENGTH); + anim.addUpdateListener(animation -> { + float fraction = animation.getAnimatedFraction(); + int alpha = (int) (fromAlpha + (toAlpha - fromAlpha) * fraction); + int channel = (int) (fromChannel + (toChannel - fromChannel) * fraction); + + setTint(iv, Color.argb(alpha, channel, channel, channel)); + }); + + anim.start(); + } else { + setTint(iv, toColor); + } } public static void setTint(ImageView iv, int color) { |