summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/ShortcutInfo.java
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2016-07-27 17:32:34 -0700
committerSunny Goyal <sunnygoyal@google.com>2016-07-29 16:06:36 -0700
commit79cf718fcdf39d0e60743b32c6611fbb971ff38c (patch)
tree03d926be58c5615ecc66e2bc23814e9ff9ad4502 /src/com/android/launcher3/ShortcutInfo.java
parenta2454ad2d8dcffa94f670853eb464726c73597f1 (diff)
downloadandroid_packages_apps_Trebuchet-79cf718fcdf39d0e60743b32c6611fbb971ff38c.tar.gz
android_packages_apps_Trebuchet-79cf718fcdf39d0e60743b32c6611fbb971ff38c.tar.bz2
android_packages_apps_Trebuchet-79cf718fcdf39d0e60743b32c6611fbb971ff38c.zip
Badging shortcuts with app icons
Change-Id: I3fa005ece20a54b31f823acb28c384ecdf1eafb1
Diffstat (limited to 'src/com/android/launcher3/ShortcutInfo.java')
-rw-r--r--src/com/android/launcher3/ShortcutInfo.java28
1 files changed, 22 insertions, 6 deletions
diff --git a/src/com/android/launcher3/ShortcutInfo.java b/src/com/android/launcher3/ShortcutInfo.java
index 0cc5a1b92..3a1be0f33 100644
--- a/src/com/android/launcher3/ShortcutInfo.java
+++ b/src/com/android/launcher3/ShortcutInfo.java
@@ -28,7 +28,6 @@ import android.text.TextUtils;
import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.compat.LauncherActivityInfoCompat;
-import com.android.launcher3.compat.LauncherAppsCompat;
import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.compat.UserManagerCompat;
import com.android.launcher3.folder.FolderIcon;
@@ -295,16 +294,33 @@ public class ShortcutInfo extends ItemInfo {
contentDescription = UserManagerCompat.getInstance(context)
.getBadgedLabelForUser(label, user);
+ // 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. */