| 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 0c5e0d0040232bd9be5f42339653fdf211fd6dff..274ebd0f36bc7cdb18d74e9b51ff3d8f75091061 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
|
| @@ -99,6 +99,7 @@
|
| private PendingIntent mContentIntent;
|
| private PendingIntent mDeleteIntent;
|
| private List<Action> mActions = new ArrayList<>(MAX_ACTION_BUTTONS);
|
| + private Action mSettingsAction;
|
| private int mDefaults = Notification.DEFAULT_ALL;
|
| private long[] mVibratePattern;
|
|
|
| @@ -140,6 +141,7 @@ public Notification build() {
|
| addWorkProfileBadge(view);
|
| }
|
| addActionButtons(bigView);
|
| + configureSettingsButton(bigView);
|
|
|
| if (useMaterial()) {
|
| compactView.setViewVisibility(R.id.small_icon_overlay, View.VISIBLE);
|
| @@ -167,6 +169,9 @@ public Notification build() {
|
| for (Action action : mActions) {
|
| builder.addAction(action);
|
| }
|
| + if (mSettingsAction != null) {
|
| + builder.addAction(mSettingsAction);
|
| + }
|
|
|
| Notification notification = builder.build();
|
| notification.bigContentView = bigView;
|
| @@ -232,6 +237,13 @@ public NotificationBuilder addAction(int iconId, CharSequence title, PendingInte
|
| }
|
|
|
| @Override
|
| + public NotificationBuilder addSettingsAction(
|
| + int iconId, CharSequence title, PendingIntent intent) {
|
| + mSettingsAction = new Action(iconId, limitLength(title), intent);
|
| + return this;
|
| + }
|
| +
|
| + @Override
|
| public NotificationBuilder setDefaults(int defaults) {
|
| mDefaults = defaults;
|
| return this;
|
| @@ -250,12 +262,12 @@ private void addActionButtons(RemoteViews bigView) {
|
| // 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. The current
|
| + // visibility state is not known as perhaps an existing notification is being updated.
|
| + int visibility = mActions.isEmpty() ? View.GONE : View.VISIBLE;
|
| + 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) {
|
| @@ -290,6 +302,16 @@ private void addActionButtons(RemoteViews bigView) {
|
| }
|
| }
|
|
|
| + private void configureSettingsButton(RemoteViews bigView) {
|
| + if (mSettingsAction == null) {
|
| + return;
|
| + }
|
| + bigView.setOnClickPendingIntent(R.id.origin, mSettingsAction.getActionIntent());
|
| + if (useMaterial()) {
|
| + bigView.setInt(R.id.origin_settings_icon, "setColorFilter", BUTTON_ICON_COLOR_MATERIAL);
|
| + }
|
| + }
|
| +
|
| /**
|
| * Shows the work profile badge if it is needed.
|
| */
|
|
|