summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/ShortcutInfo.java
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2016-07-29 23:14:51 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2016-07-29 23:14:51 +0000
commit66d17ca32db7114e7bff1811d3e5c6669eb49c71 (patch)
tree06cb0a8d24c999343a2d0318923c6617d765e82c /src/com/android/launcher3/ShortcutInfo.java
parentc39edf54e6bda1c5187ea61c358b6af81266c21f (diff)
parent79cf718fcdf39d0e60743b32c6611fbb971ff38c (diff)
downloadandroid_packages_apps_Trebuchet-66d17ca32db7114e7bff1811d3e5c6669eb49c71.tar.gz
android_packages_apps_Trebuchet-66d17ca32db7114e7bff1811d3e5c6669eb49c71.tar.bz2
android_packages_apps_Trebuchet-66d17ca32db7114e7bff1811d3e5c6669eb49c71.zip
Merge "Badging shortcuts with app icons" into ub-launcher3-calgary
Diffstat (limited to 'src/com/android/launcher3/ShortcutInfo.java')
-rw-r--r--src/com/android/launcher3/ShortcutInfo.java27
1 files changed, 22 insertions, 5 deletions
diff --git a/src/com/android/launcher3/ShortcutInfo.java b/src/com/android/launcher3/ShortcutInfo.java
index 00ac9bda4..d4c3c9d1d 100644
--- a/src/com/android/launcher3/ShortcutInfo.java
+++ b/src/com/android/launcher3/ShortcutInfo.java
@@ -305,16 +305,33 @@ public class ShortcutInfo extends ItemInfo {
isDisabled |= FLAG_DISABLED_BY_PUBLISHER;
}
+ // TODO: Use cache for this
LauncherAppState launcherAppState = LauncherAppState.getInstance();
- Drawable unbadgedIcon = launcherAppState.getShortcutManager()
+ Drawable unbadgedDrawable = launcherAppState.getShortcutManager()
.getShortcutIconDrawable(shortcutInfo,
launcherAppState.getInvariantDeviceProfile().fillResIconDpi);
- Bitmap icon = unbadgedIcon == null ? null : getBadgedIcon(unbadgedIcon, context);
- setIcon(icon != null ? icon : launcherAppState.getIconCache().getDefaultIcon(user));
+
+ IconCache cache = launcherAppState.getIconCache();
+ Bitmap unbadgedBitmap = unbadgedDrawable == null
+ ? cache.getDefaultIcon(UserHandleCompat.myUserHandle())
+ : Utilities.createScaledBitmapWithoutShadow(unbadgedDrawable, context);
+ setIcon(getBadgedIcon(unbadgedBitmap, shortcutInfo, cache, context));
}
- protected Bitmap getBadgedIcon(Drawable unbadgedIcon, Context context) {
- return Utilities.createBadgedIconBitmapWithShadow(unbadgedIcon, user, context);
+ protected Bitmap getBadgedIcon(Bitmap unbadgedBitmap, ShortcutInfoCompat shortcutInfo,
+ IconCache cache, Context context) {
+ unbadgedBitmap = Utilities.addShadowToIcon(unbadgedBitmap);
+ // Get the app info for the source activity.
+ AppInfo appInfo = new AppInfo();
+ appInfo.user = user;
+ appInfo.componentName = shortcutInfo.getActivity();
+ try {
+ cache.getTitleAndIcon(appInfo, shortcutInfo.getActivityInfo(context), false);
+ } catch (NullPointerException e) {
+ // This may happen when we fail to load the activity info. Worst case ignore badging.
+ return Utilities.badgeIconForUser(unbadgedBitmap, user, context);
+ }
+ return Utilities.badgeWithBitmap(unbadgedBitmap, appInfo.iconBitmap, context);
}
/** Returns the ShortcutInfo id associated with the deep shortcut. */