Initial changes to allow dragging external shortcuts to launcher using the same InstallShortcut intent.

Change-Id: I21b57115429ed37d604084ae01308d1d3f33ee7e
This commit is contained in:
Winson Chung committed 2010-10-27 18:35:04 -07:00
1 parent 625a647bad
commit a9abd0e0bd
6 files changed
+168 -22

No files matched your search

+19 -4
View File
@@ -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);