| 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 0381041ed47919404f9b5b459e301c26898cef95..55e1de2fb8a0d5797e8da478da2fb256cc48a0f7 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
|
| @@ -506,8 +506,10 @@ public class NotificationPlatformBridge {
|
| makePendingIntent(NotificationConstants.ACTION_CLOSE_NOTIFICATION, notificationId,
|
| origin, profileId, incognito, tag, webApkPackage, -1 /* actionIndex */);
|
|
|
| + boolean hasImage = image != null;
|
| +
|
| NotificationBuilderBase notificationBuilder =
|
| - createNotificationBuilder()
|
| + createNotificationBuilder(hasImage)
|
| .setTitle(title)
|
| .setBody(body)
|
| .setImage(image)
|
| @@ -526,13 +528,15 @@ public class NotificationPlatformBridge {
|
| PendingIntent intent = makePendingIntent(
|
| NotificationConstants.ACTION_CLICK_NOTIFICATION, notificationId, origin,
|
| profileId, incognito, tag, webApkPackage, actionIndex);
|
| + // Don't show action button icons when there's an image, as then action buttons go on
|
| + // the same row as the Site Settings button, so icons wouldn't leave room for text.
|
| + Bitmap actionIcon = hasImage ? null : actionIcons[actionIndex];
|
| // TODO(crbug.com/650302): Encode actionTypes with an enum, not a magic string!
|
| if (actionTypes[actionIndex].equals("text")) {
|
| - notificationBuilder.addTextAction(actionIcons[actionIndex],
|
| - actionTitles[actionIndex], intent, actionPlaceholders[actionIndex]);
|
| + notificationBuilder.addTextAction(actionIcon, actionTitles[actionIndex], intent,
|
| + actionPlaceholders[actionIndex]);
|
| } else {
|
| - notificationBuilder.addButtonAction(
|
| - actionIcons[actionIndex], actionTitles[actionIndex], intent);
|
| + notificationBuilder.addButtonAction(actionIcon, actionTitles[actionIndex], intent);
|
| }
|
| }
|
|
|
| @@ -540,7 +544,7 @@ public class NotificationPlatformBridge {
|
| // label and icon, so abbreviate it. This has the unfortunate side-effect of unnecessarily
|
| // abbreviating it on Android Wear also (crbug.com/576656). If custom layouts are enabled,
|
| // the label and icon provided here only affect Android Wear, so don't abbreviate them.
|
| - boolean abbreviateSiteSettings = actionTitles.length > 0 && !useCustomLayouts();
|
| + boolean abbreviateSiteSettings = actionTitles.length > 0 && !useCustomLayouts(hasImage);
|
| int settingsIconId = abbreviateSiteSettings ? 0 : R.drawable.settings_cog;
|
| CharSequence settingsTitle = abbreviateSiteSettings
|
| ? res.getString(R.string.notification_site_settings_button)
|
| @@ -569,8 +573,8 @@ public class NotificationPlatformBridge {
|
| }
|
| }
|
|
|
| - private NotificationBuilderBase createNotificationBuilder() {
|
| - if (useCustomLayouts()) {
|
| + private NotificationBuilderBase createNotificationBuilder(boolean hasImage) {
|
| + if (useCustomLayouts(hasImage)) {
|
| return new CustomNotificationBuilder(mAppContext);
|
| }
|
| return new StandardNotificationBuilder(mAppContext);
|
| @@ -604,10 +608,16 @@ public class NotificationPlatformBridge {
|
| *
|
| * The --{enable,disable}-web-notification-custom-layouts command line flags take precedence.
|
| *
|
| + * Normally a standard layout is used on Android N+, and a custom layout is used on older
|
| + * versions of Android. But if the notification has a content image, there isn't enough room for
|
| + * the Site Settings button to go on its own line when showing an image, nor is there enough
|
| + * room for action button icons, so a standard layout will be used here even on old versions.
|
| + *
|
| + * @param hasImage Whether the notification has a content image.
|
| * @return Whether custom layouts should be used.
|
| */
|
| @VisibleForTesting
|
| - static boolean useCustomLayouts() {
|
| + static boolean useCustomLayouts(boolean hasImage) {
|
| CommandLine commandLine = CommandLine.getInstance();
|
| if (commandLine.hasSwitch(ChromeSwitches.ENABLE_WEB_NOTIFICATION_CUSTOM_LAYOUTS)) {
|
| return true;
|
| @@ -618,6 +628,9 @@ public class NotificationPlatformBridge {
|
| if (Build.VERSION.CODENAME.equals("N") || Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
|
| return false;
|
| }
|
| + if (hasImage) {
|
| + return false;
|
| + }
|
| return true;
|
| }
|
|
|
|
|