-
- // TODO: Use cache for this
- LauncherAppState launcherAppState = LauncherAppState.getInstance(context);
- Drawable unbadgedDrawable = DeepShortcutManager.getInstance(context)
- .getShortcutIconDrawable(shortcutInfo,
- launcherAppState.getInvariantDeviceProfile().fillResIconDpi);
-
- IconCache cache = launcherAppState.getIconCache();
- Bitmap unbadgedBitmap = unbadgedDrawable == null
- ? cache.getDefaultIcon(Process.myUserHandle())
- : LauncherIcons.createScaledBitmapWithoutShadow(unbadgedDrawable, context);
- iconBitmap = getBadgedIcon(unbadgedBitmap, shortcutInfo, cache, context);
- }
-
- protected Bitmap getBadgedIcon(Bitmap unbadgedBitmap, ShortcutInfoCompat shortcutInfo,
- IconCache cache, Context context) {
- unbadgedBitmap = LauncherIcons.addShadowToIcon(unbadgedBitmap, context);
-
- final Bitmap badgeBitmap;
- ComponentName cn = shortcutInfo.getActivity();
- if (cn != null) {
- // Get the app info for the source activity.
- AppInfo appInfo = new AppInfo();
- appInfo.user = user;
- appInfo.componentName = cn;
- appInfo.intent = new Intent(Intent.ACTION_MAIN)
- .addCategory(Intent.CATEGORY_LAUNCHER)
- .setComponent(cn);
- cache.getTitleAndIcon(appInfo, false);
- badgeBitmap = appInfo.iconBitmap;
- } else {
- PackageItemInfo pkgInfo = new PackageItemInfo(shortcutInfo.getPackage());
- cache.getTitleAndIconForApp(pkgInfo, false);
- badgeBitmap = pkgInfo.iconBitmap;
- }
- return LauncherIcons.badgeWithBitmap(unbadgedBitmap, badgeBitmap, context);