diff options
author | 2019-11-05 19:19:52 +0000 | |
---|---|---|
committer | 2019-11-05 19:19:52 +0000 | |
commit | 3f80cd26ded60c3f569ec2b8ecfc7637f945dc7b (patch) | |
tree | 7357a7d8e04100e71af6e908b93a4f065f41646a | |
parent | 3540161ba0e13800fe31bda3c060190f747fef3e (diff) | |
parent | a217afdc699de2dc51d71b2494212ffebf6a92a4 (diff) |
Merge "Dedupe updates to the home handle tint"
5 files changed, 57 insertions, 18 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/CornerHandleView.java b/packages/SystemUI/src/com/android/systemui/CornerHandleView.java index a94952c5bc19..8e472f9c98a3 100644 --- a/packages/SystemUI/src/com/android/systemui/CornerHandleView.java +++ b/packages/SystemUI/src/com/android/systemui/CornerHandleView.java @@ -47,6 +47,7 @@ public class CornerHandleView extends View { private int mLightColor; private int mDarkColor; private Path mPath; + private boolean mRequiresInvalidate; public CornerHandleView(Context context, AttributeSet attrs) { super(context, attrs); @@ -67,6 +68,15 @@ public class CornerHandleView extends View { updatePath(); } + @Override + public void setAlpha(float alpha) { + super.setAlpha(alpha); + if (alpha > 0f && mRequiresInvalidate) { + mRequiresInvalidate = false; + invalidate(); + } + } + private void updatePath() { mPath = new Path(); @@ -104,11 +114,16 @@ public class CornerHandleView extends View { * appropriately. Intention is to match the home handle color. */ public void updateDarkness(float darkIntensity) { - mPaint.setColor((int) ArgbEvaluator.getInstance().evaluate(darkIntensity, - mLightColor, - mDarkColor)); - if (getVisibility() == VISIBLE) { - invalidate(); + int color = (int) ArgbEvaluator.getInstance().evaluate(darkIntensity, + mLightColor, mDarkColor); + if (mPaint.getColor() != color) { + mPaint.setColor(color); + if (getVisibility() == VISIBLE && getAlpha() > 0) { + invalidate(); + } else { + // If we are currently invisible, then invalidate when we are next made visible + mRequiresInvalidate = true; + } } } diff --git a/packages/SystemUI/src/com/android/systemui/assist/ui/EdgeLight.java b/packages/SystemUI/src/com/android/systemui/assist/ui/EdgeLight.java index baa3a4a938c1..c641943278d4 100644 --- a/packages/SystemUI/src/com/android/systemui/assist/ui/EdgeLight.java +++ b/packages/SystemUI/src/com/android/systemui/assist/ui/EdgeLight.java @@ -67,8 +67,10 @@ public final class EdgeLight { } /** Sets the edge light color. */ - public void setColor(@ColorInt int color) { + public boolean setColor(@ColorInt int color) { + boolean changed = mColor != color; mColor = color; + return changed; } /** Returns the edge light length, in units of the total device perimeter. */ diff --git a/packages/SystemUI/src/com/android/systemui/assist/ui/InvocationLightsView.java b/packages/SystemUI/src/com/android/systemui/assist/ui/InvocationLightsView.java index 570b911cd400..e5121a8ea35c 100644 --- a/packages/SystemUI/src/com/android/systemui/assist/ui/InvocationLightsView.java +++ b/packages/SystemUI/src/com/android/systemui/assist/ui/InvocationLightsView.java @@ -259,10 +259,13 @@ public class InvocationLightsView extends View if (mUseNavBarColor) { @ColorInt int invocationColor = (int) ArgbEvaluator.getInstance().evaluate( darkIntensity, mLightColor, mDarkColor); + boolean changed = true; for (EdgeLight light : mAssistInvocationLights) { - light.setColor(invocationColor); + changed &= light.setColor(invocationColor); + } + if (changed) { + invalidate(); } - invalidate(); } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ButtonDispatcher.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ButtonDispatcher.java index fce1dcc998fe..c2731089132c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ButtonDispatcher.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ButtonDispatcher.java @@ -203,10 +203,16 @@ public class ButtonDispatcher { mFadeAnimator.addUpdateListener(mAlphaListener); mFadeAnimator.start(); } else { - mAlpha = alpha; - final int N = mViews.size(); - for (int i = 0; i < N; i++) { - mViews.get(i).setAlpha(alpha); + // Discretize the alpha updates to prevent too frequent updates when there is a long + // alpha animation + int prevAlpha = (int) (getAlpha() * 255); + int nextAlpha = (int) (alpha * 255); + if (prevAlpha != nextAlpha) { + mAlpha = nextAlpha / 255f; + final int N = mViews.size(); + for (int i = 0; i < N; i++) { + mViews.get(i).setAlpha(mAlpha); + } } } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationHandle.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationHandle.java index 4f7af58094ec..abceb11b36e9 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationHandle.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationHandle.java @@ -31,13 +31,13 @@ import com.android.settingslib.Utils; import com.android.systemui.R; public class NavigationHandle extends View implements ButtonInterface { - private float mDarkIntensity = -1; private final Paint mPaint = new Paint(); private @ColorInt final int mLightColor; private @ColorInt final int mDarkColor; private final int mRadius; private final int mBottom; + private boolean mRequiresInvalidate; public NavigationHandle(Context context) { this(context, null); @@ -60,6 +60,15 @@ public class NavigationHandle extends View implements ButtonInterface { } @Override + public void setAlpha(float alpha) { + super.setAlpha(alpha); + if (alpha > 0f && mRequiresInvalidate) { + mRequiresInvalidate = false; + invalidate(); + } + } + + @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); @@ -85,11 +94,15 @@ public class NavigationHandle extends View implements ButtonInterface { @Override public void setDarkIntensity(float intensity) { - if (mDarkIntensity != intensity) { - mPaint.setColor((int) ArgbEvaluator.getInstance().evaluate(intensity, mLightColor, - mDarkColor)); - mDarkIntensity = intensity; - invalidate(); + int color = (int) ArgbEvaluator.getInstance().evaluate(intensity, mLightColor, mDarkColor); + if (mPaint.getColor() != color) { + mPaint.setColor(color); + if (getVisibility() == VISIBLE && getAlpha() > 0) { + invalidate(); + } else { + // If we are currently invisible, then invalidate when we are next made visible + mRequiresInvalidate = true; + } } } |