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

Commit d0b5d91d authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 13143403 from 550c9145 to 25Q2-release

Change-Id: I30554aea6261b40770e675591a3edbca1979fd11
parents 099ce71e 550c9145
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -27,4 +27,7 @@
    <string name="calendar_component_name" translatable="false"></string>
    <string name="clock_component_name" translatable="false"></string>

    <!-- Configures whether to enable forced theme icon, disabled by default -->
    <bool name="enable_forced_themed_icon">false</bool>

</resources>
 No newline at end of file
+12 −0
Original line number Diff line number Diff line
@@ -102,6 +102,8 @@ public class BaseIconFactory implements AutoCloseable {

    private static int PLACEHOLDER_BACKGROUND_COLOR = Color.rgb(245, 245, 245);

    private final boolean mShouldForceThemeIcon;

    protected BaseIconFactory(Context context, int fullResIconDpi, int iconBitmapSize,
            boolean unused) {
        this(context, fullResIconDpi, iconBitmapSize);
@@ -118,6 +120,9 @@ public class BaseIconFactory implements AutoCloseable {
        mCanvas = new Canvas();
        mCanvas.setDrawFilter(new PaintFlagsDrawFilter(DITHER_FLAG, FILTER_BITMAP_FLAG));
        clear();

        mShouldForceThemeIcon = mContext.getResources().getBoolean(
                R.bool.enable_forced_themed_icon);
    }

    protected void clear() {
@@ -263,6 +268,13 @@ public class BaseIconFactory implements AutoCloseable {
        return op;
    }

    /**
     * @return True if forced theme icon is enabled
     */
    public boolean shouldForceThemeIcon() {
        return mShouldForceThemeIcon;
    }

    @NonNull
    protected UserIconInfo getUserInfo(@NonNull UserHandle user) {
        int key = user.hashCode();
+13 −3
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.graphics.Bitmap.Config.HARDWARE
import android.graphics.BlendMode.SRC_IN
import android.graphics.BlendModeColorFilter
import android.graphics.Canvas
import android.graphics.Color
import android.graphics.Path
import android.graphics.Rect
import android.graphics.drawable.AdaptiveIconDrawable
@@ -63,6 +64,7 @@ class MonoIconThemeController(
                factory.getShapePath(icon, Rect(0, 0, info.icon.width, info.icon.height)),
                factory.iconScale,
                sourceHint?.isFileDrawable ?: false,
                factory.shouldForceThemeIcon(),
            )
        if (mono != null) {
            return MonoThemedBitmap(
@@ -85,12 +87,13 @@ class MonoIconThemeController(
        shapePath: Path,
        iconScale: Float,
        isFileDrawable: Boolean,
        shouldForceThemeIcon: Boolean,
    ): Drawable? {
        val mono = base.monochrome
        if (mono != null) {
            return ClippedMonoDrawable(mono, shapePath, iconScale)
        }
        if (Flags.forceMonochromeAppIcons() && !isFileDrawable) {
        if (Flags.forceMonochromeAppIcons() && shouldForceThemeIcon && !isFileDrawable) {
            return MonochromeIconFactory(info.icon.width).wrap(base, shapePath, iconScale)
        }
        return null
@@ -151,11 +154,18 @@ class MonoIconThemeController(
        private val shapePath: Path,
        private val iconScale: Float,
    ) : InsetDrawable(base, -AdaptiveIconDrawable.getExtraInsetFraction()) {
        // TODO(b/399666950): remove this after launcher icon shapes is fully enabled
        private val mCrop = AdaptiveIconDrawable(ColorDrawable(Color.BLACK), null)

        override fun draw(canvas: Canvas) {
            mCrop.bounds = bounds
            val saveCount = canvas.save()
            if (Flags.enableLauncherIconShapes()) {
                canvas.clipPath(shapePath)
            canvas.scale(iconScale, iconScale, canvas.width / 2f, canvas.height / 2f)
                canvas.scale(iconScale, iconScale, bounds.width() / 2f, bounds.height() / 2f)
            } else {
                canvas.clipPath(mCrop.iconMask)
            }
            super.draw(canvas)
            canvas.restoreToCount(saveCount)
        }