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

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

Snap for 9385690 from 73e98d6a to tm-qpr2-release

Change-Id: Iac7b3e627311e7d374ee9cb84f94cb91642a1388
parents 370e8f68 73e98d6a
Loading
Loading
Loading
Loading
+19 −8
Original line number Diff line number Diff line
@@ -220,20 +220,31 @@ public class BaseIconFactory implements AutoCloseable {

        if (icon instanceof BitmapInfo.Extender) {
            info = ((BitmapInfo.Extender) icon).getExtendedInfo(bitmap, color, this, scale[0]);
        } else if (mMonoIconEnabled && IconProvider.ATLEAST_T
                && icon instanceof AdaptiveIconDrawable) {
            Drawable mono = ((AdaptiveIconDrawable) icon).getMonochrome();
        } else if (IconProvider.ATLEAST_T && mMonoIconEnabled) {
            Drawable mono = getMonochromeDrawable(icon);
            if (mono != null) {
                // Convert mono drawable to bitmap
                Drawable paddedMono = new ClippedMonoDrawable(mono);
                info.setMonoIcon(
                        createIconBitmap(paddedMono, scale[0], MODE_ALPHA), this);
                info.setMonoIcon(createIconBitmap(mono, scale[0], MODE_ALPHA), this);
            }
        }
        info = info.withFlags(getBitmapFlagOp(options));
        return info;
    }

    /**
     * Returns a monochromatic version of the given drawable or null, if it is not supported
     * @param base the original icon
     */
    @TargetApi(Build.VERSION_CODES.TIRAMISU)
    protected Drawable getMonochromeDrawable(Drawable base) {
        if (base instanceof AdaptiveIconDrawable) {
            Drawable mono = ((AdaptiveIconDrawable) base).getMonochrome();
            if (mono != null) {
                return new ClippedMonoDrawable(mono);
            }
        }
        return null;
    }

    @NonNull
    public FlagOp getBitmapFlagOp(@Nullable IconOptions options) {
        FlagOp op = FlagOp.NO_OP;
@@ -528,7 +539,7 @@ public class BaseIconFactory implements AutoCloseable {
        }
    }

    private static class ClippedMonoDrawable extends InsetDrawable {
    protected static class ClippedMonoDrawable extends InsetDrawable {

        @NonNull
        private final AdaptiveIconDrawable mCrop;