Skip to content

Commit dfed49a

Browse files
Adam CohenAndroid (Google) Code Review
authored andcommitted
Merge "Changing app widget "extras" to "options" and another small API Review issue" into jb-dev
2 parents e318c9a + d2097eb commit dfed49a

File tree

7 files changed

+63
-62
lines changed

7 files changed

+63
-62
lines changed

api/current.txt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4317,15 +4317,15 @@ package android.appwidget {
43174317
method protected void prepareView(android.view.View);
43184318
method public void setAppWidget(int, android.appwidget.AppWidgetProviderInfo);
43194319
method public void updateAppWidget(android.widget.RemoteViews);
4320-
method public void updateAppWidgetExtras(android.os.Bundle);
4320+
method public void updateAppWidgetOptions(android.os.Bundle);
43214321
method public void updateAppWidgetSize(android.os.Bundle, int, int, int, int);
43224322
}
43234323

43244324
public class AppWidgetManager {
43254325
method public boolean bindAppWidgetIdIfAllowed(int, android.content.ComponentName);
4326-
method public android.os.Bundle getAppWidgetExtras(int);
43274326
method public int[] getAppWidgetIds(android.content.ComponentName);
43284327
method public android.appwidget.AppWidgetProviderInfo getAppWidgetInfo(int);
4328+
method public android.os.Bundle getAppWidgetOptions(int);
43294329
method public java.util.List<android.appwidget.AppWidgetProviderInfo> getInstalledProviders();
43304330
method public static android.appwidget.AppWidgetManager getInstance(android.content.Context);
43314331
method public void notifyAppWidgetViewDataChanged(int[], int);
@@ -4335,32 +4335,32 @@ package android.appwidget {
43354335
method public void updateAppWidget(int[], android.widget.RemoteViews);
43364336
method public void updateAppWidget(int, android.widget.RemoteViews);
43374337
method public void updateAppWidget(android.content.ComponentName, android.widget.RemoteViews);
4338-
method public void updateAppWidgetExtras(int, android.os.Bundle);
4338+
method public void updateAppWidgetOptions(int, android.os.Bundle);
43394339
field public static final java.lang.String ACTION_APPWIDGET_BIND = "android.appwidget.action.APPWIDGET_BIND";
43404340
field public static final java.lang.String ACTION_APPWIDGET_CONFIGURE = "android.appwidget.action.APPWIDGET_CONFIGURE";
43414341
field public static final java.lang.String ACTION_APPWIDGET_DELETED = "android.appwidget.action.APPWIDGET_DELETED";
43424342
field public static final java.lang.String ACTION_APPWIDGET_DISABLED = "android.appwidget.action.APPWIDGET_DISABLED";
43434343
field public static final java.lang.String ACTION_APPWIDGET_ENABLED = "android.appwidget.action.APPWIDGET_ENABLED";
4344-
field public static final java.lang.String ACTION_APPWIDGET_EXTRAS_CHANGED = "android.appwidget.action.APPWIDGET_UPDATE_EXTRAS";
4344+
field public static final java.lang.String ACTION_APPWIDGET_OPTIONS_CHANGED = "android.appwidget.action.APPWIDGET_UPDATE_OPTIONS";
43454345
field public static final java.lang.String ACTION_APPWIDGET_PICK = "android.appwidget.action.APPWIDGET_PICK";
43464346
field public static final java.lang.String ACTION_APPWIDGET_UPDATE = "android.appwidget.action.APPWIDGET_UPDATE";
4347-
field public static final java.lang.String EXTRA_APPWIDGET_EXTRAS = "appWidgetExtras";
43484347
field public static final java.lang.String EXTRA_APPWIDGET_ID = "appWidgetId";
43494348
field public static final java.lang.String EXTRA_APPWIDGET_IDS = "appWidgetIds";
4350-
field public static final java.lang.String EXTRA_APPWIDGET_MAX_HEIGHT = "appWidgetMaxHeight";
4351-
field public static final java.lang.String EXTRA_APPWIDGET_MAX_WIDTH = "appWidgetMaxWidth";
4352-
field public static final java.lang.String EXTRA_APPWIDGET_MIN_HEIGHT = "appWidgetMinHeight";
4353-
field public static final java.lang.String EXTRA_APPWIDGET_MIN_WIDTH = "appWidgetMinWidth";
4349+
field public static final java.lang.String EXTRA_APPWIDGET_OPTIONS = "appWidgetOptions";
43544350
field public static final java.lang.String EXTRA_APPWIDGET_PROVIDER = "appWidgetProvider";
43554351
field public static final java.lang.String EXTRA_CUSTOM_EXTRAS = "customExtras";
43564352
field public static final java.lang.String EXTRA_CUSTOM_INFO = "customInfo";
43574353
field public static final int INVALID_APPWIDGET_ID = 0; // 0x0
43584354
field public static final java.lang.String META_DATA_APPWIDGET_PROVIDER = "android.appwidget.provider";
4355+
field public static final java.lang.String OPTION_APPWIDGET_MAX_HEIGHT = "appWidgetMaxHeight";
4356+
field public static final java.lang.String OPTION_APPWIDGET_MAX_WIDTH = "appWidgetMaxWidth";
4357+
field public static final java.lang.String OPTION_APPWIDGET_MIN_HEIGHT = "appWidgetMinHeight";
4358+
field public static final java.lang.String OPTION_APPWIDGET_MIN_WIDTH = "appWidgetMinWidth";
43594359
}
43604360

43614361
public class AppWidgetProvider extends android.content.BroadcastReceiver {
43624362
ctor public AppWidgetProvider();
4363-
method public void onAppWidgetExtrasChanged(android.content.Context, android.appwidget.AppWidgetManager, int, android.os.Bundle);
4363+
method public void onAppWidgetOptionsChanged(android.content.Context, android.appwidget.AppWidgetManager, int, android.os.Bundle);
43644364
method public void onDeleted(android.content.Context, int[]);
43654365
method public void onDisabled(android.content.Context);
43664366
method public void onEnabled(android.content.Context);

core/java/android/appwidget/AppWidgetHostView.java

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -210,36 +210,37 @@ protected void dispatchRestoreInstanceState(SparseArray<Parcelable> container) {
210210
/**
211211
* Provide guidance about the size of this widget to the AppWidgetManager. This information
212212
* gets embedded into the AppWidgetExtras and causes a callback to the AppWidgetProvider.
213-
* @see AppWidgetProvider#onAppWidgetExtrasChanged(Context, AppWidgetManager, int, Bundle)
213+
* @see AppWidgetProvider#onAppWidgetOptionsChanged(Context, AppWidgetManager, int, Bundle)
214214
*
215-
* @param extras The bundle of extra information, in addition to the size information
215+
* @param options The bundle of options, in addition to the size information,
216216
* can be null.
217217
* @param minWidth The minimum width that the widget will be displayed at.
218218
* @param minHeight The maximum height that the widget will be displayed at.
219-
* @param maxWidth The maximum height that the widget will be displayed at.
219+
* @param maxWidth The maximum width that the widget will be displayed at.
220+
* @param maxHeight The maximum height that the widget will be displayed at.
220221
*
221222
*/
222-
public void updateAppWidgetSize(Bundle extras, int minWidth, int minHeight, int maxWidth,
223+
public void updateAppWidgetSize(Bundle options, int minWidth, int minHeight, int maxWidth,
223224
int maxHeight) {
224-
if (extras == null) {
225-
extras = new Bundle();
225+
if (options == null) {
226+
options = new Bundle();
226227
}
227-
extras.putInt(AppWidgetManager.EXTRA_APPWIDGET_MIN_WIDTH, minWidth);
228-
extras.putInt(AppWidgetManager.EXTRA_APPWIDGET_MIN_HEIGHT, minHeight);
229-
extras.putInt(AppWidgetManager.EXTRA_APPWIDGET_MAX_WIDTH, maxWidth);
230-
extras.putInt(AppWidgetManager.EXTRA_APPWIDGET_MAX_HEIGHT, maxHeight);
231-
updateAppWidgetExtras(extras);
228+
options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH, minWidth);
229+
options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT, minHeight);
230+
options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH, maxWidth);
231+
options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT, maxHeight);
232+
updateAppWidgetOptions(options);
232233
}
233234

234235
/**
235236
* Specify some extra information for the widget provider. Causes a callback to the
236237
* AppWidgetProvider.
237-
* @see AppWidgetProvider#onAppWidgetExtrasChanged(Context, AppWidgetManager, int, Bundle)
238+
* @see AppWidgetProvider#onAppWidgetOptionsChanged(Context, AppWidgetManager, int, Bundle)
238239
*
239-
* @param extras The bundle of extra information.
240+
* @param options The bundle of options information.
240241
*/
241-
public void updateAppWidgetExtras(Bundle extras) {
242-
AppWidgetManager.getInstance(mContext).updateAppWidgetExtras(mAppWidgetId, extras);
242+
public void updateAppWidgetOptions(Bundle options) {
243+
AppWidgetManager.getInstance(mContext).updateAppWidgetOptions(mAppWidgetId, options);
243244
}
244245

245246
/** {@inheritDoc} */

core/java/android/appwidget/AppWidgetManager.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -152,28 +152,28 @@ public class AppWidgetManager {
152152
/**
153153
* An bundle extra that contains the lower bound on the current width, in dips, of a widget instance.
154154
*/
155-
public static final String EXTRA_APPWIDGET_MIN_WIDTH = "appWidgetMinWidth";
155+
public static final String OPTION_APPWIDGET_MIN_WIDTH = "appWidgetMinWidth";
156156

157157
/**
158158
* An bundle extra that contains the lower bound on the current height, in dips, of a widget instance.
159159
*/
160-
public static final String EXTRA_APPWIDGET_MIN_HEIGHT = "appWidgetMinHeight";
160+
public static final String OPTION_APPWIDGET_MIN_HEIGHT = "appWidgetMinHeight";
161161

162162
/**
163163
* An bundle extra that contains the upper bound on the current width, in dips, of a widget instance.
164164
*/
165-
public static final String EXTRA_APPWIDGET_MAX_WIDTH = "appWidgetMaxWidth";
165+
public static final String OPTION_APPWIDGET_MAX_WIDTH = "appWidgetMaxWidth";
166166

167167
/**
168168
* An bundle extra that contains the upper bound on the current width, in dips, of a widget instance.
169169
*/
170-
public static final String EXTRA_APPWIDGET_MAX_HEIGHT = "appWidgetMaxHeight";
170+
public static final String OPTION_APPWIDGET_MAX_HEIGHT = "appWidgetMaxHeight";
171171

172172
/**
173173
* An intent extra which points to a bundle of extra information for a particular widget id.
174174
* In particular this bundle can contain EXTRA_APPWIDGET_WIDTH and EXTRA_APPWIDGET_HEIGHT.
175175
*/
176-
public static final String EXTRA_APPWIDGET_EXTRAS = "appWidgetExtras";
176+
public static final String EXTRA_APPWIDGET_OPTIONS = "appWidgetOptions";
177177

178178
/**
179179
* An intent extra that contains multiple appWidgetIds.
@@ -240,7 +240,7 @@ public class AppWidgetManager {
240240
* @see AppWidgetProvider#onAppWidgetExtrasChanged AppWidgetProvider#onAppWidgetExtrasChanged(
241241
* Context context, AppWidgetManager appWidgetManager, int appWidgetId, Bundle newExtras)
242242
*/
243-
public static final String ACTION_APPWIDGET_EXTRAS_CHANGED = "android.appwidget.action.APPWIDGET_UPDATE_EXTRAS";
243+
public static final String ACTION_APPWIDGET_OPTIONS_CHANGED = "android.appwidget.action.APPWIDGET_UPDATE_OPTIONS";
244244

245245
/**
246246
* Sent when an instance of an AppWidget is deleted from its host.
@@ -339,14 +339,14 @@ public void updateAppWidget(int[] appWidgetIds, RemoteViews views) {
339339
* The extras can be used to embed additional information about this widget to be accessed
340340
* by the associated widget's AppWidgetProvider.
341341
*
342-
* @see #getAppWidgetExtras(int)
342+
* @see #getAppWidgetOptions(int)
343343
*
344344
* @param appWidgetId The AppWidget instances for which to set the RemoteViews.
345-
* @param extras The extras to associate with this widget
345+
* @param options The options to associate with this widget
346346
*/
347-
public void updateAppWidgetExtras(int appWidgetId, Bundle extras) {
347+
public void updateAppWidgetOptions(int appWidgetId, Bundle options) {
348348
try {
349-
sService.updateAppWidgetExtras(appWidgetId, extras);
349+
sService.updateAppWidgetOptions(appWidgetId, options);
350350
}
351351
catch (RemoteException e) {
352352
throw new RuntimeException("system server dead?", e);
@@ -359,14 +359,14 @@ public void updateAppWidgetExtras(int appWidgetId, Bundle extras) {
359359
* The extras can be used to embed additional information about this widget to be accessed
360360
* by the associated widget's AppWidgetProvider.
361361
*
362-
* @see #updateAppWidgetExtras(int, Bundle)
362+
* @see #updateAppWidgetOptions(int, Bundle)
363363
*
364364
* @param appWidgetId The AppWidget instances for which to set the RemoteViews.
365-
* @return The extras associated with the given widget instance.
365+
* @return The options associated with the given widget instance.
366366
*/
367-
public Bundle getAppWidgetExtras(int appWidgetId) {
367+
public Bundle getAppWidgetOptions(int appWidgetId) {
368368
try {
369-
return sService.getAppWidgetExtras(appWidgetId);
369+
return sService.getAppWidgetOptions(appWidgetId);
370370
}
371371
catch (RemoteException e) {
372372
throw new RuntimeException("system server dead?", e);

core/java/android/appwidget/AppWidgetProvider.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,13 @@ else if (AppWidgetManager.ACTION_APPWIDGET_DELETED.equals(action)) {
7474
this.onDeleted(context, new int[] { appWidgetId });
7575
}
7676
}
77-
else if (AppWidgetManager.ACTION_APPWIDGET_EXTRAS_CHANGED.equals(action)) {
77+
else if (AppWidgetManager.ACTION_APPWIDGET_OPTIONS_CHANGED.equals(action)) {
7878
Bundle extras = intent.getExtras();
7979
if (extras != null && extras.containsKey(AppWidgetManager.EXTRA_APPWIDGET_ID)
80-
&& extras.containsKey(AppWidgetManager.EXTRA_APPWIDGET_EXTRAS)) {
80+
&& extras.containsKey(AppWidgetManager.EXTRA_APPWIDGET_OPTIONS)) {
8181
int appWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID);
82-
Bundle widgetExtras = extras.getBundle(AppWidgetManager.EXTRA_APPWIDGET_EXTRAS);
83-
this.onAppWidgetExtrasChanged(context, AppWidgetManager.getInstance(context),
82+
Bundle widgetExtras = extras.getBundle(AppWidgetManager.EXTRA_APPWIDGET_OPTIONS);
83+
this.onAppWidgetOptionsChanged(context, AppWidgetManager.getInstance(context),
8484
appWidgetId, widgetExtras);
8585
}
8686
}
@@ -114,7 +114,7 @@ public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] a
114114
}
115115

116116
/**
117-
* Called in response to the {@link AppWidgetManager#ACTION_APPWIDGET_EXTRAS_CHANGED}
117+
* Called in response to the {@link AppWidgetManager#ACTION_APPWIDGET_OPTIONS_CHANGED}
118118
* broadcast when this widget has been layed out at a new size.
119119
*
120120
* {@more}
@@ -124,12 +124,12 @@ public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] a
124124
* @param appWidgetManager A {@link AppWidgetManager} object you can call {@link
125125
* AppWidgetManager#updateAppWidget} on.
126126
* @param appWidgetId The appWidgetId of the widget who's size changed.
127-
* @param newExtras The appWidgetId of the widget who's size changed.
127+
* @param newOptions The appWidgetId of the widget who's size changed.
128128
*
129-
* @see AppWidgetManager#ACTION_APPWIDGET_EXTRAS_CHANGED
129+
* @see AppWidgetManager#ACTION_APPWIDGET_OPTIONS_CHANGED
130130
*/
131-
public void onAppWidgetExtrasChanged(Context context, AppWidgetManager appWidgetManager,
132-
int appWidgetId, Bundle newExtras) {
131+
public void onAppWidgetOptionsChanged(Context context, AppWidgetManager appWidgetManager,
132+
int appWidgetId, Bundle newOptions) {
133133
}
134134

135135
/**

core/java/com/android/internal/appwidget/IAppWidgetService.aidl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ interface IAppWidgetService {
4343
// for AppWidgetManager
4444
//
4545
void updateAppWidgetIds(in int[] appWidgetIds, in RemoteViews views);
46-
void updateAppWidgetExtras(int appWidgetId, in Bundle extras);
47-
Bundle getAppWidgetExtras(int appWidgetId);
46+
void updateAppWidgetOptions(int appWidgetId, in Bundle extras);
47+
Bundle getAppWidgetOptions(int appWidgetId);
4848
void partiallyUpdateAppWidgetIds(in int[] appWidgetIds, in RemoteViews views);
4949
void updateAppWidgetProvider(in ComponentName provider, in RemoteViews views);
5050
void notifyAppWidgetViewDataChanged(in int[] appWidgetIds, int viewId);

services/java/com/android/server/AppWidgetService.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,13 +279,13 @@ public RemoteViews getAppWidgetViews(int appWidgetId) throws RemoteException {
279279
}
280280

281281
@Override
282-
public void updateAppWidgetExtras(int appWidgetId, Bundle extras) {
283-
getImplForUser().updateAppWidgetExtras(appWidgetId, extras);
282+
public void updateAppWidgetOptions(int appWidgetId, Bundle options) {
283+
getImplForUser().updateAppWidgetOptions(appWidgetId, options);
284284
}
285285

286286
@Override
287-
public Bundle getAppWidgetExtras(int appWidgetId) {
288-
return getImplForUser().getAppWidgetExtras(appWidgetId);
287+
public Bundle getAppWidgetOptions(int appWidgetId) {
288+
return getImplForUser().getAppWidgetOptions(appWidgetId);
289289
}
290290

291291
static int[] getAppWidgetIds(Provider p) {

services/java/com/android/server/AppWidgetServiceImpl.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ static class AppWidgetId {
112112
int appWidgetId;
113113
Provider provider;
114114
RemoteViews views;
115-
Bundle extras;
115+
Bundle options;
116116
Host host;
117117
}
118118

@@ -820,7 +820,7 @@ public void updateAppWidgetIds(int[] appWidgetIds, RemoteViews views) {
820820
}
821821
}
822822

823-
public void updateAppWidgetExtras(int appWidgetId, Bundle extras) {
823+
public void updateAppWidgetOptions(int appWidgetId, Bundle options) {
824824
synchronized (mAppWidgetIds) {
825825
ensureStateLoadedLocked();
826826
AppWidgetId id = lookupAppWidgetIdLocked(appWidgetId);
@@ -829,23 +829,23 @@ public void updateAppWidgetExtras(int appWidgetId, Bundle extras) {
829829
return;
830830
}
831831
Provider p = id.provider;
832-
id.extras = extras;
832+
id.options = options;
833833

834834
// send the broacast saying that this appWidgetId has been deleted
835-
Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_EXTRAS_CHANGED);
835+
Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_OPTIONS_CHANGED);
836836
intent.setComponent(p.info.provider);
837837
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, id.appWidgetId);
838-
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_EXTRAS, extras);
838+
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_OPTIONS, options);
839839
mContext.sendBroadcast(intent, mUserId);
840840
}
841841
}
842842

843-
public Bundle getAppWidgetExtras(int appWidgetId) {
843+
public Bundle getAppWidgetOptions(int appWidgetId) {
844844
synchronized (mAppWidgetIds) {
845845
ensureStateLoadedLocked();
846846
AppWidgetId id = lookupAppWidgetIdLocked(appWidgetId);
847-
if (id != null && id.extras != null) {
848-
return id.extras;
847+
if (id != null && id.options != null) {
848+
return id.options;
849849
} else {
850850
return Bundle.EMPTY;
851851
}

0 commit comments

Comments
 (0)