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

Commit 99f7c361 authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Forcing pending app icons to be croped to the iconShape

Bug: 153761619
Test: Verified icon on device
Change-Id: Ie19f7705f8c9513a0a7f23dfa4272e84fed9901f
parent efe0d795
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.graphics.drawable.AdaptiveIconDrawable;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.InsetDrawable;
import android.os.Build;
import android.os.Process;
import android.os.UserHandle;
@@ -152,6 +153,20 @@ public class BaseIconFactory implements AutoCloseable {
        return BitmapInfo.of(icon, extractColor(icon));
    }

    /**
     * Creates an icon from the bitmap cropped to the current device icon shape
     */
    public BitmapInfo createShapedIconBitmap(Bitmap icon, UserHandle user) {
        Drawable d = new FixedSizeBitmapDrawable(icon);
        if (ATLEAST_OREO) {
            float inset = AdaptiveIconDrawable.getExtraInsetFraction();
            inset = inset / (1 + 2 * inset);
            d = new AdaptiveIconDrawable(new ColorDrawable(Color.BLACK),
                    new InsetDrawable(d, inset, inset, inset, inset));
        }
        return createBadgedIconBitmap(d, user, true);
    }

    public BitmapInfo createBadgedIconBitmap(Drawable icon, UserHandle user,
            boolean shrinkNonAdaptiveIcons) {
        return createBadgedIconBitmap(icon, user, shrinkNonAdaptiveIcons, false, null);
+1 −1
Original line number Diff line number Diff line
@@ -396,7 +396,7 @@ public abstract class BaseIconCache {
        }
        if (icon != null) {
            BaseIconFactory li = getIconFactory();
            entry.bitmap = li.createIconBitmap(icon);
            entry.bitmap = li.createShapedIconBitmap(icon, user);
            li.close();
        }
        if (!TextUtils.isEmpty(title) && entry.bitmap.icon != null) {