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

Commit 4ed5fea6 authored by Sunny Goyal's avatar Sunny Goyal Committed by Automerger Merge Worker
Browse files

Adding method to check if the drawable is themed or not am: fc33a2fa

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/libs/systemui/+/14686825

Change-Id: Ic89383195bd1fcb6ff79e0a5b6bb3f9a921f88c8
parents 32cc8a4c fc33a2fa
Loading
Loading
Loading
Loading
+20 −12
Original line number Diff line number Diff line
@@ -281,15 +281,22 @@ public class ClockDrawableWrapper extends AdaptiveIconDrawable implements Bitmap
        public final Bitmap mFlattenedBackground;

        public final ThemeData themeData;
        public final ColorFilter bgFilter;

        ClockBitmapInfo(Bitmap icon, int color, float scale, AnimationInfo animInfo,
                Bitmap background, ThemeData themeData) {
            this(icon, color, scale, animInfo, background, themeData, null);
        }

        ClockBitmapInfo(Bitmap icon, int color, float scale, AnimationInfo animInfo,
                Bitmap background, ThemeData themeData, ColorFilter bgFilter) {
            super(icon, color);
            this.scale = scale;
            this.animInfo = animInfo;
            this.offset = (int) Math.ceil(ShadowGenerator.BLUR_FACTOR * icon.getWidth());
            this.mFlattenedBackground = background;
            this.themeData = themeData;
            this.bgFilter = bgFilter;
        }

        @Override
@@ -299,18 +306,9 @@ public class ClockDrawableWrapper extends AdaptiveIconDrawable implements Bitmap
                if (wrapper != null) {
                    int[] colors = getColors(context);
                    ColorFilter bgFilter = new PorterDuffColorFilter(colors[0], Mode.SRC_ATOP);
                    ClockBitmapInfo bitmapInfo = new ClockBitmapInfo(icon, colors[1], scale,
                            wrapper.mAnimationInfo, mFlattenedBackground, themeData) {

                        @Override
                        void drawBackground(Canvas canvas, Rect bounds, Paint paint) {
                            ColorFilter oldFilter = paint.getColorFilter();
                            paint.setColorFilter(bgFilter);
                            super.drawBackground(canvas, bounds, paint);
                            paint.setColorFilter(oldFilter);
                        }
                    };
                    return bitmapInfo.newIcon(context);
                    return new ClockBitmapInfo(icon, colors[1], scale,
                            wrapper.mAnimationInfo, mFlattenedBackground, themeData, bgFilter)
                            .newIcon(context);
                }
            }
            return super.newThemedIcon(context);
@@ -331,7 +329,12 @@ public class ClockDrawableWrapper extends AdaptiveIconDrawable implements Bitmap

        void drawBackground(Canvas canvas, Rect bounds, Paint paint) {
            // draw the background that is already flattened to a bitmap
            ColorFilter oldFilter = paint.getColorFilter();
            if (bgFilter != null) {
                paint.setColorFilter(bgFilter);
            }
            canvas.drawBitmap(mFlattenedBackground, null, bounds, paint);
            paint.setColorFilter(oldFilter);
        }
    }

@@ -378,6 +381,11 @@ public class ClockDrawableWrapper extends AdaptiveIconDrawable implements Bitmap
            reschedule();
        }

        @Override
        public boolean isThemed() {
            return mInfo.bgFilter != null;
        }

        @Override
        protected void updateFilter() {
            super.updateFilter();
+7 −0
Original line number Diff line number Diff line
@@ -120,6 +120,13 @@ public class FastBitmapDrawable extends Drawable {
        return mIconColor;
    }

    /**
     * Returns if this represents a themed icon
     */
    public boolean isThemed() {
        return false;
    }

    @Override
    public void setColorFilter(ColorFilter cf) {
        mColorFilter = cf;
+5 −0
Original line number Diff line number Diff line
@@ -100,6 +100,11 @@ public class ThemedIconDrawable extends FastBitmapDrawable {
        }
    }

    @Override
    public boolean isThemed() {
        return true;
    }

    @Override
    public ConstantState getConstantState() {
        return new ThemedConstantState(bitmapInfo, colorBg, colorFg, mIsDisabled);