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

Commit aa0c3ab6 authored by Andrew Cole's avatar Andrew Cole
Browse files

Remove Shrink Non Adaptive Icons

This function is now obsolete and we can remove this and default to always shrinking non-adaptive (legacy) icons

Test: AllAppsSearchImageTest
Bug: 318867282
Flag: None
Change-Id: Ibac6d9fcdd3d476b954c0339c23261b152927604
parent a8b41957
Loading
Loading
Loading
Loading
+4 −19
Original line number Diff line number Diff line
@@ -5,10 +5,7 @@ import static android.graphics.Paint.DITHER_FLAG;
import static android.graphics.Paint.FILTER_BITMAP_FLAG;
import static android.graphics.drawable.AdaptiveIconDrawable.getExtraInsetFraction;

import static com.android.launcher3.icons.BitmapInfo.FLAG_CLONE;
import static com.android.launcher3.icons.BitmapInfo.FLAG_INSTANT;
import static com.android.launcher3.icons.BitmapInfo.FLAG_PRIVATE;
import static com.android.launcher3.icons.BitmapInfo.FLAG_WORK;
import static com.android.launcher3.icons.ShadowGenerator.BLUR_FACTOR;

import static java.lang.annotation.RetentionPolicy.SOURCE;
@@ -214,9 +211,8 @@ public class BaseIconFactory implements AutoCloseable {
    @NonNull
    public BitmapInfo createBadgedIconBitmap(@NonNull Drawable icon,
            @Nullable IconOptions options) {
        boolean shrinkNonAdaptiveIcons = options == null || options.mShrinkNonAdaptiveIcons;
        float[] scale = new float[1];
        icon = normalizeAndWrapToAdaptiveIcon(icon, shrinkNonAdaptiveIcons, null, scale);
        icon = normalizeAndWrapToAdaptiveIcon(icon, null, scale);
        Bitmap bitmap = createIconBitmap(icon, scale[0],
                options == null ? MODE_WITH_SHADOW : options.mGenerationMode);

@@ -302,7 +298,7 @@ public class BaseIconFactory implements AutoCloseable {
    public Bitmap createScaledBitmap(@NonNull Drawable icon, @BitmapGenerationMode int mode) {
        RectF iconBounds = new RectF();
        float[] scale = new float[1];
        icon = normalizeAndWrapToAdaptiveIcon(icon, true, iconBounds, scale);
        icon = normalizeAndWrapToAdaptiveIcon(icon, iconBounds, scale);
        return createIconBitmap(icon,
                Math.min(scale[0], ShadowGenerator.getScaleForBounds(iconBounds)), mode);
    }
@@ -316,14 +312,13 @@ public class BaseIconFactory implements AutoCloseable {

    @Nullable
    protected Drawable normalizeAndWrapToAdaptiveIcon(@Nullable Drawable icon,
            final boolean shrinkNonAdaptiveIcons, @Nullable final RectF outIconBounds,
            @NonNull final float[] outScale) {
            @Nullable final RectF outIconBounds, @NonNull final float[] outScale) {
        if (icon == null) {
            return null;
        }

        float scale;
        if (shrinkNonAdaptiveIcons && !(icon instanceof AdaptiveIconDrawable)) {
        if (!(icon instanceof AdaptiveIconDrawable)) {
            EmptyWrapper foreground = new EmptyWrapper();
            AdaptiveIconDrawable dr = new AdaptiveIconDrawable(
                    new ColorDrawable(mWrapperBackgroundColor), foreground);
@@ -512,8 +507,6 @@ public class BaseIconFactory implements AutoCloseable {

    public static class IconOptions {

        boolean mShrinkNonAdaptiveIcons = true;

        boolean mIsInstantApp;

        @BitmapGenerationMode
@@ -526,14 +519,6 @@ public class BaseIconFactory implements AutoCloseable {
        @ColorInt
        @Nullable Integer mExtractedColor;

        /**
         * Set to false if non-adaptive icons should not be treated
         */
        @NonNull
        public IconOptions setShrinkNonAdaptiveIcons(final boolean shrink) {
            mShrinkNonAdaptiveIcons = shrink;
            return this;
        }

        /**
         * User for this icon, in case of badging
+0 −1
Original line number Diff line number Diff line
@@ -78,7 +78,6 @@ public class BubbleIconFactory extends BaseIconFactory {
            outScale = new float[1];
        }
        icon = normalizeAndWrapToAdaptiveIcon(icon,
                true /* shrinkNonAdaptiveIcons */,
                null /* outscale */,
                outScale);
        return createIconBitmap(icon, outScale[0], MODE_WITH_SHADOW);