From cbaf1bfddd11b83f112c69f52a4966986bc10036 Mon Sep 17 00:00:00 2001 From: Suphon Thanakornpakapong Date: Mon, 16 May 2022 22:59:01 +0700 Subject: [PATCH] Use unthemed icon for drawer transition --- src/com/android/launcher3/BubbleTextView.java | 7 +++++-- src/com/android/launcher3/Utilities.java | 9 +++++++++ src/com/android/launcher3/views/FloatingIconView.java | 4 +++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java index 932b329007..1995dbb319 100644 --- a/src/com/android/launcher3/BubbleTextView.java +++ b/src/com/android/launcher3/BubbleTextView.java @@ -365,10 +365,13 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, mBubbleTextHolder = bubbleTextHolder; } + public boolean shouldUseTheme() { + return mDisplay == DISPLAY_WORKSPACE || mDisplay == DISPLAY_FOLDER || mDisplay == DISPLAY_TASKBAR; + } + @UiThread protected void applyIconAndLabel(ItemInfoWithIcon info) { - boolean useTheme = mDisplay == DISPLAY_WORKSPACE || mDisplay == DISPLAY_FOLDER - || mDisplay == DISPLAY_TASKBAR; + boolean useTheme = shouldUseTheme(); FastBitmapDrawable iconDrawable = info.newIcon(getContext(), useTheme); mDotParams.color = IconPalette.getMutedColor(iconDrawable.getIconColor(), 0.54f); diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java index 5b747f5dd8..b276446703 100644 --- a/src/com/android/launcher3/Utilities.java +++ b/src/com/android/launcher3/Utilities.java @@ -702,6 +702,15 @@ public final class Utilities { return icon; } + public static Drawable getFullDrawable(Context context, ItemInfo info, int width, int height, + Object[] outObj, boolean useTheme) { + Drawable icon = loadFullDrawableWithoutTheme(context, info, width, height, outObj); + if (useTheme && icon instanceof BitmapInfo.Extender) { + icon = ((BitmapInfo.Extender) icon).getThemedDrawable(context); + } + return icon; + } + public static Drawable loadFullDrawableWithoutTheme(Context context, ItemInfo info, int width, int height, Object[] outObj) { ActivityContext activity = ActivityContext.lookupContext(context); diff --git a/src/com/android/launcher3/views/FloatingIconView.java b/src/com/android/launcher3/views/FloatingIconView.java index dc3ee43548..acbf279f3f 100644 --- a/src/com/android/launcher3/views/FloatingIconView.java +++ b/src/com/android/launcher3/views/FloatingIconView.java @@ -273,7 +273,9 @@ public class FloatingIconView extends FrameLayout implements int width = (int) pos.width(); int height = (int) pos.height(); if (supportsAdaptiveIcons) { - drawable = getFullDrawable(l, info, width, height, sTmpObjArray); + boolean useTheme = originalView instanceof BubbleTextView + && ((BubbleTextView) originalView).shouldUseTheme(); + drawable = getFullDrawable(l, info, width, height, sTmpObjArray, useTheme); if (drawable instanceof AdaptiveIconDrawable) { badge = getBadge(l, info, sTmpObjArray[0]); } else {