From 097efdc8ac879da86efb419db8f321017c77345c Mon Sep 17 00:00:00 2001 From: Sihua Ma Date: Tue, 18 Feb 2025 08:47:18 +0000 Subject: [PATCH] Exclude dynamic shortcuts from being force themed Test: Manual Bug: 397501448 Flag: com.android.launcher3.force_monochrome_app_icons Change-Id: Iff1010e268c99ce192e1445ec124229c84420b23 --- .../android/launcher3/uioverrides/SystemApiWrapper.kt | 5 ++++- .../android/launcher3/icons/CacheableShortcutInfo.kt | 11 ++++++++++- src/com/android/launcher3/util/ApiWrapper.java | 7 +++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/quickstep/src/com/android/launcher3/uioverrides/SystemApiWrapper.kt b/quickstep/src/com/android/launcher3/uioverrides/SystemApiWrapper.kt index 6e901ee6d1..1f34969a49 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/SystemApiWrapper.kt +++ b/quickstep/src/com/android/launcher3/uioverrides/SystemApiWrapper.kt @@ -144,7 +144,7 @@ open class SystemApiWrapper @Inject constructor(@ApplicationContext context: Con override fun isNonResizeableActivity(lai: LauncherActivityInfo) = lai.activityInfo.resizeMode == ActivityInfo.RESIZE_MODE_UNRESIZEABLE - override fun supportsMultiInstance(lai: LauncherActivityInfo) : Boolean { + override fun supportsMultiInstance(lai: LauncherActivityInfo): Boolean { return try { super.supportsMultiInstance(lai) || lai.supportsMultiInstance() } catch (e: Exception) { @@ -202,4 +202,7 @@ open class SystemApiWrapper @Inject constructor(@ApplicationContext context: Con (appInfo.sourceDir?.hashCode() ?: 0).toString() + " " + appInfo.longVersionCode override fun getRoundIconRes(appInfo: ApplicationInfo) = appInfo.roundIconRes + + override fun isFileDrawable(shortcutInfo: ShortcutInfo) = + shortcutInfo.hasIconFile() || shortcutInfo.hasIconUri() } diff --git a/src/com/android/launcher3/icons/CacheableShortcutInfo.kt b/src/com/android/launcher3/icons/CacheableShortcutInfo.kt index 225e12f47a..50dd146ca6 100644 --- a/src/com/android/launcher3/icons/CacheableShortcutInfo.kt +++ b/src/com/android/launcher3/icons/CacheableShortcutInfo.kt @@ -30,6 +30,7 @@ import com.android.launcher3.icons.BaseIconFactory.IconOptions import com.android.launcher3.icons.cache.BaseIconCache import com.android.launcher3.icons.cache.CachingLogic import com.android.launcher3.shortcuts.ShortcutKey +import com.android.launcher3.util.ApiWrapper import com.android.launcher3.util.ApplicationInfoWrapper import com.android.launcher3.util.PackageUserKey import com.android.launcher3.util.Themes @@ -114,7 +115,15 @@ object CacheableShortcutCachingLogic : CachingLogic { d, IconOptions() .setExtractedColor(Themes.getColorAccent(context)) - .setSourceHint(getSourceHint(info, cache)), + .setSourceHint( + getSourceHint(info, cache) + .copy( + isFileDrawable = + ApiWrapper.INSTANCE[context].isFileDrawable( + info.shortcutInfo + ) + ) + ), ) } ?: BitmapInfo.LOW_RES_INFO } diff --git a/src/com/android/launcher3/util/ApiWrapper.java b/src/com/android/launcher3/util/ApiWrapper.java index 56337b08e1..0510d591e4 100644 --- a/src/com/android/launcher3/util/ApiWrapper.java +++ b/src/com/android/launcher3/util/ApiWrapper.java @@ -216,6 +216,13 @@ public class ApiWrapper { return 0; } + /** + * Checks if the shortcut is using an icon with file or URI source + */ + public boolean isFileDrawable(@NonNull ShortcutInfo shortcutInfo) { + return false; + } + private static class NoopDrawable extends ColorDrawable { @Override public int getIntrinsicHeight() {