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

Commit 6010f97b authored by Andrew Cole's avatar Andrew Cole
Browse files

Removing AdaptiveIconDrawable Checks

As part of the internal cleanup for adaptive icons, we are removing if checks for AdaptiveIconDrawable that are no longer necessary. Also refactoring to follow a more functional programming pattern for easier future refactors.

Bug: 318867282
Flag: EXEMPT BUGFIX
Test: AllAppsSearchImageTest
Change-Id: I9e72e6d061bc6f7b1661c35c87cca1ec91a77008
parent 44ab3f29
Loading
Loading
Loading
Loading
+9 −11
Original line number Diff line number Diff line
@@ -212,18 +212,18 @@ public class BaseIconFactory implements AutoCloseable {
    public BitmapInfo createBadgedIconBitmap(@NonNull Drawable icon,
            @Nullable IconOptions options) {
        float[] scale = new float[1];
        icon = normalizeAndWrapToAdaptiveIcon(icon, null, scale);
        Bitmap bitmap = createIconBitmap(icon, scale[0],
        AdaptiveIconDrawable adaptiveIcon = normalizeAndWrapToAdaptiveIcon(icon, null, scale);
        Bitmap bitmap = createIconBitmap(adaptiveIcon, scale[0],
                options == null ? MODE_WITH_SHADOW : options.mGenerationMode);

        int color = (options != null && options.mExtractedColor != null)
                ? options.mExtractedColor : mColorExtractor.findDominantColorByHue(bitmap);
        BitmapInfo info = BitmapInfo.of(bitmap, color);

        if (icon instanceof BitmapInfo.Extender) {
            info = ((BitmapInfo.Extender) icon).getExtendedInfo(bitmap, color, this, scale[0]);
        if (adaptiveIcon instanceof BitmapInfo.Extender extender) {
            info = extender.getExtendedInfo(bitmap, color, this, scale[0]);
        } else if (IconProvider.ATLEAST_T && mMonoIconEnabled) {
            Drawable mono = getMonochromeDrawable(icon);
            Drawable mono = getMonochromeDrawable(adaptiveIcon);
            if (mono != null) {
                info.setMonoIcon(createIconBitmap(mono, scale[0], MODE_ALPHA), this);
            }
@@ -238,13 +238,11 @@ public class BaseIconFactory implements AutoCloseable {
     * @param base the original icon
     */
    @TargetApi(Build.VERSION_CODES.TIRAMISU)
    protected Drawable getMonochromeDrawable(Drawable base) {
        if (base instanceof AdaptiveIconDrawable) {
            Drawable mono = ((AdaptiveIconDrawable) base).getMonochrome();
    protected Drawable getMonochromeDrawable(AdaptiveIconDrawable base) {
        Drawable mono = base.getMonochrome();
        if (mono != null) {
            return new ClippedMonoDrawable(mono);
        }
        }
        return null;
    }