diff options
| author | Tony Mak <tonymak@google.com> | 2018-11-27 17:29:36 +0000 |
|---|---|---|
| committer | Tony Mak <tonymak@google.com> | 2018-11-29 11:43:53 +0000 |
| commit | 7d4b3a5f19a3834ed75a3e61d4fdd20b0b64f9cb (patch) | |
| tree | 424936685375d691148d16b761a867c1d43f930c /core/java/android/widget/RemoteViews.java | |
| parent | d8a9db84862b7f9a8d2dc50373e7642b818862f4 (diff) | |
Add onActionClicked in NotificationAssistantService
This is added to report clicks on actions buttons to NAS.
BUG: 119010281
Test: atest SystemUITests
Test: atest RemoteViewsTest
Test: atest NotificationManagerServiceTest
Test: Manual. Tapped on the action (both normal and contextual) and
observed the log.
Change-Id: I381994737d8c3185d3fabf9b6c481fd01a89a634
Diffstat (limited to 'core/java/android/widget/RemoteViews.java')
| -rw-r--r-- | core/java/android/widget/RemoteViews.java | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/core/java/android/widget/RemoteViews.java b/core/java/android/widget/RemoteViews.java index c0979fe13de4..7b39efed0c3a 100644 --- a/core/java/android/widget/RemoteViews.java +++ b/core/java/android/widget/RemoteViews.java @@ -161,6 +161,7 @@ public class RemoteViews implements Parcelable, Filter { private static final int LAYOUT_PARAM_ACTION_TAG = 19; private static final int OVERRIDE_TEXT_COLORS_TAG = 20; private static final int SET_RIPPLE_DRAWABLE_COLOR_TAG = 21; + private static final int SET_INT_TAG_TAG = 22; /** * Application that hosts the remote views. @@ -274,6 +275,15 @@ public class RemoteViews implements Parcelable, Filter { } /** + * Sets an integer tag to the view. + * + * @hide + */ + public void setIntTag(int viewId, int key, int tag) { + addAction(new SetIntTagAction(viewId, key, tag)); + } + + /** * Set that it is disallowed to reapply another remoteview with the same layout as this view. * This should be done if an action is destroying the view tree of the base layout. * @@ -2122,6 +2132,43 @@ public class RemoteViews implements Parcelable, Filter { } } + private class SetIntTagAction extends Action { + private final int mViewId; + private final int mKey; + private final int mTag; + + SetIntTagAction(int viewId, int key, int tag) { + mViewId = viewId; + mKey = key; + mTag = tag; + } + + SetIntTagAction(Parcel parcel) { + mViewId = parcel.readInt(); + mKey = parcel.readInt(); + mTag = parcel.readInt(); + } + + public void writeToParcel(Parcel dest, int flags) { + dest.writeInt(mViewId); + dest.writeInt(mKey); + dest.writeInt(mTag); + } + + @Override + public void apply(View root, ViewGroup rootParent, OnClickHandler handler) { + final View target = root.findViewById(mViewId); + if (target == null) return; + + target.setTagInternal(mKey, mTag); + } + + @Override + public int getActionTag() { + return SET_INT_TAG_TAG; + } + } + /** * Create a new RemoteViews object that will display the views contained * in the specified layout file. @@ -2326,6 +2373,8 @@ public class RemoteViews implements Parcelable, Filter { return new OverrideTextColorsAction(parcel); case SET_RIPPLE_DRAWABLE_COLOR_TAG: return new SetRippleDrawableColor(parcel); + case SET_INT_TAG_TAG: + return new SetIntTagAction(parcel); default: throw new ActionException("Tag " + tag + " not found"); } |
