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

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: Hooking up Android N inline notification replies end-to-end 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
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..c9990a99af6caddf06b3350d6ada34b6714351c5 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));
awdf 2016/10/17 14:51:23 I will work on doing the progress notification thi
return true;
} else if (NotificationConstants.ACTION_CLOSE_NOTIFICATION.equals(intent.getAction())) {
// Notification deleteIntent is executed only "when the notification is explicitly
@@ -215,6 +216,19 @@ public class NotificationPlatformBridge {
return false;
}
+ @Nullable
+ private static String getNotificationReply(Intent intent) {
+ String reply = null;
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
+ // RemoteInput was added in KITKATCH_WATCH.
Peter Beverloo 2016/10/17 14:11:39 KITKATCH!
awdf 2016/10/17 14:51:23 ! Fixed.
+ Bundle remoteInputResults = RemoteInput.getResultsFromIntent(intent);
+ if (remoteInputResults != null) {
+ reply = remoteInputResults.getString(NotificationConstants.KEY_TEXT_REPLY);
+ }
+ }
+ return reply;
+ }
+
/**
* 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 +693,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 +725,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);

Powered by Google App Engine
This is Rietveld 408576698