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

Commit badf5f5f authored by Steven Ng's avatar Steven Ng
Browse files

Expose disabled color filter for drawable

Fix: 192333050
Test: Manual
Change-Id: I8ef548b934183f152d0df1c80998d85202fd0e8a
parent ecaa3818
Loading
Loading
Loading
Loading
+20 −16
Original line number Diff line number Diff line
@@ -253,22 +253,7 @@ public class FastBitmapDrawable extends Drawable {

    private ColorFilter getDisabledColorFilter() {
        if (sDisabledFColorFilter == null) {
            ColorMatrix tempBrightnessMatrix = new ColorMatrix();
            ColorMatrix tempFilterMatrix = new ColorMatrix();

            tempFilterMatrix.setSaturation(1f - DISABLED_DESATURATION);
            float scale = 1 - DISABLED_BRIGHTNESS;
            int brightnessI =   (int) (255 * DISABLED_BRIGHTNESS);
            float[] mat = tempBrightnessMatrix.getArray();
            mat[0] = scale;
            mat[6] = scale;
            mat[12] = scale;
            mat[4] = brightnessI;
            mat[9] = brightnessI;
            mat[14] = brightnessI;
            mat[18] = mDisabledAlpha;
            tempFilterMatrix.preConcat(tempBrightnessMatrix);
            sDisabledFColorFilter = new ColorMatrixColorFilter(tempFilterMatrix);
            sDisabledFColorFilter = getDisabledFColorFilter(mDisabledAlpha);
        }
        return sDisabledFColorFilter;
    }
@@ -286,6 +271,25 @@ public class FastBitmapDrawable extends Drawable {
        return new FastBitmapConstantState(mBitmap, mIconColor, mIsDisabled);
    }

    public static ColorFilter getDisabledFColorFilter(float disabledAlpha) {
        ColorMatrix tempBrightnessMatrix = new ColorMatrix();
        ColorMatrix tempFilterMatrix = new ColorMatrix();

        tempFilterMatrix.setSaturation(1f - DISABLED_DESATURATION);
        float scale = 1 - DISABLED_BRIGHTNESS;
        int brightnessI =   (int) (255 * DISABLED_BRIGHTNESS);
        float[] mat = tempBrightnessMatrix.getArray();
        mat[0] = scale;
        mat[6] = scale;
        mat[12] = scale;
        mat[4] = brightnessI;
        mat[9] = brightnessI;
        mat[14] = brightnessI;
        mat[18] = disabledAlpha;
        tempFilterMatrix.preConcat(tempBrightnessMatrix);
        return new ColorMatrixColorFilter(tempBrightnessMatrix);
    }

    protected static class FastBitmapConstantState extends ConstantState {
        protected final Bitmap mBitmap;
        protected final int mIconColor;