summaryrefslogtreecommitdiff
path: root/core/java/android/appwidget/AppWidgetManager.java
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2017-02-28 11:11:51 -0800
committerSunny Goyal <sunnygoyal@google.com>2017-03-01 16:58:21 -0800
commit4ad6b57700bef4c484021f49e018117046562e6b (patch)
treeb25a1bc734fc9faeefd6d6fc7fdfee19b64c6445 /core/java/android/appwidget/AppWidgetManager.java
parent195bbc6d5e4e01000eed1ab80a0b7c146c1062ac (diff)
Adding support for passing arbitrary extras when requesting to pin a widget.
Also defining an extra constant for widget preview which can be used by developers to provide a snapshot of the widget with the pin request Bug: 35811129 Test: All exisiting tests passing for f in 1 2 3 4 5 6 7 8 9 10; do \ adb shell am instrument -e class com.android.server.pm.ShortcutManagerTest$f \ -w com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner; \ done; adb shell am instrument -e class com.android.server.appwidget.AppWidgetServiceImplTest \ -w com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner Change-Id: Id854bd28468a5bf0416ff1a1b19c44d850016f32
Diffstat (limited to 'core/java/android/appwidget/AppWidgetManager.java')
-rw-r--r--core/java/android/appwidget/AppWidgetManager.java30
1 files changed, 26 insertions, 4 deletions
diff --git a/core/java/android/appwidget/AppWidgetManager.java b/core/java/android/appwidget/AppWidgetManager.java
index 077331e36f05..67c791df3c9a 100644
--- a/core/java/android/appwidget/AppWidgetManager.java
+++ b/core/java/android/appwidget/AppWidgetManager.java
@@ -417,6 +417,17 @@ public class AppWidgetManager {
public static final String EXTRA_APPWIDGET_OLD_IDS = "appWidgetOldIds";
/**
+ * An extra that can be passed to
+ * {@link #requestPinAppWidget(ComponentName, Bundle, PendingIntent)}. This would allow the
+ * launcher app to present a custom preview to the user.
+ *
+ * <p>
+ * The value should be a {@link RemoteViews} similar to what is used with
+ * {@link #updateAppWidget} calls.
+ */
+ public static final String EXTRA_APPWIDGET_PREVIEW = "appWidgetPreview";
+
+ /**
* Field for the manifest meta-data tag.
*
* @see AppWidgetProviderInfo
@@ -1073,7 +1084,7 @@ public class AppWidgetManager {
/**
* Return {@code TRUE} if the default launcher supports
- * {@link #requestPinAppWidget(ComponentName, PendingIntent)}
+ * {@link #requestPinAppWidget(ComponentName, Bundle, PendingIntent)}
*/
public boolean isRequestPinAppWidgetSupported() {
try {
@@ -1084,6 +1095,15 @@ public class AppWidgetManager {
}
/**
+ * Only used during development. Can be deleted before release.
+ * @hide
+ */
+ public boolean requestPinAppWidget(@NonNull ComponentName provider,
+ @Nullable PendingIntent successCallback) {
+ return requestPinAppWidget(provider, null, successCallback);
+ }
+
+ /**
* Request to pin an app widget on the current launcher. It's up to the launcher to accept this
* request (optionally showing a user confirmation). If the request is accepted, the caller will
* get a confirmation with extra {@link #EXTRA_APPWIDGET_ID}.
@@ -1099,6 +1119,8 @@ public class AppWidgetManager {
*
* @param provider The {@link ComponentName} for the {@link
* android.content.BroadcastReceiver BroadcastReceiver} provider for your AppWidget.
+ * @param extras In not null, this is passed to the launcher app. For eg {@link
+ * #EXTRA_APPWIDGET_PREVIEW} can be used for a custom preview.
* @param successCallback If not null, this intent will be sent when the widget is created.
*
* @return {@code TRUE} if the launcher supports this feature. Note the API will return without
@@ -1113,10 +1135,10 @@ public class AppWidgetManager {
* service or when the user is locked.
*/
public boolean requestPinAppWidget(@NonNull ComponentName provider,
- @Nullable PendingIntent successCallback) {
+ @Nullable Bundle extras, @Nullable PendingIntent successCallback) {
try {
- return mService.requestPinAppWidget(mPackageName, provider,
- successCallback == null ? null : successCallback.getIntentSender());
+ return mService.requestPinAppWidget(mPackageName, provider, extras,
+ successCallback == null ? null : successCallback.getIntentSender());
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}