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

Commit 23357b75 authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Adding support for overriding bitmap mode during icon generation

Bug: 268253894
Test: Verified on device
Change-Id: Iff91144384789db9cbfb19e35009439ec68e3314
parent dee9e1f5
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -212,7 +212,8 @@ public class BaseIconFactory implements AutoCloseable {
        boolean shrinkNonAdaptiveIcons = options == null || options.mShrinkNonAdaptiveIcons;
        float[] scale = new float[1];
        icon = normalizeAndWrapToAdaptiveIcon(icon, shrinkNonAdaptiveIcons, null, scale);
        Bitmap bitmap = createIconBitmap(icon, scale[0], MODE_WITH_SHADOW);
        Bitmap bitmap = createIconBitmap(icon, scale[0],
                options == null ? MODE_WITH_SHADOW : options.mGenerationMode);

        int color = (options != null && options.mExtractedColor != null)
                ? options.mExtractedColor : mColorExtractor.findDominantColorByHue(bitmap);
@@ -463,6 +464,9 @@ public class BaseIconFactory implements AutoCloseable {

        boolean mIsInstantApp;

        @BitmapGenerationMode
        int mGenerationMode = MODE_WITH_SHADOW;

        @Nullable UserHandle mUserHandle;

        @ColorInt
@@ -503,6 +507,16 @@ public class BaseIconFactory implements AutoCloseable {
            mExtractedColor = color;
            return this;
        }

        /**
         * Sets the bitmap generation mode to use for the bitmap info. Note that some generation
         * modes do not support color extraction, so consider setting a extracted color manually
         * in those cases.
         */
        public IconOptions setBitmapGenerationMode(@BitmapGenerationMode int generationMode) {
            mGenerationMode = generationMode;
            return this;
        }
    }

    /**