summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorSelim Cinek <cinek@google.com>2017-05-18 22:16:00 -0700
committerSelim Cinek <cinek@google.com>2017-06-02 17:13:03 -0700
commit5d6ef8de1e2da541d1cf7c6603739289be4d593e (patch)
tree27e54d066d78026fea1928056ff849a8c5df1137 /core/java/android
parentd6fb3081d9ddd6384d7e764308e2967ce672d3e5 (diff)
Allow inline replying directly from the image
Test: runtest systemui Fixes: 35853345 Change-Id: Id942392b8de5b24de6f4f5cf335fd7f28e48d49a
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/app/Notification.java61
-rw-r--r--core/java/android/widget/RemoteViews.java2
2 files changed, 58 insertions, 5 deletions
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index 4587f2899e16..df9b64cb7b86 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -2742,6 +2742,11 @@ public class Notification implements Parcelable
private int mBackgroundColor = COLOR_INVALID;
private int mForegroundColor = COLOR_INVALID;
private int mBackgroundColorHint = COLOR_INVALID;
+ /**
+ * A temporary location where actions are stored. If != null the view originally has action
+ * but doesn't have any for this inflation.
+ */
+ private ArrayList<Action> mOriginalActions;
private boolean mRebuildStyledRemoteViews;
/**
@@ -4054,7 +4059,53 @@ public class Notification implements Parcelable
contentView.setViewLayoutMarginEndDimen(R.id.line1, endMargin);
contentView.setViewLayoutMarginEndDimen(R.id.text, endMargin);
contentView.setViewLayoutMarginEndDimen(R.id.progress, endMargin);
+ // Bind the reply action
+ Action action = findReplyAction();
+ contentView.setViewVisibility(R.id.reply_icon_action, action != null
+ ? View.VISIBLE
+ : View.GONE);
+
+ if (action != null) {
+ int contrastColor = resolveContrastColor();
+ contentView.setDrawableParameters(R.id.reply_icon_action,
+ true /* targetBackground */,
+ -1,
+ contrastColor,
+ PorterDuff.Mode.SRC_ATOP, -1);
+ int iconColor = NotificationColorUtil.isColorLight(contrastColor)
+ ? Color.BLACK : Color.WHITE;
+ contentView.setDrawableParameters(R.id.reply_icon_action,
+ false /* targetBackground */,
+ -1,
+ iconColor,
+ PorterDuff.Mode.SRC_ATOP, -1);
+ contentView.setOnClickPendingIntent(R.id.right_icon,
+ action.actionIntent);
+ contentView.setOnClickPendingIntent(R.id.reply_icon_action,
+ action.actionIntent);
+ contentView.setRemoteInputs(R.id.right_icon, action.mRemoteInputs);
+ contentView.setRemoteInputs(R.id.reply_icon_action, action.mRemoteInputs);
+
+ }
}
+ contentView.setViewVisibility(R.id.right_icon_container, mN.mLargeIcon != null
+ ? View.VISIBLE
+ : View.GONE);
+ }
+
+ private Action findReplyAction() {
+ ArrayList<Action> actions = mActions;
+ if (mOriginalActions != null) {
+ actions = mOriginalActions;
+ }
+ int numActions = actions.size();
+ for (int i = 0; i < numActions; i++) {
+ Action action = actions.get(i);
+ if (hasValidRemoteInput(action)) {
+ return action;
+ }
+ }
+ return null;
}
private void bindNotificationHeader(RemoteViews contentView, boolean ambient) {
@@ -5604,10 +5655,11 @@ public class Notification implements Parcelable
@Override
public RemoteViews makeContentView(boolean increasedHeight) {
if (increasedHeight) {
- ArrayList<Action> actions = mBuilder.mActions;
+ mBuilder.mOriginalActions = mBuilder.mActions;
mBuilder.mActions = new ArrayList<>();
RemoteViews remoteViews = makeBigContentView();
- mBuilder.mActions = actions;
+ mBuilder.mActions = mBuilder.mOriginalActions;
+ mBuilder.mOriginalActions = null;
return remoteViews;
}
return super.makeContentView(increasedHeight);
@@ -5891,10 +5943,11 @@ public class Notification implements Parcelable
return mBuilder.applyStandardTemplate(mBuilder.getBaseLayoutResource(),
mBuilder.mParams.reset().hasProgress(false).title(title).text(text));
} else {
- ArrayList<Action> actions = mBuilder.mActions;
+ mBuilder.mOriginalActions = mBuilder.mActions;
mBuilder.mActions = new ArrayList<>();
RemoteViews remoteViews = makeBigContentView();
- mBuilder.mActions = actions;
+ mBuilder.mActions = mBuilder.mOriginalActions;
+ mBuilder.mOriginalActions = null;
return remoteViews;
}
}
diff --git a/core/java/android/widget/RemoteViews.java b/core/java/android/widget/RemoteViews.java
index 985584e7d7ab..49e1d4486cf8 100644
--- a/core/java/android/widget/RemoteViews.java
+++ b/core/java/android/widget/RemoteViews.java
@@ -2191,7 +2191,7 @@ public class RemoteViews implements Parcelable, Filter {
@Override
public void apply(View root, ViewGroup rootParent, OnClickHandler handler) {
- final TextView target = (TextView) root.findViewById(viewId);
+ final View target = root.findViewById(viewId);
if (target == null) return;
target.setTagInternal(R.id.remote_input_tag, remoteInputs);