Adding support to restore widgets even for jelly beans.
> Show 'widget-not-ready' until the widget app is installed
> Once the app is installed, bind a new widget id (not required on L if
id-remap was received).
**Remove the widget if bind failed
> If the widget has no configuration screen, show the widget, otherwise
show 'setup-widget'.
> Clicking 'setup-widget' shows the config screen, and updates the
widget on RESULT_OK.
issue: 10779035
Change-Id: I2f8b06d09dd6acbc498cdd93edc59c26e5ce17af
diff --git a/src/com/android/launcher3/LauncherAppWidgetHostView.java b/src/com/android/launcher3/LauncherAppWidgetHostView.java
index 7eb0052..e39727b 100644
--- a/src/com/android/launcher3/LauncherAppWidgetHostView.java
+++ b/src/com/android/launcher3/LauncherAppWidgetHostView.java
@@ -18,7 +18,6 @@
import android.appwidget.AppWidgetHostView;
import android.content.Context;
-import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
@@ -32,36 +31,22 @@
* {@inheritDoc}
*/
public class LauncherAppWidgetHostView extends AppWidgetHostView implements TouchCompleteListener {
+
+ LayoutInflater mInflater;
+
private CheckLongPressHelper mLongPressHelper;
- private LayoutInflater mInflater;
private Context mContext;
private int mPreviousOrientation;
private DragLayer mDragLayer;
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
@@ -70,22 +55,14 @@
}
@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;
super.updateAppWidget(remoteViews);
}
- public boolean orientationChangedSincedInflation() {
+ public boolean isReinflateRequired() {
+ // Re-inflate is required if the orientation has changed since last inflated.
int orientation = mContext.getResources().getConfiguration().orientation;
if (mPreviousOrientation != orientation) {
return true;