diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2017-03-08 14:49:55 -0800 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2017-03-17 11:25:29 -0700 |
commit | c65a0085d77edd8e8821254f081eb94e9dcc5e75 (patch) | |
tree | 9b5828af69bd8c6fb34d47e121202cfe86123b8f /tests/src/com/android/launcher3/testcomponent | |
parent | efd5cbf55c45185230d56799e67b31e96d8d7029 (diff) | |
download | android_packages_apps_Trebuchet-c65a0085d77edd8e8821254f081eb94e9dcc5e75.tar.gz android_packages_apps_Trebuchet-c65a0085d77edd8e8821254f081eb94e9dcc5e75.tar.bz2 android_packages_apps_Trebuchet-c65a0085d77edd8e8821254f081eb94e9dcc5e75.zip |
Adding support for showing the widget preview based on the provided RemoteViews
Bug: 35811129
Change-Id: I336e48cd00cfec2e617ac73bd8a81419b0944aa7
Diffstat (limited to 'tests/src/com/android/launcher3/testcomponent')
-rw-r--r-- | tests/src/com/android/launcher3/testcomponent/RequestPinItemActivity.java | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/tests/src/com/android/launcher3/testcomponent/RequestPinItemActivity.java b/tests/src/com/android/launcher3/testcomponent/RequestPinItemActivity.java index 2a031af69..85809922e 100644 --- a/tests/src/com/android/launcher3/testcomponent/RequestPinItemActivity.java +++ b/tests/src/com/android/launcher3/testcomponent/RequestPinItemActivity.java @@ -28,6 +28,7 @@ import android.graphics.Color; import android.graphics.Paint; import android.graphics.drawable.Icon; import android.os.Bundle; +import android.widget.RemoteViews; /** * Sample activity to request pinning an item. @@ -36,7 +37,8 @@ import android.os.Bundle; public class RequestPinItemActivity extends BaseTestingActivity { private PendingIntent mCallback = null; - private String mShortcutId; + private String mShortcutId = "test-id"; + private int mRemoteViewColor = Color.TRANSPARENT; @Override protected void onCreate(Bundle savedInstanceState) { @@ -51,6 +53,10 @@ public class RequestPinItemActivity extends BaseTestingActivity { mCallback = callback; } + public void setRemoteViewColor(int color) { + mRemoteViewColor = color; + } + public void setShortcutId(String id) { mShortcutId = id; } @@ -84,6 +90,16 @@ public class RequestPinItemActivity extends BaseTestingActivity { } private void requestWidget(ComponentName cn) { - AppWidgetManager.getInstance(this).requestPinAppWidget(cn, null, mCallback); + Bundle extras = null; + if (mRemoteViewColor != Color.TRANSPARENT) { + int layoutId = getResources().getIdentifier( + "test_layout_appwidget_view", "layout", getPackageName()); + RemoteViews views = new RemoteViews(getPackageName(), layoutId); + views.setInt(android.R.id.icon, "setBackgroundColor", mRemoteViewColor); + extras = new Bundle(); + extras.putParcelable(AppWidgetManager.EXTRA_APPWIDGET_PREVIEW, views); + } + + AppWidgetManager.getInstance(this).requestPinAppWidget(cn, extras, mCallback); } } |