Merge "Hide the snooze button from various notifications." into sc-dev
This commit is contained in:
@@ -5494,12 +5494,28 @@ public class Notification implements Parcelable
|
||||
big.setViewVisibility(R.id.notification_material_reply_text_3, View.GONE);
|
||||
big.setTextViewText(R.id.notification_material_reply_text_3, null);
|
||||
|
||||
final boolean snoozeEnabled = mContext.getContentResolver() != null
|
||||
&& (Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
Settings.Secure.SHOW_NOTIFICATION_SNOOZE, 0) == 1);
|
||||
int bottomMarginDimen = snoozeEnabled ? 0 : R.dimen.notification_content_margin;
|
||||
// This may get erased by bindSnoozeAction
|
||||
big.setViewLayoutMarginDimen(R.id.notification_action_list_margin_target,
|
||||
RemoteViews.MARGIN_BOTTOM, bottomMarginDimen);
|
||||
RemoteViews.MARGIN_BOTTOM, R.dimen.notification_content_margin);
|
||||
}
|
||||
|
||||
private void bindSnoozeAction(RemoteViews big, StandardTemplateParams p) {
|
||||
boolean hideSnoozeButton = mN.isForegroundService() || mN.fullScreenIntent != null
|
||||
|| isColorized(p) || p.mViewType == StandardTemplateParams.VIEW_TYPE_HEADS_UP;
|
||||
big.setBoolean(R.id.snooze_button, "setEnabled", !hideSnoozeButton);
|
||||
if (hideSnoozeButton) {
|
||||
// Only hide; NotificationContentView will show it when it adds the click listener
|
||||
big.setViewVisibility(R.id.snooze_button, View.GONE);
|
||||
}
|
||||
|
||||
final boolean snoozeEnabled = !hideSnoozeButton
|
||||
&& mContext.getContentResolver() != null
|
||||
&& (Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
Settings.Secure.SHOW_NOTIFICATION_SNOOZE, 0) == 1);
|
||||
if (snoozeEnabled) {
|
||||
big.setViewLayoutMarginDimen(R.id.notification_action_list_margin_target,
|
||||
RemoteViews.MARGIN_BOTTOM, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -5521,6 +5537,7 @@ public class Notification implements Parcelable
|
||||
RemoteViews big = applyStandardTemplate(layoutId, p, result);
|
||||
|
||||
resetStandardTemplateWithActions(big);
|
||||
bindSnoozeAction(big, p);
|
||||
|
||||
boolean validRemoteInput = false;
|
||||
|
||||
@@ -9358,6 +9375,7 @@ public class Notification implements Parcelable
|
||||
|
||||
// Bind actions.
|
||||
mBuilder.resetStandardTemplateWithActions(contentView);
|
||||
mBuilder.bindSnoozeAction(contentView, p);
|
||||
bindCallActions(contentView, p);
|
||||
|
||||
// Bind some extra conversation-specific header fields.
|
||||
@@ -11998,6 +12016,7 @@ public class Notification implements Parcelable
|
||||
boolean mHideTitle;
|
||||
boolean mHideActions;
|
||||
boolean mHideProgress;
|
||||
boolean mHideSnoozeButton;
|
||||
boolean mPromotePicture;
|
||||
boolean mAllowActionIcons;
|
||||
CharSequence title;
|
||||
@@ -12015,6 +12034,7 @@ public class Notification implements Parcelable
|
||||
mHideTitle = false;
|
||||
mHideActions = false;
|
||||
mHideProgress = false;
|
||||
mHideSnoozeButton = false;
|
||||
mPromotePicture = false;
|
||||
mAllowActionIcons = false;
|
||||
title = null;
|
||||
@@ -12061,6 +12081,11 @@ public class Notification implements Parcelable
|
||||
return this;
|
||||
}
|
||||
|
||||
final StandardTemplateParams hideSnoozeButton(boolean hideSnoozeButton) {
|
||||
this.mHideSnoozeButton = hideSnoozeButton;
|
||||
return this;
|
||||
}
|
||||
|
||||
final StandardTemplateParams promotePicture(boolean promotePicture) {
|
||||
this.mPromotePicture = promotePicture;
|
||||
return this;
|
||||
|
||||
@@ -17,15 +17,11 @@
|
||||
package com.android.systemui.statusbar.notification.row;
|
||||
|
||||
|
||||
import static android.provider.Settings.Global.NOTIFICATION_BUBBLES;
|
||||
import static android.provider.Settings.Secure.SHOW_NOTIFICATION_SNOOZE;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.app.Notification;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
@@ -1317,7 +1313,7 @@ public class NotificationContentView extends FrameLayout {
|
||||
|
||||
private boolean isBubblesEnabled() {
|
||||
return Settings.Global.getInt(mContext.getContentResolver(),
|
||||
NOTIFICATION_BUBBLES, 0) == 1;
|
||||
Settings.Global.NOTIFICATION_BUBBLES, 0) == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1373,27 +1369,26 @@ public class NotificationContentView extends FrameLayout {
|
||||
}
|
||||
ImageView snoozeButton = layout.findViewById(com.android.internal.R.id.snooze_button);
|
||||
View actionContainer = layout.findViewById(com.android.internal.R.id.actions_container);
|
||||
LinearLayout actionContainerLayout =
|
||||
layout.findViewById(com.android.internal.R.id.actions_container_layout);
|
||||
if (snoozeButton == null || actionContainer == null || actionContainerLayout == null) {
|
||||
if (snoozeButton == null || actionContainer == null) {
|
||||
return;
|
||||
}
|
||||
final boolean showSnooze = Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
SHOW_NOTIFICATION_SNOOZE, 0) == 1;
|
||||
if (!showSnooze) {
|
||||
Settings.Secure.SHOW_NOTIFICATION_SNOOZE, 0) == 1;
|
||||
// Notification.Builder can 'disable' the snooze button to prevent it from being shown here
|
||||
boolean snoozeDisabled = !snoozeButton.isEnabled();
|
||||
if (!showSnooze || snoozeDisabled) {
|
||||
snoozeButton.setVisibility(GONE);
|
||||
return;
|
||||
}
|
||||
|
||||
Resources res = mContext.getResources();
|
||||
Drawable snoozeDrawable = res.getDrawable(R.drawable.ic_snooze);
|
||||
Drawable snoozeDrawable = mContext.getDrawable(R.drawable.ic_snooze);
|
||||
mContainingNotification.updateNotificationColor();
|
||||
snoozeDrawable.setTint(mContainingNotification.getNotificationColor());
|
||||
snoozeButton.setImageDrawable(snoozeDrawable);
|
||||
|
||||
final NotificationSnooze snoozeGuts = (NotificationSnooze) LayoutInflater.from(mContext)
|
||||
.inflate(R.layout.notification_snooze, null, false);
|
||||
final String snoozeDescription = res.getString(
|
||||
final String snoozeDescription = mContext.getString(
|
||||
R.string.notification_menu_snooze_description);
|
||||
final NotificationMenuRowPlugin.MenuItem snoozeMenuItem =
|
||||
new NotificationMenuRow.NotificationMenuItem(
|
||||
|
||||
Reference in New Issue
Block a user