Loading res/values/strings.xml +8 −2 Original line number Diff line number Diff line Loading @@ -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> Loading res/xml/app_notification_settings.xml +18 −5 Original line number Diff line number Diff line Loading @@ -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> src/com/android/settings/notification/AppNotificationSettings.java +10 −12 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); Loading @@ -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); Loading @@ -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); } Loading @@ -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() { Loading src/com/android/settings/notification/NotificationSettingsBase.java +89 −42 Original line number Diff line number Diff line Loading @@ -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(); Loading @@ -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) { Loading Loading @@ -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 Loading @@ -143,9 +150,18 @@ 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) { 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) { Loading Loading @@ -191,6 +207,37 @@ abstract public class NotificationSettingsBase extends SettingsPreferenceFragmen } }); 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) { Loading Loading
res/values/strings.xml +8 −2 Original line number Diff line number Diff line Loading @@ -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> Loading
res/xml/app_notification_settings.xml +18 −5 Original line number Diff line number Diff line Loading @@ -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>
src/com/android/settings/notification/AppNotificationSettings.java +10 −12 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); Loading @@ -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); Loading @@ -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); } Loading @@ -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() { Loading
src/com/android/settings/notification/NotificationSettingsBase.java +89 −42 Original line number Diff line number Diff line Loading @@ -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(); Loading @@ -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) { Loading Loading @@ -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 Loading @@ -143,9 +150,18 @@ 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) { 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) { Loading Loading @@ -191,6 +207,37 @@ abstract public class NotificationSettingsBase extends SettingsPreferenceFragmen } }); 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) { Loading