From ff572277112ec3d6a6a8c1be274d6fa1019e3648 Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Wed, 23 Jul 2014 13:58:07 -0700 Subject: 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 --- .../launcher3/LauncherAppWidgetHostView.java | 33 ++++------------------ 1 file changed, 5 insertions(+), 28 deletions(-) (limited to 'src/com/android/launcher3/LauncherAppWidgetHostView.java') diff --git a/src/com/android/launcher3/LauncherAppWidgetHostView.java b/src/com/android/launcher3/LauncherAppWidgetHostView.java index 7eb005255..e39727b17 100644 --- a/src/com/android/launcher3/LauncherAppWidgetHostView.java +++ b/src/com/android/launcher3/LauncherAppWidgetHostView.java @@ -18,7 +18,6 @@ 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; @@ -32,36 +31,22 @@ import com.android.launcher3.DragLayer.TouchCompleteListener; * {@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 @@ -69,15 +54,6 @@ public class LauncherAppWidgetHostView extends AppWidgetHostView implements Touc return mInflater.inflate(R.layout.appwidget_error, this, false); } - @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 @@ -85,7 +61,8 @@ public class LauncherAppWidgetHostView extends AppWidgetHostView implements Touc 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; -- cgit v1.2.3