Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3f80cd26 authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

Merge "Dedupe updates to the home handle tint"

parents 3540161b a217afdc
Loading
Loading
Loading
Loading
+20 −5
Original line number Diff line number Diff line
@@ -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) {
        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;
            }
        }
    }

+3 −1
Original line number Diff line number Diff line
@@ -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. */
+5 −2
Original line number Diff line number Diff line
@@ -259,12 +259,15 @@ 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();
            }
        }
    }

    private void renderLight(EdgeLight light, Canvas canvas) {
        if (light.getLength() > 0) {
+10 −4
Original line number Diff line number Diff line
@@ -203,10 +203,16 @@ public class ButtonDispatcher {
            mFadeAnimator.addUpdateListener(mAlphaListener);
            mFadeAnimator.start();
        } else {
            mAlpha = 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(alpha);
                    mViews.get(i).setAlpha(mAlpha);
                }
            }
        }
    }
+19 −6
Original line number Diff line number Diff line
@@ -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;
        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;
            }
        }
    }