summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2017-01-13 20:37:53 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2017-01-13 20:37:53 +0000
commitbde762c61837b6f446ced065e979e472bd39fca6 (patch)
treeb23ffe3911472947ad8a5559e9425fbec835eafd
parent761d49a7a1c51de256a1b0e6181e9ad46c9347e1 (diff)
parentf745b925b4ab9ce037a31fc41277c638df4964db (diff)
downloadandroid_packages_apps_Trebuchet-bde762c61837b6f446ced065e979e472bd39fca6.tar.gz
android_packages_apps_Trebuchet-bde762c61837b6f446ced065e979e472bd39fca6.tar.bz2
android_packages_apps_Trebuchet-bde762c61837b6f446ced065e979e472bd39fca6.zip
Merge "Loading proper app icon if the associated activity is null" into ub-launcher3-master
-rw-r--r--src/com/android/launcher3/ShortcutInfo.java30
1 files changed, 21 insertions, 9 deletions
diff --git a/src/com/android/launcher3/ShortcutInfo.java b/src/com/android/launcher3/ShortcutInfo.java
index c76217d3d..976d73344 100644
--- a/src/com/android/launcher3/ShortcutInfo.java
+++ b/src/com/android/launcher3/ShortcutInfo.java
@@ -17,6 +17,7 @@
package com.android.launcher3;
import android.annotation.TargetApi;
+import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
@@ -29,6 +30,7 @@ import android.text.TextUtils;
import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.compat.UserManagerCompat;
import com.android.launcher3.graphics.LauncherIcons;
+import com.android.launcher3.model.PackageItemInfo;
import com.android.launcher3.shortcuts.DeepShortcutManager;
import com.android.launcher3.shortcuts.ShortcutInfoCompat;
import com.android.launcher3.util.ContentWriter;
@@ -240,15 +242,25 @@ public class ShortcutInfo extends ItemInfoWithIcon {
protected Bitmap getBadgedIcon(Bitmap unbadgedBitmap, ShortcutInfoCompat shortcutInfo,
IconCache cache, Context context) {
unbadgedBitmap = LauncherIcons.addShadowToIcon(unbadgedBitmap, context);
- // Get the app info for the source activity.
- AppInfo appInfo = new AppInfo();
- appInfo.user = user;
- appInfo.componentName = shortcutInfo.getActivity();
- appInfo.intent = new Intent(Intent.ACTION_MAIN)
- .addCategory(Intent.CATEGORY_LAUNCHER)
- .setComponent(shortcutInfo.getActivity());
- cache.getTitleAndIcon(appInfo, false);
- return LauncherIcons.badgeWithBitmap(unbadgedBitmap, appInfo.iconBitmap, 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);
}
/** Returns the ShortcutInfo id associated with the deep shortcut. */