Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1815)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationPlatformBridge.java

Issue 2418153002: Hooking up Android N inline notification replies end-to-end (Closed)
Patch Set: Reformat getNotificationReply Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/android/javatests/src/org/chromium/chrome/browser/notifications/NotificationPlatformBridgeTest.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationPlatformBridge.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationPlatformBridge.java b/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationPlatformBridge.java
index 55e1de2fb8a0d5797e8da478da2fb256cc48a0f7..d68eea08e96c3e42ae3742d1da2bff90163827c1 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationPlatformBridge.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationPlatformBridge.java
@@ -7,6 +7,7 @@ package org.chromium.chrome.browser.notifications;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
+import android.app.RemoteInput;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
@@ -199,8 +200,8 @@ public class NotificationPlatformBridge {
}
int actionIndex = intent.getIntExtra(
NotificationConstants.EXTRA_NOTIFICATION_INFO_ACTION_INDEX, -1);
- sInstance.onNotificationClicked(
- notificationId, origin, profileId, incognito, tag, webApkPackage, actionIndex);
+ sInstance.onNotificationClicked(notificationId, origin, profileId, incognito, tag,
+ webApkPackage, actionIndex, getNotificationReply(intent));
return true;
} else if (NotificationConstants.ACTION_CLOSE_NOTIFICATION.equals(intent.getAction())) {
// Notification deleteIntent is executed only "when the notification is explicitly
@@ -215,6 +216,22 @@ public class NotificationPlatformBridge {
return false;
}
+ @Nullable
+ private static String getNotificationReply(Intent intent) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
+ // RemoteInput was added in KITKAT_WATCH.
+ Bundle remoteInputResults = RemoteInput.getResultsFromIntent(intent);
+ if (remoteInputResults != null) {
+ CharSequence reply =
+ remoteInputResults.getCharSequence(NotificationConstants.KEY_TEXT_REPLY);
+ if (reply != null) {
+ return reply.toString();
+ }
+ }
+ }
+ return null;
+ }
+
/**
* Launches the notifications preferences screen. If the received intent indicates it came
* from the gear button on a flipped notification, this launches the site specific preferences
@@ -679,12 +696,15 @@ public class NotificationPlatformBridge {
* @param webApkPackage The package of the WebAPK associated with the notification.
* Empty if the notification is not associated with a WebAPK.
* @param actionIndex
+ * @param reply User reply to a text action on the notification. Null if the user did not click
+ * on a text action or if inline replies are not supported.
*/
private void onNotificationClicked(String notificationId, String origin, String profileId,
- boolean incognito, String tag, String webApkPackage, int actionIndex) {
+ boolean incognito, String tag, String webApkPackage, int actionIndex,
+ @Nullable String reply) {
mLastNotificationClickMs = System.currentTimeMillis();
nativeOnNotificationClicked(mNativeNotificationPlatformBridge, notificationId, origin,
- profileId, incognito, tag, webApkPackage, actionIndex);
+ profileId, incognito, tag, webApkPackage, actionIndex, reply);
}
/**
@@ -708,7 +728,7 @@ public class NotificationPlatformBridge {
private native void nativeOnNotificationClicked(long nativeNotificationPlatformBridgeAndroid,
String notificationId, String origin, String profileId, boolean incognito, String tag,
- String webApkPackage, int actionIndex);
+ String webApkPackage, int actionIndex, String reply);
private native void nativeOnNotificationClosed(long nativeNotificationPlatformBridgeAndroid,
String notificationId, String origin, String profileId, boolean incognito, String tag,
boolean byUser);
« no previous file with comments | « no previous file | chrome/android/javatests/src/org/chromium/chrome/browser/notifications/NotificationPlatformBridgeTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698