Loading iconloaderlib/src/com/android/launcher3/icons/BitmapInfo.java +2 −1 Original line number Diff line number Diff line Loading @@ -59,6 +59,7 @@ public class BitmapInfo { public static final String TAG = "BitmapInfo"; @NonNull public final Bitmap icon; public final int color; Loading @@ -72,7 +73,7 @@ public class BitmapInfo { private BitmapInfo badgeInfo; public BitmapInfo(Bitmap icon, int color) { public BitmapInfo(@NonNull Bitmap icon, int color) { this.icon = icon; this.color = color; } Loading iconloaderlib/src/com/android/launcher3/icons/ClockDrawableWrapper.java +5 −5 Original line number Diff line number Diff line Loading @@ -306,7 +306,7 @@ public class ClockDrawableWrapper extends AdaptiveIconDrawable implements Bitmap return super.newIcon(context, creationFlags); } ClockIconDrawable.ClockConstantState cs = new ClockIconDrawable.ClockConstantState( icon, color, themedFgColor, boundsOffset, info, bg, bgFilter); this, themedFgColor, boundsOffset, info, bg, bgFilter); FastBitmapDrawable d = cs.newDrawable(); applyFlags(context, d, creationFlags); return d; Loading Loading @@ -341,7 +341,7 @@ public class ClockDrawableWrapper extends AdaptiveIconDrawable implements Bitmap private final float mCanvasScale; ClockIconDrawable(ClockConstantState cs) { super(cs.mBitmap, cs.mIconColor); super(cs.mBitmapInfo); mBoundsOffset = cs.mBoundsOffset; mAnimInfo = cs.mAnimInfo; Loading Loading @@ -447,7 +447,7 @@ public class ClockDrawableWrapper extends AdaptiveIconDrawable implements Bitmap @Override public FastBitmapConstantState newConstantState() { return new ClockConstantState(mBitmap, mIconColor, mThemedFgColor, mBoundsOffset, return new ClockConstantState(mBitmapInfo, mThemedFgColor, mBoundsOffset, mAnimInfo, mBG, mBgPaint.getColorFilter()); } Loading @@ -459,9 +459,9 @@ public class ClockDrawableWrapper extends AdaptiveIconDrawable implements Bitmap private final ColorFilter mBgFilter; private final int mThemedFgColor; ClockConstantState(Bitmap bitmap, int color, int themedFgColor, ClockConstantState(BitmapInfo info, int themedFgColor, float boundsOffset, AnimationInfo animInfo, Bitmap bg, ColorFilter bgFilter) { super(bitmap, color); super(info); mBoundsOffset = boundsOffset; mAnimInfo = animInfo; mBG = bg; Loading iconloaderlib/src/com/android/launcher3/icons/FastBitmapDrawable.java +25 −18 Original line number Diff line number Diff line Loading @@ -65,8 +65,7 @@ public class FastBitmapDrawable extends Drawable implements Drawable.Callback { private static boolean sFlagHoverEnabled = false; protected final Paint mPaint = new Paint(Paint.FILTER_BITMAP_FLAG | Paint.ANTI_ALIAS_FLAG); protected final Bitmap mBitmap; protected final int mIconColor; public final BitmapInfo mBitmapInfo; @Nullable private ColorFilter mColorFilter; Loading Loading @@ -99,18 +98,24 @@ public class FastBitmapDrawable extends Drawable implements Drawable.Callback { private boolean mHoverScaleEnabledForDisplay = true; protected FastBitmapDrawable(Bitmap b, int iconColor) { this(BitmapInfo.of(b, iconColor)); } public FastBitmapDrawable(Bitmap b) { this(b, Color.TRANSPARENT); this(BitmapInfo.fromBitmap(b)); } public FastBitmapDrawable(BitmapInfo info) { this(info.icon, info.color); mBitmapInfo = info; setFilterBitmap(true); } protected FastBitmapDrawable(Bitmap b, int iconColor) { mBitmap = b; mIconColor = iconColor; setFilterBitmap(true); /** * Returns true if the drawable points to the same bitmap icon object */ public boolean isSameInfo(BitmapInfo info) { return mBitmapInfo == info; } @Override Loading Loading @@ -145,7 +150,7 @@ public class FastBitmapDrawable extends Drawable implements Drawable.Callback { } protected void drawInternal(Canvas canvas, Rect bounds) { canvas.drawBitmap(mBitmap, null, bounds, mPaint); canvas.drawBitmap(mBitmapInfo.icon, null, bounds, mPaint); } /** Loading @@ -153,7 +158,7 @@ public class FastBitmapDrawable extends Drawable implements Drawable.Callback { */ public int getIconColor() { int whiteScrim = setColorAlphaBound(Color.WHITE, WHITE_SCRIM_ALPHA); return ColorUtils.compositeColors(whiteScrim, mIconColor); return ColorUtils.compositeColors(whiteScrim, mBitmapInfo.color); } /** Loading Loading @@ -220,12 +225,12 @@ public class FastBitmapDrawable extends Drawable implements Drawable.Callback { @Override public int getIntrinsicWidth() { return mBitmap.getWidth(); return mBitmapInfo.icon.getWidth(); } @Override public int getIntrinsicHeight() { return mBitmap.getHeight(); return mBitmapInfo.icon.getHeight(); } @Override Loading Loading @@ -333,7 +338,7 @@ public class FastBitmapDrawable extends Drawable implements Drawable.Callback { } protected FastBitmapConstantState newConstantState() { return new FastBitmapConstantState(mBitmap, mIconColor); return new FastBitmapConstantState(mBitmapInfo); } @Override Loading Loading @@ -423,8 +428,7 @@ public class FastBitmapDrawable extends Drawable implements Drawable.Callback { } public static class FastBitmapConstantState extends ConstantState { protected final Bitmap mBitmap; protected final int mIconColor; protected final BitmapInfo mBitmapInfo; // These are initialized later so that subclasses don't need to // pass everything in constructor Loading @@ -434,12 +438,15 @@ public class FastBitmapDrawable extends Drawable implements Drawable.Callback { @DrawableCreationFlags int mCreationFlags = 0; public FastBitmapConstantState(Bitmap bitmap, int color) { mBitmap = bitmap; mIconColor = color; this(BitmapInfo.of(bitmap, color)); } public FastBitmapConstantState(BitmapInfo info) { mBitmapInfo = info; } protected FastBitmapDrawable createDrawable() { return new FastBitmapDrawable(mBitmap, mIconColor); return new FastBitmapDrawable(mBitmapInfo); } @Override Loading iconloaderlib/src/com/android/launcher3/icons/mono/ThemedIconDrawable.kt +5 −6 Original line number Diff line number Diff line Loading @@ -28,8 +28,7 @@ import com.android.launcher3.icons.R /** Class to handle monochrome themed app icons */ class ThemedIconDrawable(constantState: ThemedConstantState) : FastBitmapDrawable(constantState.getBitmap(), constantState.colorFg) { val bitmapInfo = constantState.bitmapInfo FastBitmapDrawable(constantState.getBitmapInfo()) { private val colorFg = constantState.colorFg private val colorBg = constantState.colorBg Loading Loading @@ -66,21 +65,21 @@ class ThemedIconDrawable(constantState: ThemedConstantState) : override fun isThemed() = true override fun newConstantState() = ThemedConstantState(bitmapInfo, monoIcon, bgBitmap, colorBg, colorFg) ThemedConstantState(mBitmapInfo, monoIcon, bgBitmap, colorBg, colorFg) override fun getIconColor() = colorFg class ThemedConstantState( val bitmapInfo: BitmapInfo, bitmapInfo: BitmapInfo, val mono: Bitmap, val whiteShadowLayer: Bitmap, val colorBg: Int, val colorFg: Int, ) : FastBitmapConstantState(bitmapInfo.icon, bitmapInfo.color) { ) : FastBitmapConstantState(bitmapInfo) { public override fun createDrawable() = ThemedIconDrawable(this) fun getBitmap(): Bitmap = mBitmap fun getBitmapInfo(): BitmapInfo = mBitmapInfo } companion object { Loading Loading
iconloaderlib/src/com/android/launcher3/icons/BitmapInfo.java +2 −1 Original line number Diff line number Diff line Loading @@ -59,6 +59,7 @@ public class BitmapInfo { public static final String TAG = "BitmapInfo"; @NonNull public final Bitmap icon; public final int color; Loading @@ -72,7 +73,7 @@ public class BitmapInfo { private BitmapInfo badgeInfo; public BitmapInfo(Bitmap icon, int color) { public BitmapInfo(@NonNull Bitmap icon, int color) { this.icon = icon; this.color = color; } Loading
iconloaderlib/src/com/android/launcher3/icons/ClockDrawableWrapper.java +5 −5 Original line number Diff line number Diff line Loading @@ -306,7 +306,7 @@ public class ClockDrawableWrapper extends AdaptiveIconDrawable implements Bitmap return super.newIcon(context, creationFlags); } ClockIconDrawable.ClockConstantState cs = new ClockIconDrawable.ClockConstantState( icon, color, themedFgColor, boundsOffset, info, bg, bgFilter); this, themedFgColor, boundsOffset, info, bg, bgFilter); FastBitmapDrawable d = cs.newDrawable(); applyFlags(context, d, creationFlags); return d; Loading Loading @@ -341,7 +341,7 @@ public class ClockDrawableWrapper extends AdaptiveIconDrawable implements Bitmap private final float mCanvasScale; ClockIconDrawable(ClockConstantState cs) { super(cs.mBitmap, cs.mIconColor); super(cs.mBitmapInfo); mBoundsOffset = cs.mBoundsOffset; mAnimInfo = cs.mAnimInfo; Loading Loading @@ -447,7 +447,7 @@ public class ClockDrawableWrapper extends AdaptiveIconDrawable implements Bitmap @Override public FastBitmapConstantState newConstantState() { return new ClockConstantState(mBitmap, mIconColor, mThemedFgColor, mBoundsOffset, return new ClockConstantState(mBitmapInfo, mThemedFgColor, mBoundsOffset, mAnimInfo, mBG, mBgPaint.getColorFilter()); } Loading @@ -459,9 +459,9 @@ public class ClockDrawableWrapper extends AdaptiveIconDrawable implements Bitmap private final ColorFilter mBgFilter; private final int mThemedFgColor; ClockConstantState(Bitmap bitmap, int color, int themedFgColor, ClockConstantState(BitmapInfo info, int themedFgColor, float boundsOffset, AnimationInfo animInfo, Bitmap bg, ColorFilter bgFilter) { super(bitmap, color); super(info); mBoundsOffset = boundsOffset; mAnimInfo = animInfo; mBG = bg; Loading
iconloaderlib/src/com/android/launcher3/icons/FastBitmapDrawable.java +25 −18 Original line number Diff line number Diff line Loading @@ -65,8 +65,7 @@ public class FastBitmapDrawable extends Drawable implements Drawable.Callback { private static boolean sFlagHoverEnabled = false; protected final Paint mPaint = new Paint(Paint.FILTER_BITMAP_FLAG | Paint.ANTI_ALIAS_FLAG); protected final Bitmap mBitmap; protected final int mIconColor; public final BitmapInfo mBitmapInfo; @Nullable private ColorFilter mColorFilter; Loading Loading @@ -99,18 +98,24 @@ public class FastBitmapDrawable extends Drawable implements Drawable.Callback { private boolean mHoverScaleEnabledForDisplay = true; protected FastBitmapDrawable(Bitmap b, int iconColor) { this(BitmapInfo.of(b, iconColor)); } public FastBitmapDrawable(Bitmap b) { this(b, Color.TRANSPARENT); this(BitmapInfo.fromBitmap(b)); } public FastBitmapDrawable(BitmapInfo info) { this(info.icon, info.color); mBitmapInfo = info; setFilterBitmap(true); } protected FastBitmapDrawable(Bitmap b, int iconColor) { mBitmap = b; mIconColor = iconColor; setFilterBitmap(true); /** * Returns true if the drawable points to the same bitmap icon object */ public boolean isSameInfo(BitmapInfo info) { return mBitmapInfo == info; } @Override Loading Loading @@ -145,7 +150,7 @@ public class FastBitmapDrawable extends Drawable implements Drawable.Callback { } protected void drawInternal(Canvas canvas, Rect bounds) { canvas.drawBitmap(mBitmap, null, bounds, mPaint); canvas.drawBitmap(mBitmapInfo.icon, null, bounds, mPaint); } /** Loading @@ -153,7 +158,7 @@ public class FastBitmapDrawable extends Drawable implements Drawable.Callback { */ public int getIconColor() { int whiteScrim = setColorAlphaBound(Color.WHITE, WHITE_SCRIM_ALPHA); return ColorUtils.compositeColors(whiteScrim, mIconColor); return ColorUtils.compositeColors(whiteScrim, mBitmapInfo.color); } /** Loading Loading @@ -220,12 +225,12 @@ public class FastBitmapDrawable extends Drawable implements Drawable.Callback { @Override public int getIntrinsicWidth() { return mBitmap.getWidth(); return mBitmapInfo.icon.getWidth(); } @Override public int getIntrinsicHeight() { return mBitmap.getHeight(); return mBitmapInfo.icon.getHeight(); } @Override Loading Loading @@ -333,7 +338,7 @@ public class FastBitmapDrawable extends Drawable implements Drawable.Callback { } protected FastBitmapConstantState newConstantState() { return new FastBitmapConstantState(mBitmap, mIconColor); return new FastBitmapConstantState(mBitmapInfo); } @Override Loading Loading @@ -423,8 +428,7 @@ public class FastBitmapDrawable extends Drawable implements Drawable.Callback { } public static class FastBitmapConstantState extends ConstantState { protected final Bitmap mBitmap; protected final int mIconColor; protected final BitmapInfo mBitmapInfo; // These are initialized later so that subclasses don't need to // pass everything in constructor Loading @@ -434,12 +438,15 @@ public class FastBitmapDrawable extends Drawable implements Drawable.Callback { @DrawableCreationFlags int mCreationFlags = 0; public FastBitmapConstantState(Bitmap bitmap, int color) { mBitmap = bitmap; mIconColor = color; this(BitmapInfo.of(bitmap, color)); } public FastBitmapConstantState(BitmapInfo info) { mBitmapInfo = info; } protected FastBitmapDrawable createDrawable() { return new FastBitmapDrawable(mBitmap, mIconColor); return new FastBitmapDrawable(mBitmapInfo); } @Override Loading
iconloaderlib/src/com/android/launcher3/icons/mono/ThemedIconDrawable.kt +5 −6 Original line number Diff line number Diff line Loading @@ -28,8 +28,7 @@ import com.android.launcher3.icons.R /** Class to handle monochrome themed app icons */ class ThemedIconDrawable(constantState: ThemedConstantState) : FastBitmapDrawable(constantState.getBitmap(), constantState.colorFg) { val bitmapInfo = constantState.bitmapInfo FastBitmapDrawable(constantState.getBitmapInfo()) { private val colorFg = constantState.colorFg private val colorBg = constantState.colorBg Loading Loading @@ -66,21 +65,21 @@ class ThemedIconDrawable(constantState: ThemedConstantState) : override fun isThemed() = true override fun newConstantState() = ThemedConstantState(bitmapInfo, monoIcon, bgBitmap, colorBg, colorFg) ThemedConstantState(mBitmapInfo, monoIcon, bgBitmap, colorBg, colorFg) override fun getIconColor() = colorFg class ThemedConstantState( val bitmapInfo: BitmapInfo, bitmapInfo: BitmapInfo, val mono: Bitmap, val whiteShadowLayer: Bitmap, val colorBg: Int, val colorFg: Int, ) : FastBitmapConstantState(bitmapInfo.icon, bitmapInfo.color) { ) : FastBitmapConstantState(bitmapInfo) { public override fun createDrawable() = ThemedIconDrawable(this) fun getBitmap(): Bitmap = mBitmap fun getBitmapInfo(): BitmapInfo = mBitmapInfo } companion object { Loading