Cannot have badge only channels.
Test: manual
Change-Id: I564f6b7e076a10847bd7f48c59a0de095180ea92
diff --git a/res/xml/channel_notification_settings.xml b/res/xml/channel_notification_settings.xml
index c2d1f73..e1d6d55 100644
--- a/res/xml/channel_notification_settings.xml
+++ b/res/xml/channel_notification_settings.xml
@@ -27,15 +27,6 @@
settings:useAdditionalSummary="true"
settings:restrictedSwitchSummary="@string/enabled_by_admin" />
- <!-- Show notification -->
- <com.android.settingslib.RestrictedSwitchPreference
- android:key="show"
- android:title="@string/notification_content_block_title"
- android:summary="@string/notification_content_block_summary"
- android:order="2"
- settings:useAdditionalSummary="true"
- settings:restrictedSwitchSummary="@string/enabled_by_admin" />
-
<!-- Show badge -->
<com.android.settingslib.RestrictedSwitchPreference
android:key="badge"
diff --git a/src/com/android/settings/notification/ChannelNotificationSettings.java b/src/com/android/settings/notification/ChannelNotificationSettings.java
index 77bf6be..e73feb5 100644
--- a/src/com/android/settings/notification/ChannelNotificationSettings.java
+++ b/src/com/android/settings/notification/ChannelNotificationSettings.java
@@ -55,7 +55,6 @@
protected static final String KEY_LIGHTS = "lights";
protected static final String KEY_VIBRATE = "vibrate";
protected static final String KEY_RINGTONE = "ringtone";
- protected static final String KEY_SHOW = "show";
protected static final String KEY_BADGE = "badge";
protected RestrictedSwitchPreference mLights;
@@ -91,7 +90,6 @@
addPreferencesFromResource(R.xml.channel_notification_settings);
mBlock = (RestrictedSwitchPreference) getPreferenceScreen().findPreference(KEY_BLOCK);
- mShow = (RestrictedSwitchPreference) getPreferenceScreen().findPreference(KEY_SHOW);
mBadge = (RestrictedSwitchPreference) getPreferenceScreen().findPreference(KEY_BADGE);
mImportance = (RestrictedDropDownPreference) findPreference(KEY_IMPORTANCE);
mPriority =
@@ -141,7 +139,6 @@
mPriority.setDisabledByAdmin(mSuspendedAppsAdmin);
mVisibilityOverride.setDisabledByAdmin(mSuspendedAppsAdmin);
mBlock.setDisabledByAdmin(mSuspendedAppsAdmin);
- mShow.setDisabledByAdmin(mSuspendedAppsAdmin);
mBadge.setDisabledByAdmin(mSuspendedAppsAdmin);
}
@@ -192,26 +189,12 @@
protected void setupBlockAndImportance() {
mBlock.setDisabledByAdmin(mSuspendedAppsAdmin);
- mBlock.setChecked(!mChannel.isAllowed());
+ mBlock.setChecked(mChannel.getImportance() == NotificationManager.IMPORTANCE_NONE);
mBlock.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean value = (Boolean) newValue;
- mChannel.setAllowed(!value);
- mChannel.lockFields(NotificationChannel.USER_LOCKED_ALLOWED);
- mBackend.updateChannel(mPkg, mUid, mChannel);
- updateDependents();
- return true;
- }
- });
-
- mShow.setDisabledByAdmin(mSuspendedAppsAdmin);
- mShow.setChecked(mChannel.getImportance() != NotificationManager.IMPORTANCE_NONE);
- mShow.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
- @Override
- public boolean onPreferenceChange(Preference preference, Object newValue) {
- final boolean value = (Boolean) newValue;
- int importance = value ? IMPORTANCE_LOW : IMPORTANCE_NONE;
+ int importance = value ? IMPORTANCE_NONE : IMPORTANCE_LOW;
mImportance.setValue(String.valueOf(importance));
mChannel.setImportance(importance);
mChannel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE);
@@ -386,7 +369,8 @@
return lockscreenSecure;
}
- protected boolean checkCanBeVisible(int minImportanceVisible, int importance) {
+ protected boolean checkCanBeVisible(int minImportanceVisible) {
+ int importance = mChannel.getImportance();
if (importance == NotificationManager.IMPORTANCE_UNSPECIFIED) {
return true;
}
@@ -420,23 +404,16 @@
}
private void updateDependents() {
- boolean allowed = mChannel.isAllowed();
- int importance = mChannel.getImportance();
- setVisible(mShow, allowed);
- setVisible(mBadge, allowed);
- setVisible(mImportance, allowed && importance != NotificationManager.IMPORTANCE_NONE);
- setVisible(mLights, allowed && checkCanBeVisible(
- NotificationManager.IMPORTANCE_LOW, importance) && canPulseLight());
- setVisible(mVibrate, allowed
- && checkCanBeVisible(NotificationManager.IMPORTANCE_DEFAULT, importance));
- setVisible(mRingtone, allowed && checkCanBeVisible(
- NotificationManager.IMPORTANCE_DEFAULT, importance));
- setVisible(mPriority, allowed
- && (checkCanBeVisible(NotificationManager.IMPORTANCE_DEFAULT, importance)
- || (checkCanBeVisible(NotificationManager.IMPORTANCE_LOW, importance)
- && mDndVisualEffectsSuppressed)));
- setVisible(mVisibilityOverride, allowed
- && checkCanBeVisible(NotificationManager.IMPORTANCE_MIN, importance)
+ setVisible(mBadge, checkCanBeVisible(NotificationManager.IMPORTANCE_MIN));
+ setVisible(mImportance, checkCanBeVisible(NotificationManager.IMPORTANCE_MIN));
+ setVisible(mLights, checkCanBeVisible(
+ NotificationManager.IMPORTANCE_LOW) && canPulseLight());
+ setVisible(mVibrate, checkCanBeVisible(NotificationManager.IMPORTANCE_DEFAULT));
+ setVisible(mRingtone, checkCanBeVisible(NotificationManager.IMPORTANCE_DEFAULT));
+ setVisible(mPriority, checkCanBeVisible(NotificationManager.IMPORTANCE_DEFAULT)
+ || (checkCanBeVisible(NotificationManager.IMPORTANCE_LOW)
+ && mDndVisualEffectsSuppressed));
+ setVisible(mVisibilityOverride, checkCanBeVisible(NotificationManager.IMPORTANCE_MIN)
&& isLockScreenSecure());
}
}
diff --git a/src/com/android/settings/notification/NotificationSettingsBase.java b/src/com/android/settings/notification/NotificationSettingsBase.java
index 046c5e6..f3e4390 100644
--- a/src/com/android/settings/notification/NotificationSettingsBase.java
+++ b/src/com/android/settings/notification/NotificationSettingsBase.java
@@ -66,7 +66,6 @@
protected String mPkg;
protected PackageInfo mPkgInfo;
protected RestrictedSwitchPreference mBlock;
- protected RestrictedSwitchPreference mShow;
protected RestrictedSwitchPreference mBadge;
protected EnforcedAdmin mSuspendedAppsAdmin;
protected boolean mDndVisualEffectsSuppressed;