Adding method to check if the drawable is themed or not

Bug: 188840653
Test: Manual
Change-Id: I1ed7fc0ff9e95558b73b94e08bda7156eb7ac178
diff --git a/iconloaderlib/src/com/android/launcher3/icons/ClockDrawableWrapper.java b/iconloaderlib/src/com/android/launcher3/icons/ClockDrawableWrapper.java
index 41de147..a7894c9 100644
--- a/iconloaderlib/src/com/android/launcher3/icons/ClockDrawableWrapper.java
+++ b/iconloaderlib/src/com/android/launcher3/icons/ClockDrawableWrapper.java
@@ -281,15 +281,22 @@
         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 @@
                 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 @@
 
         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);
         }
     }
 
@@ -379,6 +382,11 @@
         }
 
         @Override
+        public boolean isThemed() {
+            return mInfo.bgFilter != null;
+        }
+
+        @Override
         protected void updateFilter() {
             super.updateFilter();
             mFullDrawable.setColorFilter(mPaint.getColorFilter());
diff --git a/iconloaderlib/src/com/android/launcher3/icons/FastBitmapDrawable.java b/iconloaderlib/src/com/android/launcher3/icons/FastBitmapDrawable.java
index 72864c8..96ee291 100644
--- a/iconloaderlib/src/com/android/launcher3/icons/FastBitmapDrawable.java
+++ b/iconloaderlib/src/com/android/launcher3/icons/FastBitmapDrawable.java
@@ -120,6 +120,13 @@
         return mIconColor;
     }
 
+    /**
+     * Returns if this represents a themed icon
+     */
+    public boolean isThemed() {
+        return false;
+    }
+
     @Override
     public void setColorFilter(ColorFilter cf) {
         mColorFilter = cf;
diff --git a/iconloaderlib/src/com/android/launcher3/icons/ThemedIconDrawable.java b/iconloaderlib/src/com/android/launcher3/icons/ThemedIconDrawable.java
index b4d72d4..797a439 100644
--- a/iconloaderlib/src/com/android/launcher3/icons/ThemedIconDrawable.java
+++ b/iconloaderlib/src/com/android/launcher3/icons/ThemedIconDrawable.java
@@ -101,6 +101,11 @@
     }
 
     @Override
+    public boolean isThemed() {
+        return true;
+    }
+
+    @Override
     public ConstantState getConstantState() {
         return new ThemedConstantState(bitmapInfo, colorBg, colorFg, mIsDisabled);
     }