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

Commit 9142dc1d authored by Sihua Ma's avatar Sihua Ma Committed by Android (Google) Code Review
Browse files

Merge "Experimentally increasing contrast for themed icons" into main

parents b6eab990 c1850b40
Loading
Loading
Loading
Loading
+23 −1
Original line number Diff line number Diff line
@@ -82,7 +82,6 @@ public class MonochromeIconFactory extends Drawable {
        // Crate a color matrix which converts the icon to grayscale and then uses the average
        // of RGB components as the alpha component.
        ColorMatrix satMatrix = new ColorMatrix();
        satMatrix.setSaturation(0);
        float[] vals = satMatrix.getArray();
        vals[15] = vals[16] = vals[17] = .3333f;
        vals[18] = vals[19] = 0;
@@ -145,6 +144,29 @@ public class MonochromeIconFactory extends Drawable {
                int p2 = Math.round((p - min) * 0xFF / range);
                mPixels[i] = flipColor ? (byte) (255 - p2) : (byte) (p2);
            }

            // Second phase of processing, aimed on increasing the contrast
            for (int i = 0; i < mPixels.length; i++) {
                int p = mPixels[i] & 0xFF;
                int p2;
                double coefficient;
                if (p > 128) {
                    coefficient = (1 - (double) (p - 128) / 128);
                    p2 = 255 - (int) (coefficient * (255 - p));
                } else {
                    coefficient = (1 - (double) (128 - p) / 128);
                    p2 = (int) (coefficient * p);
                }

                if (p2 > 255) {
                    p2 = 255;
                } else if (p2 < 0) {
                    p2 = 0;
                }

                mPixels[i] = (byte) p2;
            }

            buffer.rewind();
            mAlphaBitmap.copyPixelsFromBuffer(buffer);
        }
+2 −3
Original line number Diff line number Diff line
@@ -639,9 +639,8 @@ constructor(
        fun getPackageKey(packageName: String, user: UserHandle) =
            ComponentKey(ComponentName(packageName, packageName + EMPTY_CLASS_NAME), user)

        // Ensures archived app icons are invalidated after flag is flipped.
        // TODO: Remove conditional with FLAG_USE_NEW_ICON_FOR_ARCHIVED_APPS
        @JvmField val RELEASE_VERSION = if (Flags.forceMonochromeAppIcons()) 3 else 2
        // Ensures themed bitmaps in the icon cache are invalidated
        @JvmField val RELEASE_VERSION = if (Flags.forceMonochromeAppIcons()) 4 else 3

        @JvmField val TABLE_NAME = "icons"
        @JvmField val COLUMN_ROWID = "rowid"