Merge "Dedupe updates to the home handle tint"
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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. */
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
@@ -59,6 +59,15 @@ public class NavigationHandle extends View implements ButtonInterface {
|
||||
setFocusable(false);
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user