diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2014-06-30 14:15:31 -0700 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2014-07-21 10:34:21 -0700 |
commit | 651077bdd603bb182be039925fd17bdf0da15016 (patch) | |
tree | a8707757fd1c77ecf0de554dab61090a72e7cbb8 /src/com/android/launcher3/LauncherAppWidgetHostView.java | |
parent | 82cc3fe6c77322d93ff74b25354e4bca77ab4a83 (diff) | |
download | android_packages_apps_Trebuchet-651077bdd603bb182be039925fd17bdf0da15016.tar.gz android_packages_apps_Trebuchet-651077bdd603bb182be039925fd17bdf0da15016.tar.bz2 android_packages_apps_Trebuchet-651077bdd603bb182be039925fd17bdf0da15016.zip |
Adding app widget restore support in Launcher3 for android L
When the app is restored, it displays placeholders for all pending widgets.
These placeholders can be moved and removed similar to a widget (size is fixed
to what defined in backup). Once the system notifies the launcher of the new
widget ids, the place holders are replaced with actual widgets.
issue: 10779035
Change-Id: I68cbe4da01e9ca2978cb4471a7c645d2aa592055
Diffstat (limited to 'src/com/android/launcher3/LauncherAppWidgetHostView.java')
-rw-r--r-- | src/com/android/launcher3/LauncherAppWidgetHostView.java | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/com/android/launcher3/LauncherAppWidgetHostView.java b/src/com/android/launcher3/LauncherAppWidgetHostView.java index f47fd13ec..7eb005255 100644 --- a/src/com/android/launcher3/LauncherAppWidgetHostView.java +++ b/src/com/android/launcher3/LauncherAppWidgetHostView.java @@ -18,6 +18,7 @@ package com.android.launcher3; import android.appwidget.AppWidgetHostView; import android.content.Context; +import android.os.Bundle; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; @@ -39,12 +40,28 @@ public class LauncherAppWidgetHostView extends AppWidgetHostView implements Touc private float mSlop; + private boolean mWidgetReady; + public LauncherAppWidgetHostView(Context context) { + this(context, true); + } + + public LauncherAppWidgetHostView(Context context, boolean widgetReady) { super(context); mContext = context; mLongPressHelper = new CheckLongPressHelper(this); mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); mDragLayer = ((Launcher) context).getDragLayer(); + mWidgetReady = widgetReady; + } + + @Override + public void updateAppWidgetSize(Bundle newOptions, int minWidth, int minHeight, int maxWidth, + int maxHeight) { + // If the widget is not yet ready, the app widget size cannot be updated. + if (mWidgetReady) { + super.updateAppWidgetSize(newOptions, minWidth, minHeight, maxWidth, maxHeight); + } } @Override @@ -53,6 +70,15 @@ public class LauncherAppWidgetHostView extends AppWidgetHostView implements Touc } @Override + protected View getDefaultView() { + if (mWidgetReady) { + return super.getDefaultView(); + } else { + return mInflater.inflate(R.layout.appwidget_not_ready, this, false); + } + } + + @Override public void updateAppWidget(RemoteViews remoteViews) { // Store the orientation in which the widget was inflated mPreviousOrientation = mContext.getResources().getConfiguration().orientation; |