Replace slider with switches; move slider to tuner.
Bug: 22451710 Change-Id: I86a57479757b3c7a43a789b0b3d7a81afb6d0cf9
This commit is contained in:
@@ -5953,14 +5953,20 @@
|
|||||||
<string name="notification_importance_default">Normal: Silently show these notifications</string>
|
<string name="notification_importance_default">Normal: Silently show these notifications</string>
|
||||||
|
|
||||||
<!-- [CHAR LIMIT=100] Notification Importance slider: high importance level description -->
|
<!-- [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 -->
|
<!-- [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 -->
|
<!-- [CHAR LIMIT=60] Notification importance reset button -->
|
||||||
<string name="importance_reset">Reset</string>
|
<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 -->
|
<!-- Default Apps > Default notification assistant -->
|
||||||
<string name="default_notification_assistant">Notification assistant</string>
|
<string name="default_notification_assistant">Notification assistant</string>
|
||||||
|
|
||||||
|
@@ -19,31 +19,44 @@
|
|||||||
android:key="app_notification_settings">
|
android:key="app_notification_settings">
|
||||||
|
|
||||||
<!-- Importance -->
|
<!-- 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
|
<com.android.settingslib.RestrictedPreference
|
||||||
android:key="importance_title"
|
android:key="importance_title"
|
||||||
android:title="@string/notification_importance_title"
|
android:title="@string/notification_importance_title"
|
||||||
android:order="2" />
|
android:order="4"/>
|
||||||
<com.android.settings.notification.ImportanceSeekBarPreference
|
<com.android.settings.notification.ImportanceSeekBarPreference
|
||||||
android:key="importance"
|
android:key="importance"
|
||||||
android:order="3"/>
|
android:order="5"/>
|
||||||
|
|
||||||
<com.android.settings.applications.LayoutPreference
|
<com.android.settings.applications.LayoutPreference
|
||||||
android:key="importance_reset_button"
|
android:key="importance_reset_button"
|
||||||
android:layout="@layout/two_buttons_panel"
|
android:layout="@layout/two_buttons_panel"
|
||||||
android:order="4" />
|
android:order="6" />
|
||||||
|
|
||||||
<!-- Sensitive -->
|
<!-- Sensitive -->
|
||||||
<com.android.settingslib.RestrictedSwitchPreference
|
<com.android.settingslib.RestrictedSwitchPreference
|
||||||
android:key="sensitive"
|
android:key="sensitive"
|
||||||
android:title="@string/app_notification_sensitive_title"
|
android:title="@string/app_notification_sensitive_title"
|
||||||
android:summary="@string/app_notification_sensitive_summary"
|
android:summary="@string/app_notification_sensitive_summary"
|
||||||
android:order="5" />
|
android:order="7" />
|
||||||
|
|
||||||
<!-- Bypass DND -->
|
<!-- Bypass DND -->
|
||||||
<com.android.settingslib.RestrictedSwitchPreference
|
<com.android.settingslib.RestrictedSwitchPreference
|
||||||
android:key="bypass_dnd"
|
android:key="bypass_dnd"
|
||||||
android:title="@string/app_notification_override_dnd_title"
|
android:title="@string/app_notification_override_dnd_title"
|
||||||
android:summary="@string/app_notification_override_dnd_summary"
|
android:summary="@string/app_notification_override_dnd_summary"
|
||||||
android:order="6" />
|
android:order="8" />
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
@@ -26,23 +26,15 @@ import android.os.Bundle;
|
|||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.service.notification.NotificationListenerService.Ranking;
|
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.ArrayMap;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.android.internal.logging.MetricsLogger;
|
|
||||||
import com.android.internal.logging.MetricsProto.MetricsEvent;
|
import com.android.internal.logging.MetricsProto.MetricsEvent;
|
||||||
import com.android.internal.widget.LockPatternUtils;
|
import com.android.internal.widget.LockPatternUtils;
|
||||||
import com.android.settings.AppHeader;
|
import com.android.settings.AppHeader;
|
||||||
import com.android.settings.R;
|
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.applications.LayoutPreference;
|
||||||
import com.android.settings.notification.NotificationBackend.AppRow;
|
import com.android.settings.notification.NotificationBackend.AppRow;
|
||||||
import com.android.settingslib.RestrictedLockUtils;
|
|
||||||
import com.android.settingslib.RestrictedSwitchPreference;
|
import com.android.settingslib.RestrictedSwitchPreference;
|
||||||
import com.android.settingslib.RestrictedPreference;
|
import com.android.settingslib.RestrictedPreference;
|
||||||
|
|
||||||
@@ -86,6 +78,8 @@ public class AppNotificationSettings extends NotificationSettingsBase {
|
|||||||
(RestrictedSwitchPreference) getPreferenceScreen().findPreference(KEY_BYPASS_DND);
|
(RestrictedSwitchPreference) getPreferenceScreen().findPreference(KEY_BYPASS_DND);
|
||||||
mSensitive =
|
mSensitive =
|
||||||
(RestrictedSwitchPreference) getPreferenceScreen().findPreference(KEY_SENSITIVE);
|
(RestrictedSwitchPreference) getPreferenceScreen().findPreference(KEY_SENSITIVE);
|
||||||
|
mBlock = (RestrictedSwitchPreference) getPreferenceScreen().findPreference(KEY_BLOCK);
|
||||||
|
mSilent = (RestrictedSwitchPreference) getPreferenceScreen().findPreference(KEY_SILENT);
|
||||||
|
|
||||||
mAppRow = mBackend.loadAppRow(mPm, mPkgInfo);
|
mAppRow = mBackend.loadAppRow(mPm, mPkgInfo);
|
||||||
|
|
||||||
@@ -98,7 +92,7 @@ public class AppNotificationSettings extends NotificationSettingsBase {
|
|||||||
rows.put(mAppRow.pkg, mAppRow);
|
rows.put(mAppRow.pkg, mAppRow);
|
||||||
collectConfigActivities(rows);
|
collectConfigActivities(rows);
|
||||||
|
|
||||||
setupImportancePrefs(mAppRow.systemApp, mAppRow.appImportance);
|
setupImportancePrefs(mAppRow.systemApp, mAppRow.appImportance, mAppRow.banned);
|
||||||
setupPriorityPref(mAppRow.appBypassDnd);
|
setupPriorityPref(mAppRow.appBypassDnd);
|
||||||
setupSensitivePref(mAppRow.appSensitive);
|
setupSensitivePref(mAppRow.appSensitive);
|
||||||
updateDependents(mAppRow.appImportance);
|
updateDependents(mAppRow.appImportance);
|
||||||
@@ -111,9 +105,13 @@ public class AppNotificationSettings extends NotificationSettingsBase {
|
|||||||
final boolean lockscreenNotificationsEnabled = getLockscreenNotificationsEnabled();
|
final boolean lockscreenNotificationsEnabled = getLockscreenNotificationsEnabled();
|
||||||
final boolean allowPrivate = getLockscreenAllowPrivateNotifications();
|
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);
|
&& !mDndVisualEffectsSuppressed);
|
||||||
setVisible(mSensitive, checkCanBeVisible(Ranking.IMPORTANCE_LOW, importance)
|
setVisible(mSensitive, checkCanBeVisible(Ranking.IMPORTANCE_HIGH, importance)
|
||||||
&& lockscreenSecure && lockscreenNotificationsEnabled && allowPrivate);
|
&& lockscreenSecure && lockscreenNotificationsEnabled && allowPrivate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,7 +119,7 @@ public class AppNotificationSettings extends NotificationSettingsBase {
|
|||||||
if (importance == Ranking.IMPORTANCE_UNSPECIFIED) {
|
if (importance == Ranking.IMPORTANCE_UNSPECIFIED) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return importance > minImportanceVisible;
|
return importance >= minImportanceVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean getLockscreenNotificationsEnabled() {
|
private boolean getLockscreenNotificationsEnabled() {
|
||||||
|
@@ -46,12 +46,15 @@ import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
|
|||||||
abstract public class NotificationSettingsBase extends SettingsPreferenceFragment {
|
abstract public class NotificationSettingsBase extends SettingsPreferenceFragment {
|
||||||
private static final String TAG = "NotifiSettingsBase";
|
private static final String TAG = "NotifiSettingsBase";
|
||||||
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
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_BYPASS_DND = "bypass_dnd";
|
||||||
protected static final String KEY_SENSITIVE = "sensitive";
|
protected static final String KEY_SENSITIVE = "sensitive";
|
||||||
protected static final String KEY_IMPORTANCE = "importance";
|
protected static final String KEY_IMPORTANCE = "importance";
|
||||||
protected static final String KEY_IMPORTANCE_TITLE = "importance_title";
|
protected static final String KEY_IMPORTANCE_TITLE = "importance_title";
|
||||||
protected static final String KEY_IMPORTANCE_RESET = "importance_reset_button";
|
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 PackageManager mPm;
|
||||||
protected final NotificationBackend mBackend = new NotificationBackend();
|
protected final NotificationBackend mBackend = new NotificationBackend();
|
||||||
@@ -66,7 +69,10 @@ abstract public class NotificationSettingsBase extends SettingsPreferenceFragmen
|
|||||||
protected LayoutPreference mImportanceReset;
|
protected LayoutPreference mImportanceReset;
|
||||||
protected RestrictedSwitchPreference mPriority;
|
protected RestrictedSwitchPreference mPriority;
|
||||||
protected RestrictedSwitchPreference mSensitive;
|
protected RestrictedSwitchPreference mSensitive;
|
||||||
|
protected RestrictedSwitchPreference mBlock;
|
||||||
|
protected RestrictedSwitchPreference mSilent;
|
||||||
protected EnforcedAdmin mSuspendedAppsAdmin;
|
protected EnforcedAdmin mSuspendedAppsAdmin;
|
||||||
|
protected boolean mShowSlider = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivityCreated(Bundle savedInstanceState) {
|
public void onActivityCreated(Bundle savedInstanceState) {
|
||||||
@@ -119,6 +125,7 @@ abstract public class NotificationSettingsBase extends SettingsPreferenceFragmen
|
|||||||
|
|
||||||
mSuspendedAppsAdmin = RestrictedLockUtils.checkIfApplicationIsSuspended(
|
mSuspendedAppsAdmin = RestrictedLockUtils.checkIfApplicationIsSuspended(
|
||||||
mContext, mPkg, mUserId);
|
mContext, mPkg, mUserId);
|
||||||
|
mShowSlider = Settings.Secure.getInt(getContentResolver(), TUNER_SETTING, 0) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -143,54 +150,94 @@ abstract public class NotificationSettingsBase extends SettingsPreferenceFragmen
|
|||||||
if (mImportanceTitle != null) {
|
if (mImportanceTitle != null) {
|
||||||
mImportanceTitle.setDisabledByAdmin(mSuspendedAppsAdmin);
|
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) {
|
||||||
mImportance.setDisabledByAdmin(mSuspendedAppsAdmin);
|
if (mShowSlider) {
|
||||||
mImportanceTitle.setDisabledByAdmin(mSuspendedAppsAdmin);
|
setVisible(mBlock, false);
|
||||||
if (importance == Ranking.IMPORTANCE_UNSPECIFIED) {
|
setVisible(mSilent, false);
|
||||||
mImportance.setVisible(false);
|
mImportance.setDisabledByAdmin(mSuspendedAppsAdmin);
|
||||||
mImportanceReset.setVisible(false);
|
mImportanceTitle.setDisabledByAdmin(mSuspendedAppsAdmin);
|
||||||
mImportanceTitle.setOnPreferenceClickListener(showEditableImportance);
|
if (importance == Ranking.IMPORTANCE_UNSPECIFIED) {
|
||||||
} 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);
|
|
||||||
mImportance.setVisible(false);
|
mImportance.setVisible(false);
|
||||||
|
mImportanceReset.setVisible(false);
|
||||||
mImportanceTitle.setOnPreferenceClickListener(showEditableImportance);
|
mImportanceTitle.setOnPreferenceClickListener(showEditableImportance);
|
||||||
mImportanceTitle.setSummary(getProgressSummary(Ranking.IMPORTANCE_UNSPECIFIED));
|
} else {
|
||||||
updateDependents(Ranking.IMPORTANCE_UNSPECIFIED);
|
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) {
|
private String getProgressSummary(int progress) {
|
||||||
|
Reference in New Issue
Block a user