Replace slider with switches; move slider to tuner.
Bug: 22451710
Change-Id: I86a57479757b3c7a43a789b0b3d7a81afb6d0cf9
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 3b9e712..deb1cb3 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -5953,14 +5953,20 @@
<string name="notification_importance_default">Normal: Silently show these notifications</string>
<!-- [CHAR LIMIT=100] Notification Importance slider: high importance level description -->
- <string name="notification_importance_high">High: Show at the top of the notifications list and make sound</string>
+ <string name="notification_importance_high">High: Show at the top of the notifications list and allow sound</string>
<!-- [CHAR LIMIT=100] Notification Importance slider: max importance level description -->
- <string name="notification_importance_max">Urgent: Peek onto the screen and make sound</string>
+ <string name="notification_importance_max">Urgent: Peek onto the screen and allow sound</string>
<!-- [CHAR LIMIT=60] Notification importance reset button -->
<string name="importance_reset">Reset</string>
+ <!-- [CHAR LIMIT=40] Notification importance title -->
+ <string name="show_silently">Show silently</string>
+
+ <!-- [CHAR LIMIT=180] Notification importance summary -->
+ <string name="show_silently_summary">Don\'t make sound, vibrate, or peek these notifications into view on the current screen.</string>
+
<!-- Default Apps > Default notification assistant -->
<string name="default_notification_assistant">Notification assistant</string>
diff --git a/res/xml/app_notification_settings.xml b/res/xml/app_notification_settings.xml
index 1a2584a..37c4426 100644
--- a/res/xml/app_notification_settings.xml
+++ b/res/xml/app_notification_settings.xml
@@ -19,31 +19,44 @@
android:key="app_notification_settings">
<!-- Importance -->
+ <!-- Block -->
+ <com.android.settingslib.RestrictedSwitchPreference
+ android:key="block"
+ android:title="@string/app_notification_block_title"
+ android:summary="@string/app_notification_block_summary"
+ android:order="2" />
+ <!-- Silent -->
+ <com.android.settingslib.RestrictedSwitchPreference
+ android:key="silent"
+ android:title="@string/show_silently"
+ android:summary="@string/show_silently_summary"
+ android:order="3" />
+ <!-- Slider -->
<com.android.settingslib.RestrictedPreference
android:key="importance_title"
android:title="@string/notification_importance_title"
- android:order="2" />
+ android:order="4"/>
<com.android.settings.notification.ImportanceSeekBarPreference
android:key="importance"
- android:order="3"/>
+ android:order="5"/>
<com.android.settings.applications.LayoutPreference
android:key="importance_reset_button"
android:layout="@layout/two_buttons_panel"
- android:order="4" />
+ android:order="6" />
<!-- Sensitive -->
<com.android.settingslib.RestrictedSwitchPreference
android:key="sensitive"
android:title="@string/app_notification_sensitive_title"
android:summary="@string/app_notification_sensitive_summary"
- android:order="5" />
+ android:order="7" />
<!-- Bypass DND -->
<com.android.settingslib.RestrictedSwitchPreference
android:key="bypass_dnd"
android:title="@string/app_notification_override_dnd_title"
android:summary="@string/app_notification_override_dnd_summary"
- android:order="6" />
+ android:order="8" />
</PreferenceScreen>
diff --git a/src/com/android/settings/notification/AppNotificationSettings.java b/src/com/android/settings/notification/AppNotificationSettings.java
index 8f30f59..f04cf2f 100644
--- a/src/com/android/settings/notification/AppNotificationSettings.java
+++ b/src/com/android/settings/notification/AppNotificationSettings.java
@@ -26,23 +26,15 @@
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 @@
(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 @@
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 @@
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 @@
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 a58edf7..895d38d 100644
--- a/src/com/android/settings/notification/NotificationSettingsBase.java
+++ b/src/com/android/settings/notification/NotificationSettingsBase.java
@@ -46,12 +46,15 @@
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 @@
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 @@
mSuspendedAppsAdmin = RestrictedLockUtils.checkIfApplicationIsSuspended(
mContext, mPkg, mUserId);
+ mShowSlider = Settings.Secure.getInt(getContentResolver(), TUNER_SETTING, 0) == 1;
}
@Override
@@ -143,54 +150,94 @@
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) {