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

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

Issue 2628723003: Android notifications: set group for push notifications (Closed)
Patch Set: rebase Created 3 years, 11 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/NotificationBuilderBase.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationBuilderBase.java b/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationBuilderBase.java
index 6635ecca72c969545d3f25e12d52abd9980284de..f3c79fc3f9cf5fd62a95362690e130ffcbc9a165 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationBuilderBase.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationBuilderBase.java
@@ -4,6 +4,7 @@
package org.chromium.chrome.browser.notifications;
+import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Notification;
import android.app.PendingIntent;
@@ -429,6 +430,21 @@ public abstract class NotificationBuilderBase {
}
}
+ /**
+ * Sets the notification group for the builder, determined by the origin provided.
+ * Note, after this notification is built and posted, a further summary notification must be
+ * posted for notifications in the group to appear grouped in the notification shade.
+ */
+ @SuppressLint("NewApi") // For setGroup
+ static void setGroupOnBuilder(Notification.Builder builder, CharSequence origin) {
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT_WATCH || origin == null) return;
+ builder.setGroup(NotificationConstants.GROUP_WEB_PREFIX + origin);
+ // TODO(crbug.com/674927) Post a group summary notification.
+ // Notifications with the same group will only actually be stacked if we post a group
+ // summary notification. Calling setGroup at least prevents them being autobundled with
+ // all Chrome notifications on N though (see crbug.com/674015).
+ }
+
@TargetApi(Build.VERSION_CODES.KITKAT_WATCH) // For Notification.Action.Builder
@SuppressWarnings("deprecation") // For Builder(int, CharSequence, PendingIntent)
private static Notification.Action.Builder getActionBuilder(Action action) {

Powered by Google App Engine
This is Rietveld 408576698