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

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

Issue 2702023002: Migrate web notifications to ChromeNotificationBuilder (Closed)
Patch Set: rebase Created 3 years, 10 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/CustomNotificationBuilder.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/notifications/CustomNotificationBuilder.java b/chrome/android/java/src/org/chromium/chrome/browser/notifications/CustomNotificationBuilder.java
index 94b138c15da4fdd46fd7dbb36414f410aa69f5d6..1e2a414db26d5d5253f9b677b8144081ea07a23c 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/notifications/CustomNotificationBuilder.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/notifications/CustomNotificationBuilder.java
@@ -24,6 +24,7 @@ import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.VisibleForTesting;
import org.chromium.base.metrics.RecordHistogram;
import org.chromium.chrome.R;
+import org.chromium.chrome.browser.ChromeApplication;
import org.chromium.ui.base.LocalizationUtils;
import java.util.Date;
@@ -137,9 +138,18 @@ public class CustomNotificationBuilder extends NotificationBuilderBase {
addActionButtons(bigView);
configureSettingsButton(bigView);
- // Note: this is not a NotificationCompat builder so be mindful of the
+ // Note: under the hood this is not a NotificationCompat builder so be mindful of the
// API level of methods you call on the builder.
- Notification.Builder builder = new Notification.Builder(mContext);
+ // TODO(crbug.com/697104) We should probably use a Compat builder.
+ ChromeNotificationBuilder builder =
+ ((ChromeApplication) mContext.getApplicationContext())
+ .createChromeNotificationBuilder(false /* preferCompat */,
+ NotificationConstants.CATEGORY_ID_SITES,
+ mContext.getString(
+ org.chromium.chrome.R.string.notification_category_sites),
+ NotificationConstants.CATEGORY_GROUP_ID_GENERAL,
+ mContext.getString(org.chromium.chrome.R.string
+ .notification_category_group_general));
builder.setTicker(mTickerText);
builder.setContentIntent(mContentIntent);
builder.setDeleteIntent(mDeleteIntent);
@@ -147,7 +157,7 @@ public class CustomNotificationBuilder extends NotificationBuilderBase {
builder.setVibrate(mVibratePattern);
builder.setWhen(mTimestamp);
builder.setOnlyAlertOnce(!mRenotify);
- ApiCompatibilityUtils.setContentViewForNotificationBuilder(builder, compactView);
+ builder.setContent(compactView);
// Some things are duplicated in the builder to ensure the notification shows correctly on
// Wear devices and custom lock screens.
@@ -163,12 +173,9 @@ public class CustomNotificationBuilder extends NotificationBuilderBase {
addActionToBuilder(builder, mSettingsAction);
}
setGroupOnBuilder(builder, mOrigin);
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
- // Notification.Builder.setPublicVersion was added in Android L.
- builder.setPublicVersion(createPublicNotification(mContext));
- }
+ builder.setPublicVersion(createPublicNotification(mContext));
- return ApiCompatibilityUtils.notificationWithBigContentView(builder, bigView);
+ return builder.buildWithBigContentView(bigView);
}
/**

Powered by Google App Engine
This is Rietveld 408576698