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

Commit 6c6ddf37 authored by Charlie Anderson's avatar Charlie Anderson Committed by Android (Google) Code Review
Browse files

Merge "remove shape-based icon scaling" into main

parents c1b28e1d 31c99eb1
Loading
Loading
Loading
Loading
+1 −8
Original line number Diff line number Diff line
@@ -189,10 +189,7 @@ public class BaseIconFactory implements AutoCloseable {
    @NonNull
    public AdaptiveIconDrawable createShapedAdaptiveIcon(Bitmap iconBitmap) {
        Drawable drawable = new FixedSizeBitmapDrawable(iconBitmap);
        if (getIconScale() < 1f) {
            drawable = createScaledDrawable(drawable, 1 / getIconScale());
        }
        float inset = getExtraInsetFraction() * getIconScale();
        float inset = getExtraInsetFraction();
        inset = inset / (1 + 2 * inset);
        return new AdaptiveIconDrawable(new ColorDrawable(BLACK),
                new InsetDrawable(drawable, inset, inset, inset, inset)
@@ -298,10 +295,6 @@ public class BaseIconFactory implements AutoCloseable {
        return drawable.getIconMask();
    }

    public float getIconScale() {
        return 1f;
    }

    @NonNull
    public Bitmap getWhiteShadowLayer() {
        if (mWhiteShadowLayer == null) {
+2 −2
Original line number Diff line number Diff line
@@ -100,12 +100,12 @@ public class MonochromeIconFactory extends Drawable {
     * Creates a monochrome version of the provided drawable
     */
    @WorkerThread
    public Drawable wrap(AdaptiveIconDrawable icon, Path shapePath, Float iconScale) {
    public Drawable wrap(AdaptiveIconDrawable icon, Path shapePath) {
        mFlatCanvas.drawColor(Color.BLACK);
        drawDrawable(icon.getBackground());
        drawDrawable(icon.getForeground());
        generateMono();
        return new ClippedMonoDrawable(this, shapePath, iconScale);
        return new ClippedMonoDrawable(this, shapePath);
    }

    @WorkerThread
+4 −10
Original line number Diff line number Diff line
@@ -62,7 +62,6 @@ class MonoIconThemeController(
                icon,
                info,
                factory.getShapePath(icon, Rect(0, 0, info.icon.width, info.icon.height)),
                factory.iconScale,
                sourceHint?.isFileDrawable ?: false,
                factory.shouldForceThemeIcon(),
            )
@@ -85,16 +84,15 @@ class MonoIconThemeController(
        base: AdaptiveIconDrawable,
        info: BitmapInfo,
        shapePath: Path,
        iconScale: Float,
        isFileDrawable: Boolean,
        shouldForceThemeIcon: Boolean,
    ): Drawable? {
        val mono = base.monochrome
        if (mono != null) {
            return ClippedMonoDrawable(mono, shapePath, iconScale)
            return ClippedMonoDrawable(mono, shapePath)
        }
        if (Flags.forceMonochromeAppIcons() && shouldForceThemeIcon && !isFileDrawable) {
            return MonochromeIconFactory(info.icon.width).wrap(base, shapePath, iconScale)
            return MonochromeIconFactory(info.icon.width).wrap(base, shapePath)
        }
        return null
    }
@@ -149,11 +147,8 @@ class MonoIconThemeController(
        return monoDrawable?.let { AdaptiveIconDrawable(ColorDrawable(colors[0]), it) }
    }

    class ClippedMonoDrawable(
        base: Drawable?,
        private val shapePath: Path,
        private val iconScale: Float,
    ) : InsetDrawable(base, -AdaptiveIconDrawable.getExtraInsetFraction()) {
    class ClippedMonoDrawable(base: Drawable?, private val shapePath: Path) :
        InsetDrawable(base, -AdaptiveIconDrawable.getExtraInsetFraction()) {
        // TODO(b/399666950): remove this after launcher icon shapes is fully enabled
        private val mCrop = AdaptiveIconDrawable(ColorDrawable(Color.BLACK), null)

@@ -162,7 +157,6 @@ class MonoIconThemeController(
            val saveCount = canvas.save()
            if (Flags.enableLauncherIconShapes()) {
                canvas.clipPath(shapePath)
                canvas.scale(iconScale, iconScale, bounds.width() / 2f, bounds.height() / 2f)
            } else {
                canvas.clipPath(mCrop.iconMask)
            }