diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2022-02-16 17:13:10 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2022-02-16 17:13:10 +0000 |
commit | 19fff8cb74432dcd0fe347b0c4c704cb6037bce8 (patch) | |
tree | 9c3cb876ae3b15c7c28aa3a0601c5f97629fe3bd /src | |
parent | b39ef5849369d5ba7b8d67bd0bed2911c64625b7 (diff) | |
parent | 0aa263c5a02efc4d7e989461bcecb4e5a37f318e (diff) | |
download | Launcher3-19fff8cb74432dcd0fe347b0c4c704cb6037bce8.tar.gz |
Merge "Do not theme icons when the original view is not themed."
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/launcher3/Utilities.java | 7 | ||||
-rw-r--r-- | src/com/android/launcher3/dragndrop/DragView.java | 3 | ||||
-rw-r--r-- | src/com/android/launcher3/views/FloatingIconView.java | 32 |
3 files changed, 24 insertions, 18 deletions
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java index cbc21eb352..9bc3d15da2 100644 --- a/src/com/android/launcher3/Utilities.java +++ b/src/com/android/launcher3/Utilities.java @@ -671,14 +671,15 @@ public final class Utilities { /** * Returns the full drawable for info without any flattening or pre-processing. * - * @param outObj this is set to the internal data associated with {@param info}, + * @param shouldThemeIcon If true, will theme icons when applicable + * @param outObj this is set to the internal data associated with {@code info}, * eg {@link LauncherActivityInfo} or {@link ShortcutInfo}. */ @TargetApi(Build.VERSION_CODES.TIRAMISU) public static Drawable getFullDrawable(Context context, ItemInfo info, int width, int height, - Object[] outObj) { + boolean shouldThemeIcon, Object[] outObj) { Drawable icon = loadFullDrawableWithoutTheme(context, info, width, height, outObj); - if (ATLEAST_T && icon instanceof AdaptiveIconDrawable) { + if (ATLEAST_T && icon instanceof AdaptiveIconDrawable && shouldThemeIcon) { AdaptiveIconDrawable aid = (AdaptiveIconDrawable) icon.mutate(); Drawable mono = aid.getMonochrome(); if (mono != null && Themes.isThemedIconEnabled(context)) { diff --git a/src/com/android/launcher3/dragndrop/DragView.java b/src/com/android/launcher3/dragndrop/DragView.java index 4588a04444..8bfd774918 100644 --- a/src/com/android/launcher3/dragndrop/DragView.java +++ b/src/com/android/launcher3/dragndrop/DragView.java @@ -216,7 +216,8 @@ public abstract class DragView<T extends Context & ActivityContext> extends Fram Object[] outObj = new Object[1]; int w = mWidth; int h = mHeight; - Drawable dr = Utilities.getFullDrawable(mActivity, info, w, h, outObj); + Drawable dr = Utilities.getFullDrawable(mActivity, info, w, h, + true /* shouldThemeIcon */, outObj); if (dr instanceof AdaptiveIconDrawable) { int blurMargin = (int) mActivity.getResources() diff --git a/src/com/android/launcher3/views/FloatingIconView.java b/src/com/android/launcher3/views/FloatingIconView.java index 106bb92fd8..0f69530ec0 100644 --- a/src/com/android/launcher3/views/FloatingIconView.java +++ b/src/com/android/launcher3/views/FloatingIconView.java @@ -247,11 +247,13 @@ public class FloatingIconView extends FrameLayout implements * @param originalView The View that the FloatingIconView will replace. * @param info ItemInfo of the originalView * @param pos The position of the view. + * @param btvIcon The drawable of the BubbleTextView. May be null if original view is not a BTV + * @param outIconLoadResult We store the icon results into this object. */ @WorkerThread @SuppressWarnings("WrongThread") private static void getIconResult(Launcher l, View originalView, ItemInfo info, RectF pos, - Drawable btvIcon, IconLoadResult iconLoadResult) { + @Nullable Drawable btvIcon, IconLoadResult outIconLoadResult) { Drawable drawable; boolean supportsAdaptiveIcons = !info.isDisabled(); // Use original icon for disabled icons. @@ -271,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 shouldThemeIcon = btvIcon instanceof FastBitmapDrawable + && ((FastBitmapDrawable) btvIcon).isThemed(); + drawable = getFullDrawable(l, info, width, height, shouldThemeIcon, sTmpObjArray); if (drawable instanceof AdaptiveIconDrawable) { badge = getBadge(l, info, sTmpObjArray[0]); } else { @@ -284,24 +288,25 @@ public class FloatingIconView extends FrameLayout implements // Similar to DragView, we simply use the BubbleTextView icon here. drawable = btvIcon; } else { - drawable = getFullDrawable(l, info, width, height, sTmpObjArray); + drawable = getFullDrawable(l, info, width, height, true /* shouldThemeIcon */, + sTmpObjArray); } } } drawable = drawable == null ? null : drawable.getConstantState().newDrawable(); int iconOffset = getOffsetForIconBounds(l, drawable, pos); - synchronized (iconLoadResult) { - iconLoadResult.btvDrawable = btvIcon == null || drawable == btvIcon + synchronized (outIconLoadResult) { + outIconLoadResult.btvDrawable = btvIcon == null || drawable == btvIcon ? null : btvIcon.getConstantState().newDrawable(); - iconLoadResult.drawable = drawable; - iconLoadResult.badge = badge; - iconLoadResult.iconOffset = iconOffset; - if (iconLoadResult.onIconLoaded != null) { - l.getMainExecutor().execute(iconLoadResult.onIconLoaded); - iconLoadResult.onIconLoaded = null; + outIconLoadResult.drawable = drawable; + outIconLoadResult.badge = badge; + outIconLoadResult.iconOffset = iconOffset; + if (outIconLoadResult.onIconLoaded != null) { + l.getMainExecutor().execute(outIconLoadResult.onIconLoaded); + outIconLoadResult.onIconLoaded = null; } - iconLoadResult.isIconLoaded = true; + outIconLoadResult.isIconLoaded = true; } } @@ -528,8 +533,7 @@ public class FloatingIconView extends FrameLayout implements btvIcon = null; } - IconLoadResult result = new IconLoadResult(info, - btvIcon == null ? false : btvIcon.isThemed()); + IconLoadResult result = new IconLoadResult(info, btvIcon != null && btvIcon.isThemed()); result.btvDrawable = btvIcon; final long fetchIconId = sFetchIconId++; |