diff --git a/res/values/strings.xml b/res/values/strings.xml
index 3b9e71269ae..deb1cb3bc2a 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -5953,14 +5953,20 @@
Normal: Silently show these notifications
- High: Show at the top of the notifications list and make sound
+ High: Show at the top of the notifications list and allow sound
- Urgent: Peek onto the screen and make sound
+ Urgent: Peek onto the screen and allow sound
Reset
+
+ Show silently
+
+
+ Don\'t make sound, vibrate, or peek these notifications into view on the current screen.
+
Notification assistant
diff --git a/res/xml/app_notification_settings.xml b/res/xml/app_notification_settings.xml
index 1a2584ae3bb..37c4426f02e 100644
--- a/res/xml/app_notification_settings.xml
+++ b/res/xml/app_notification_settings.xml
@@ -19,31 +19,44 @@
android:key="app_notification_settings">
+
+
+
+
+
+ android:order="4"/>
+ android:order="5"/>
+ android:order="6" />
+ android:order="7" />
+ android:order="8" />
diff --git a/src/com/android/settings/notification/AppNotificationSettings.java b/src/com/android/settings/notification/AppNotificationSettings.java
index 8f30f591d11..f04cf2fe61b 100644
--- a/src/com/android/settings/notification/AppNotificationSettings.java
+++ b/src/com/android/settings/notification/AppNotificationSettings.java
@@ -26,23 +26,15 @@ import android.os.Bundle;
import android.os.UserHandle;
import android.provider.Settings;
import android.service.notification.NotificationListenerService.Ranking;
-import android.support.v7.preference.Preference;
-import android.support.v7.preference.Preference.OnPreferenceChangeListener;
-import android.support.v7.preference.Preference.OnPreferenceClickListener;
-import android.support.v7.preference.PreferenceCategory;
import android.util.ArrayMap;
import android.util.Log;
-import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.MetricsProto.MetricsEvent;
import com.android.internal.widget.LockPatternUtils;
import com.android.settings.AppHeader;
import com.android.settings.R;
-import com.android.settings.Utils;
-import com.android.settings.applications.AppInfoBase;
import com.android.settings.applications.LayoutPreference;
import com.android.settings.notification.NotificationBackend.AppRow;
-import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedSwitchPreference;
import com.android.settingslib.RestrictedPreference;
@@ -86,6 +78,8 @@ public class AppNotificationSettings extends NotificationSettingsBase {
(RestrictedSwitchPreference) getPreferenceScreen().findPreference(KEY_BYPASS_DND);
mSensitive =
(RestrictedSwitchPreference) getPreferenceScreen().findPreference(KEY_SENSITIVE);
+ mBlock = (RestrictedSwitchPreference) getPreferenceScreen().findPreference(KEY_BLOCK);
+ mSilent = (RestrictedSwitchPreference) getPreferenceScreen().findPreference(KEY_SILENT);
mAppRow = mBackend.loadAppRow(mPm, mPkgInfo);
@@ -98,7 +92,7 @@ public class AppNotificationSettings extends NotificationSettingsBase {
rows.put(mAppRow.pkg, mAppRow);
collectConfigActivities(rows);
- setupImportancePrefs(mAppRow.systemApp, mAppRow.appImportance);
+ setupImportancePrefs(mAppRow.systemApp, mAppRow.appImportance, mAppRow.banned);
setupPriorityPref(mAppRow.appBypassDnd);
setupSensitivePref(mAppRow.appSensitive);
updateDependents(mAppRow.appImportance);
@@ -111,9 +105,13 @@ public class AppNotificationSettings extends NotificationSettingsBase {
final boolean lockscreenNotificationsEnabled = getLockscreenNotificationsEnabled();
final boolean allowPrivate = getLockscreenAllowPrivateNotifications();
- setVisible(mPriority, checkCanBeVisible(Ranking.IMPORTANCE_DEFAULT, importance)
+ if (getPreferenceScreen().findPreference(mBlock.getKey()) != null) {
+ setVisible(mSilent, checkCanBeVisible(Ranking.IMPORTANCE_LOW, importance));
+ mSilent.setChecked(importance == Ranking.IMPORTANCE_DEFAULT);
+ }
+ setVisible(mPriority, checkCanBeVisible(Ranking.IMPORTANCE_LOW, importance)
&& !mDndVisualEffectsSuppressed);
- setVisible(mSensitive, checkCanBeVisible(Ranking.IMPORTANCE_LOW, importance)
+ setVisible(mSensitive, checkCanBeVisible(Ranking.IMPORTANCE_HIGH, importance)
&& lockscreenSecure && lockscreenNotificationsEnabled && allowPrivate);
}
@@ -121,7 +119,7 @@ public class AppNotificationSettings extends NotificationSettingsBase {
if (importance == Ranking.IMPORTANCE_UNSPECIFIED) {
return true;
}
- return importance > minImportanceVisible;
+ return importance >= minImportanceVisible;
}
private boolean getLockscreenNotificationsEnabled() {
diff --git a/src/com/android/settings/notification/NotificationSettingsBase.java b/src/com/android/settings/notification/NotificationSettingsBase.java
index a58edf7f793..895d38dbd8e 100644
--- a/src/com/android/settings/notification/NotificationSettingsBase.java
+++ b/src/com/android/settings/notification/NotificationSettingsBase.java
@@ -46,12 +46,15 @@ import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
abstract public class NotificationSettingsBase extends SettingsPreferenceFragment {
private static final String TAG = "NotifiSettingsBase";
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
+ private static final String TUNER_SETTING = "show_importance_slider";
protected static final String KEY_BYPASS_DND = "bypass_dnd";
protected static final String KEY_SENSITIVE = "sensitive";
protected static final String KEY_IMPORTANCE = "importance";
protected static final String KEY_IMPORTANCE_TITLE = "importance_title";
protected static final String KEY_IMPORTANCE_RESET = "importance_reset_button";
+ protected static final String KEY_BLOCK = "block";
+ protected static final String KEY_SILENT = "silent";
protected PackageManager mPm;
protected final NotificationBackend mBackend = new NotificationBackend();
@@ -66,7 +69,10 @@ abstract public class NotificationSettingsBase extends SettingsPreferenceFragmen
protected LayoutPreference mImportanceReset;
protected RestrictedSwitchPreference mPriority;
protected RestrictedSwitchPreference mSensitive;
+ protected RestrictedSwitchPreference mBlock;
+ protected RestrictedSwitchPreference mSilent;
protected EnforcedAdmin mSuspendedAppsAdmin;
+ protected boolean mShowSlider = false;
@Override
public void onActivityCreated(Bundle savedInstanceState) {
@@ -119,6 +125,7 @@ abstract public class NotificationSettingsBase extends SettingsPreferenceFragmen
mSuspendedAppsAdmin = RestrictedLockUtils.checkIfApplicationIsSuspended(
mContext, mPkg, mUserId);
+ mShowSlider = Settings.Secure.getInt(getContentResolver(), TUNER_SETTING, 0) == 1;
}
@Override
@@ -143,54 +150,94 @@ abstract public class NotificationSettingsBase extends SettingsPreferenceFragmen
if (mImportanceTitle != null) {
mImportanceTitle.setDisabledByAdmin(mSuspendedAppsAdmin);
}
+ if (mBlock != null) {
+ mBlock.setDisabledByAdmin(mSuspendedAppsAdmin);
+ }
+ if (mSilent != null) {
+ mSilent.setDisabledByAdmin(mSuspendedAppsAdmin);
+ }
}
- protected void setupImportancePrefs(boolean isSystemApp, int importance) {
- mImportance.setDisabledByAdmin(mSuspendedAppsAdmin);
- mImportanceTitle.setDisabledByAdmin(mSuspendedAppsAdmin);
- if (importance == Ranking.IMPORTANCE_UNSPECIFIED) {
- mImportance.setVisible(false);
- mImportanceReset.setVisible(false);
- mImportanceTitle.setOnPreferenceClickListener(showEditableImportance);
- } else {
- mImportanceTitle.setOnPreferenceClickListener(null);
- }
-
- mImportanceTitle.setSummary(getProgressSummary(importance));
- mImportance.setSystemApp(isSystemApp);
- mImportance.setMinimumProgress(
- isSystemApp ? Ranking.IMPORTANCE_LOW : Ranking.IMPORTANCE_NONE);
- mImportance.setMax(Ranking.IMPORTANCE_MAX);
- mImportance.setProgress(importance);
- mImportance.setCallback(new ImportanceSeekBarPreference.Callback() {
- @Override
- public void onImportanceChanged(int progress) {
- mBackend.setImportance(mPkg, mUid, progress);
- mImportanceTitle.setSummary(getProgressSummary(progress));
- updateDependents(progress);
- }
- });
-
- Button button = (Button) mImportanceReset.findViewById(R.id.left_button);
- button.setText(R.string.importance_reset);
- button.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (mSuspendedAppsAdmin != null) {
- RestrictedLockUtils.sendShowAdminSupportDetailsIntent(
- getActivity(), mSuspendedAppsAdmin);
- return;
- }
-
- mBackend.setImportance(mPkg, mUid, Ranking.IMPORTANCE_UNSPECIFIED);
- mImportanceReset.setVisible(false);
+ protected void setupImportancePrefs(boolean isSystemApp, int importance, boolean banned) {
+ if (mShowSlider) {
+ setVisible(mBlock, false);
+ setVisible(mSilent, false);
+ mImportance.setDisabledByAdmin(mSuspendedAppsAdmin);
+ mImportanceTitle.setDisabledByAdmin(mSuspendedAppsAdmin);
+ if (importance == Ranking.IMPORTANCE_UNSPECIFIED) {
mImportance.setVisible(false);
+ mImportanceReset.setVisible(false);
mImportanceTitle.setOnPreferenceClickListener(showEditableImportance);
- mImportanceTitle.setSummary(getProgressSummary(Ranking.IMPORTANCE_UNSPECIFIED));
- updateDependents(Ranking.IMPORTANCE_UNSPECIFIED);
+ } else {
+ mImportanceTitle.setOnPreferenceClickListener(null);
}
- });
- mImportanceReset.findViewById(R.id.right_button).setVisibility(View.INVISIBLE);
+
+ mImportanceTitle.setSummary(getProgressSummary(importance));
+ mImportance.setSystemApp(isSystemApp);
+ mImportance.setMinimumProgress(
+ isSystemApp ? Ranking.IMPORTANCE_LOW : Ranking.IMPORTANCE_NONE);
+ mImportance.setMax(Ranking.IMPORTANCE_MAX);
+ mImportance.setProgress(importance);
+ mImportance.setCallback(new ImportanceSeekBarPreference.Callback() {
+ @Override
+ public void onImportanceChanged(int progress) {
+ mBackend.setImportance(mPkg, mUid, progress);
+ mImportanceTitle.setSummary(getProgressSummary(progress));
+ updateDependents(progress);
+ }
+ });
+
+ Button button = (Button) mImportanceReset.findViewById(R.id.left_button);
+ button.setText(R.string.importance_reset);
+ button.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (mSuspendedAppsAdmin != null) {
+ RestrictedLockUtils.sendShowAdminSupportDetailsIntent(
+ getActivity(), mSuspendedAppsAdmin);
+ return;
+ }
+
+ mBackend.setImportance(mPkg, mUid, Ranking.IMPORTANCE_UNSPECIFIED);
+ mImportanceReset.setVisible(false);
+ mImportance.setVisible(false);
+ mImportanceTitle.setOnPreferenceClickListener(showEditableImportance);
+ mImportanceTitle.setSummary(getProgressSummary(Ranking.IMPORTANCE_UNSPECIFIED));
+ updateDependents(Ranking.IMPORTANCE_UNSPECIFIED);
+ }
+ });
+ mImportanceReset.findViewById(R.id.right_button).setVisibility(View.INVISIBLE);
+ } else {
+ setVisible(mImportance, false);
+ setVisible(mImportanceReset, false);
+ setVisible(mImportanceTitle, false);
+ boolean blocked = importance == Ranking.IMPORTANCE_NONE || banned;
+ mBlock.setChecked(blocked);
+ mBlock.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ final boolean blocked = (Boolean) newValue;
+ final int importance =
+ blocked ? Ranking.IMPORTANCE_NONE :Ranking.IMPORTANCE_UNSPECIFIED;
+ mBackend.setImportance(mPkgInfo.packageName, mUid, importance);
+ updateDependents(importance);
+ return true;
+ }
+ });
+
+ mSilent.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ final boolean silenced = (Boolean) newValue;
+ final int importance =
+ silenced ? Ranking.IMPORTANCE_DEFAULT : Ranking.IMPORTANCE_UNSPECIFIED;
+ mBackend.setImportance(mPkgInfo.packageName, mUid, importance);
+ updateDependents(importance);
+ return true;
+ }
+ });
+ updateDependents(banned ? Ranking.IMPORTANCE_NONE : importance);
+ }
}
private String getProgressSummary(int progress) {