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

Commit bd0c04a4 authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Fixing themed icons not getting cropped to icon mask

Bug: 221273742
Test: Manual
Change-Id: I99fcb11e4cb306b9e4795ca2a9a17db3eb799445
parent 7bc26cd6
Loading
Loading
Loading
Loading
+20 −1
Original line number Diff line number Diff line
@@ -204,7 +204,7 @@ public class BaseIconFactory implements AutoCloseable {
            Drawable mono = ((AdaptiveIconDrawable) icon).getMonochrome();
            if (mono != null) {
                // Convert mono drawable to bitmap
                Drawable paddedMono = new InsetDrawable(mono, -getExtraInsetFraction());
                Drawable paddedMono = new ClippedMonoDrawable(mono);
                info.setMonoIcon(
                        createIconBitmap(paddedMono, scale[0], mIconBitmapSize, Config.ALPHA_8),
                        this);
@@ -472,4 +472,23 @@ public class BaseIconFactory implements AutoCloseable {
            return 1;
        }
    }

    private static class ClippedMonoDrawable extends InsetDrawable {

        private final AdaptiveIconDrawable mCrop;

        public ClippedMonoDrawable(Drawable base) {
            super(base, -getExtraInsetFraction());
            mCrop = new AdaptiveIconDrawable(new ColorDrawable(Color.BLACK), null);
        }

        @Override
        public void draw(Canvas canvas) {
            mCrop.setBounds(getBounds());
            int saveCount = canvas.save();
            canvas.clipPath(mCrop.getIconMask());
            super.draw(canvas);
            canvas.restoreToCount(saveCount);
        }
    }
}