Bug 760708 - Add ability to remove homescreen shortcuts. r=mfinkle

This commit is contained in:
Wes Johnston
2012-06-06 13:52:14 -07:00
parent 010be15ca0
commit 1caa19dc38
4 changed files with 41 additions and 4 deletions

View File

@@ -808,6 +808,35 @@ public class GeckoAppShell
});
}
public static void removeShortcut(final String aTitle, final String aURI, final String aType) {
getHandler().post(new Runnable() {
public void run() {
Log.w(LOGTAG, "removeShortcut for " + aURI + " [" + aTitle + "] > " + aType);
// the intent to be launched by the shortcut
Intent shortcutIntent = new Intent();
if (aType.equalsIgnoreCase(SHORTCUT_TYPE_WEBAPP)) {
shortcutIntent.setAction(GeckoApp.ACTION_WEBAPP);
} else {
shortcutIntent.setAction(GeckoApp.ACTION_BOOKMARK);
}
shortcutIntent.setData(Uri.parse(aURI));
shortcutIntent.setClassName(GeckoApp.mAppContext,
GeckoApp.mAppContext.getPackageName() + ".App");
Intent intent = new Intent();
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
if (aTitle != null)
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, aTitle);
else
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, aURI);
intent.setAction("com.android.launcher.action.UNINSTALL_SHORTCUT");
GeckoApp.mAppContext.sendBroadcast(intent);
}
});
}
static private Bitmap getLauncherIcon(Bitmap aSource, String aType) {
final int kOffset = 6;
final int kRadius = 5;