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

Commit 12584781 authored by Hyunyoung Song's avatar Hyunyoung Song
Browse files

[DO NOT MERGE] Add shadow to Adaptive Icons

Bug: 35920618

Change-Id: Ib48a656f988d1f007c32ab15cb28d120fab1e94f
(cherry picked from commit da9ac1f0)
parent 9407d4ab
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -201,7 +201,7 @@ public class LauncherIcons {
            int textureWidth = iconBitmapSize;
            int textureHeight = iconBitmapSize;

            final Bitmap bitmap = Bitmap.createBitmap(textureWidth, textureHeight,
            Bitmap bitmap = Bitmap.createBitmap(textureWidth, textureHeight,
                    Bitmap.Config.ARGB_8888);
            final Canvas canvas = sCanvas;
            canvas.setBitmap(bitmap);
@@ -218,6 +218,16 @@ public class LauncherIcons {
            icon.setBounds(sOldBounds);
            canvas.setBitmap(null);

            if (FeatureFlags.ADAPTIVE_ICON_SHADOW && Utilities.isAtLeastO()) {
                try {
                    Class clazz = Class.forName("android.graphics.drawable.AdaptiveIconDrawable");
                    if (clazz.isAssignableFrom(icon.getClass())) {
                        bitmap = ShadowGenerator.getInstance(context).recreateIcon(bitmap);
                    }
                } catch (Exception e) {
                    // do nothing
                }
            }
            return bitmap;
        }
    }
@@ -233,7 +243,7 @@ public class LauncherIcons {
        }

        try {
            Class clazz = Class.forName("android.graphics.drawable.MaskableIconDrawable");
            Class clazz = Class.forName("android.graphics.drawable.AdaptiveIconDrawable");
            if (!clazz.isAssignableFrom(drawable.getClass())) {
                Drawable maskWrapper =
                        context.getDrawable(R.drawable.mask_drawable_wrapper).mutate();
+2 −0
Original line number Diff line number Diff line
@@ -44,4 +44,6 @@ public final class FeatureFlags {
    public static final boolean BADGE_ICONS = true;
    // When enabled, icons not supporting {@link MaskableIconDrawable} will be wrapped in this class.
    public static final boolean LEGACY_ICON_TREATMENT = false;
    // When enabled, adaptive icons would have shadows baked when being stored to icon cache.
    public static final boolean ADAPTIVE_ICON_SHADOW = true;
}