summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher2/LauncherModel.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/launcher2/LauncherModel.java')
-rw-r--r--src/com/android/launcher2/LauncherModel.java23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/com/android/launcher2/LauncherModel.java b/src/com/android/launcher2/LauncherModel.java
index 1e58ca0e4..179a5d5c0 100644
--- a/src/com/android/launcher2/LauncherModel.java
+++ b/src/com/android/launcher2/LauncherModel.java
@@ -1513,14 +1513,25 @@ public class LauncherModel extends BroadcastReceiver {
ShortcutInfo addShortcut(Context context, Intent data,
int screen, int cellX, int cellY, boolean notify) {
- final ShortcutInfo info = infoFromShortcutIntent(context, data);
+ final ShortcutInfo info = infoFromShortcutIntent(context, data, null);
addItemToDatabase(context, info, LauncherSettings.Favorites.CONTAINER_DESKTOP,
screen, cellX, cellY, notify);
return info;
}
- private ShortcutInfo infoFromShortcutIntent(Context context, Intent data) {
+ /**
+ * Ensures that a given shortcut intent actually has all the fields that we need to create a
+ * proper ShortcutInfo.
+ */
+ boolean validateShortcutIntent(Intent data) {
+ // We don't require Intent.EXTRA_SHORTCUT_ICON, since we can pull a default fallback icon
+ return InstallShortcutReceiver.ACTION_INSTALL_SHORTCUT.equals(data.getAction()) &&
+ (data.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT) != null) &&
+ (data.getStringExtra(Intent.EXTRA_SHORTCUT_NAME) != null);
+ }
+
+ ShortcutInfo infoFromShortcutIntent(Context context, Intent data, Bitmap fallbackIcon) {
Intent intent = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT);
String name = data.getStringExtra(Intent.EXTRA_SHORTCUT_NAME);
Parcelable bitmap = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON);
@@ -1553,8 +1564,12 @@ public class LauncherModel extends BroadcastReceiver {
final ShortcutInfo info = new ShortcutInfo();
if (icon == null) {
- icon = getFallbackIcon();
- info.usingFallbackIcon = true;
+ if (fallbackIcon != null) {
+ icon = fallbackIcon;
+ } else {
+ icon = getFallbackIcon();
+ info.usingFallbackIcon = true;
+ }
}
info.setIcon(icon);