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 c394cecacbb60d2df194b2890b91e6e01c3dbab6..99ceac2ced2d5bc77c52de802c780fc610e0c398 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 |
@@ -238,18 +238,27 @@ public NotificationBuilder setVibrate(long[] pattern) { |
* If there are actions, shows the button related views, and adds a button for each action. |
*/ |
private void addActionButtons(RemoteViews bigView) { |
+ // The settings button is always the last one. |
+ if (mActions.isEmpty()) { |
+ throw new IllegalStateException("There must be an action for the settings button."); |
Peter Beverloo
2016/01/08 21:29:31
Could we instead have a new method for setting the
Michael van Ouwerkerk
2016/01/11 16:33:17
Yes, I was avoiding that because it's not needed f
|
+ } |
+ |
// Remove the existing buttons in case an existing notification is being updated. |
bigView.removeAllViews(R.id.buttons); |
- if (mActions.isEmpty()) { |
- return; |
- } |
+ // Always set the visibility of the views associated with the action buttons that are not |
+ // the settings button. The current visibility state is not known as perhaps an existing |
+ // notification is being updated. |
+ int visibility = mActions.size() > 1 ? View.VISIBLE : View.GONE; |
+ bigView.setViewVisibility(R.id.button_divider, visibility); |
+ bigView.setViewVisibility(R.id.buttons, visibility); |
- bigView.setViewVisibility(R.id.button_divider, View.VISIBLE); |
- bigView.setViewVisibility(R.id.buttons, View.VISIBLE); |
Resources resources = mContext.getResources(); |
DisplayMetrics metrics = resources.getDisplayMetrics(); |
- for (Action action : mActions) { |
+ |
+ // The settings button is always the last one. First do the regular buttons. |
+ for (int i = 0; i < mActions.size() - 1; i++) { |
+ Action action = mActions.get(i); |
RemoteViews view = |
new RemoteViews(mContext.getPackageName(), R.layout.web_notification_button); |
@@ -279,6 +288,13 @@ private void addActionButtons(RemoteViews bigView) { |
view.setOnClickPendingIntent(R.id.button, action.getActionIntent()); |
bigView.addView(R.id.buttons, view); |
} |
+ |
+ // Configure the settings button. |
+ Action action = mActions.get(mActions.size() - 1); |
+ bigView.setOnClickPendingIntent(R.id.origin, action.getActionIntent()); |
+ if (useMaterial()) { |
+ bigView.setInt(R.id.origin_settings_icon, "setColorFilter", BUTTON_ICON_COLOR_MATERIAL); |
+ } |
} |
@Nullable |