diff options
Diffstat (limited to 'src/com/android/launcher3/LauncherAppWidgetInfo.java')
-rw-r--r-- | src/com/android/launcher3/LauncherAppWidgetInfo.java | 53 |
1 files changed, 50 insertions, 3 deletions
diff --git a/src/com/android/launcher3/LauncherAppWidgetInfo.java b/src/com/android/launcher3/LauncherAppWidgetInfo.java index 28df90fb0..5c6535a24 100644 --- a/src/com/android/launcher3/LauncherAppWidgetInfo.java +++ b/src/com/android/launcher3/LauncherAppWidgetInfo.java @@ -19,11 +19,36 @@ package com.android.launcher3; import android.appwidget.AppWidgetHostView; import android.content.ComponentName; import android.content.ContentValues; +import android.content.Context; + +import com.android.launcher3.compat.UserHandleCompat; /** * Represents a widget (either instantiated or about to be) in the Launcher. */ -class LauncherAppWidgetInfo extends ItemInfo { +public class LauncherAppWidgetInfo extends ItemInfo { + + public static final int RESTORE_COMPLETED = 0; + + /** + * This is set during the package backup creation. + */ + public static final int FLAG_ID_NOT_VALID = 1; + + /** + * Indicates that the provider is not available yet. + */ + public static final int FLAG_PROVIDER_NOT_READY = 2; + + /** + * Indicates that the widget UI is not yet ready, and user needs to set it up again. + */ + public static final int FLAG_UI_NOT_READY = 4; + + /** + * Indicates that the widget restore has started. + */ + public static final int FLAG_RESTORE_STARTED = 8; /** * Indicates that the widget hasn't been instantiated yet. @@ -42,6 +67,16 @@ class LauncherAppWidgetInfo extends ItemInfo { int minWidth = -1; int minHeight = -1; + /** + * Indicates the restore status of the widget. + */ + int restoreStatus; + + /** + * Indicates the installation progress of the widget provider + */ + int installProgress = -1; + private boolean mHasNotifiedInitialWidgetSizeChanged; /** @@ -59,13 +94,17 @@ class LauncherAppWidgetInfo extends ItemInfo { // to indicate that they should be calculated based on the layout and minWidth/minHeight spanX = -1; spanY = -1; + // We only support app widgets on current user. + user = UserHandleCompat.myUserHandle(); + restoreStatus = RESTORE_COMPLETED; } @Override - void onAddToDatabase(ContentValues values) { - super.onAddToDatabase(values); + void onAddToDatabase(Context context, ContentValues values) { + super.onAddToDatabase(context, values); values.put(LauncherSettings.Favorites.APPWIDGET_ID, appWidgetId); values.put(LauncherSettings.Favorites.APPWIDGET_PROVIDER, providerName.flattenToString()); + values.put(LauncherSettings.Favorites.RESTORED, restoreStatus); } /** @@ -96,4 +135,12 @@ class LauncherAppWidgetInfo extends ItemInfo { super.unbind(); hostView = null; } + + public final boolean isWidgetIdValid() { + return (restoreStatus & FLAG_ID_NOT_VALID) == 0; + } + + public final boolean hasRestoreFlag(int flag) { + return (restoreStatus & flag) == flag; + } } |