Fix for widgets with config not getting size info (issue 7266053)

Change-Id: I0b55555ed38d4f2a70345d1b6316a075a9346111
This commit is contained in:
Adam Cohen
2012-10-04 16:53:44 -07:00
parent a2042d0ae9
commit dd70d66852
3 changed files with 19 additions and 3 deletions
@@ -628,7 +628,10 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
private void preloadWidget(final PendingAddWidgetInfo info) {
final AppWidgetProviderInfo pInfo = info.info;
final Bundle options = getDefaultOptionsForWidget(mLauncher, info);
if (pInfo.configure != null) {
info.bindOptions = options;
return;
}
@@ -637,8 +640,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
@Override
public void run() {
mWidgetLoadingId = mLauncher.getAppWidgetHost().allocateAppWidgetId();
Bundle options = getDefaultOptionsForWidget(mLauncher, info);
// Options will be null for platforms with JB or lower, so this serves as an
// SDK level check.
if (options == null) {
+13 -1
View File
@@ -1746,13 +1746,25 @@ public final class Launcher extends Activity
// In this case, we either need to start an activity to get permission to bind
// the widget, or we need to start an activity to configure the widget, or both.
appWidgetId = getAppWidgetHost().allocateAppWidgetId();
if (mAppWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId, info.componentName)) {
Bundle options = info.bindOptions;
boolean success = false;
if (options != null) {
success = mAppWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId,
info.componentName, options);
} else {
success = mAppWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId,
info.componentName);
}
if (success) {
addAppWidgetImpl(appWidgetId, info, null, info.info);
} else {
mPendingAddWidgetInfo = info.info;
Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_BIND);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_PROVIDER, info.componentName);
// TODO: we need to make sure that this accounts for the options bundle.
// intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_OPTIONS, options);
startActivityForResult(intent, REQUEST_BIND_APPWIDGET);
}
}
@@ -20,6 +20,7 @@ import android.appwidget.AppWidgetHostView;
import android.appwidget.AppWidgetProviderInfo;
import android.content.ComponentName;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.os.Parcelable;
/**
@@ -55,6 +56,7 @@ class PendingAddWidgetInfo extends PendingAddItemInfo {
int icon;
AppWidgetProviderInfo info;
AppWidgetHostView boundWidget;
Bundle bindOptions = null;
// Any configuration data that we want to pass to a configuration activity when
// starting up a widget
@@ -95,6 +97,7 @@ class PendingAddWidgetInfo extends PendingAddItemInfo {
spanY = copy.spanY;
minSpanX = copy.minSpanX;
minSpanY = copy.minSpanY;
bindOptions = copy.bindOptions == null ? null : (Bundle) copy.bindOptions.clone();
}
@Override