From 5940042d39b576553c2499bcf3d0641281e6ad52 Mon Sep 17 00:00:00 2001 From: Adam Cohen Date: Wed, 5 Mar 2014 18:07:04 -0800 Subject: Supporting custom widgets provided by launcher -> This change provides integration for widgets provided by the launcher package which can run arbitrary code. Change-Id: I6052da5c4afed7ee72e3b44d045b9c46f2d84c42 --- src/com/android/launcher3/LauncherAppWidgetInfo.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/com/android/launcher3/LauncherAppWidgetInfo.java') diff --git a/src/com/android/launcher3/LauncherAppWidgetInfo.java b/src/com/android/launcher3/LauncherAppWidgetInfo.java index 5c6535a24..aad18b578 100644 --- a/src/com/android/launcher3/LauncherAppWidgetInfo.java +++ b/src/com/android/launcher3/LauncherAppWidgetInfo.java @@ -55,6 +55,11 @@ public class LauncherAppWidgetInfo extends ItemInfo { */ static final int NO_ID = -1; + /** + * Indicates that this is a locally defined widget and hence has no system allocated id. + */ + static final int CUSTOM_WIDGET_ID = -100; + /** * Identifier for this widget when talking with * {@link android.appwidget.AppWidgetManager} for updates. @@ -86,7 +91,12 @@ public class LauncherAppWidgetInfo extends ItemInfo { AppWidgetHostView hostView = null; LauncherAppWidgetInfo(int appWidgetId, ComponentName providerName) { - itemType = LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET; + if (appWidgetId == CUSTOM_WIDGET_ID) { + itemType = LauncherSettings.Favorites.ITEM_TYPE_CUSTOM_APPWIDGET; + } else { + itemType = LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET; + } + this.appWidgetId = appWidgetId; this.providerName = providerName; @@ -99,6 +109,10 @@ public class LauncherAppWidgetInfo extends ItemInfo { restoreStatus = RESTORE_COMPLETED; } + public boolean isCustomWidget() { + return appWidgetId == CUSTOM_WIDGET_ID; + } + @Override void onAddToDatabase(Context context, ContentValues values) { super.onAddToDatabase(context, values); -- cgit v1.2.3