Cannot have badge only channels.
Test: manual Change-Id: I564f6b7e076a10847bd7f48c59a0de095180ea92
This commit is contained in:
@@ -27,15 +27,6 @@
|
|||||||
settings:useAdditionalSummary="true"
|
settings:useAdditionalSummary="true"
|
||||||
settings:restrictedSwitchSummary="@string/enabled_by_admin" />
|
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 -->
|
<!-- Show badge -->
|
||||||
<com.android.settingslib.RestrictedSwitchPreference
|
<com.android.settingslib.RestrictedSwitchPreference
|
||||||
android:key="badge"
|
android:key="badge"
|
||||||
|
@@ -55,7 +55,6 @@ public class ChannelNotificationSettings extends NotificationSettingsBase {
|
|||||||
protected static final String KEY_LIGHTS = "lights";
|
protected static final String KEY_LIGHTS = "lights";
|
||||||
protected static final String KEY_VIBRATE = "vibrate";
|
protected static final String KEY_VIBRATE = "vibrate";
|
||||||
protected static final String KEY_RINGTONE = "ringtone";
|
protected static final String KEY_RINGTONE = "ringtone";
|
||||||
protected static final String KEY_SHOW = "show";
|
|
||||||
protected static final String KEY_BADGE = "badge";
|
protected static final String KEY_BADGE = "badge";
|
||||||
|
|
||||||
protected RestrictedSwitchPreference mLights;
|
protected RestrictedSwitchPreference mLights;
|
||||||
@@ -91,7 +90,6 @@ public class ChannelNotificationSettings extends NotificationSettingsBase {
|
|||||||
addPreferencesFromResource(R.xml.channel_notification_settings);
|
addPreferencesFromResource(R.xml.channel_notification_settings);
|
||||||
|
|
||||||
mBlock = (RestrictedSwitchPreference) getPreferenceScreen().findPreference(KEY_BLOCK);
|
mBlock = (RestrictedSwitchPreference) getPreferenceScreen().findPreference(KEY_BLOCK);
|
||||||
mShow = (RestrictedSwitchPreference) getPreferenceScreen().findPreference(KEY_SHOW);
|
|
||||||
mBadge = (RestrictedSwitchPreference) getPreferenceScreen().findPreference(KEY_BADGE);
|
mBadge = (RestrictedSwitchPreference) getPreferenceScreen().findPreference(KEY_BADGE);
|
||||||
mImportance = (RestrictedDropDownPreference) findPreference(KEY_IMPORTANCE);
|
mImportance = (RestrictedDropDownPreference) findPreference(KEY_IMPORTANCE);
|
||||||
mPriority =
|
mPriority =
|
||||||
@@ -141,7 +139,6 @@ public class ChannelNotificationSettings extends NotificationSettingsBase {
|
|||||||
mPriority.setDisabledByAdmin(mSuspendedAppsAdmin);
|
mPriority.setDisabledByAdmin(mSuspendedAppsAdmin);
|
||||||
mVisibilityOverride.setDisabledByAdmin(mSuspendedAppsAdmin);
|
mVisibilityOverride.setDisabledByAdmin(mSuspendedAppsAdmin);
|
||||||
mBlock.setDisabledByAdmin(mSuspendedAppsAdmin);
|
mBlock.setDisabledByAdmin(mSuspendedAppsAdmin);
|
||||||
mShow.setDisabledByAdmin(mSuspendedAppsAdmin);
|
|
||||||
mBadge.setDisabledByAdmin(mSuspendedAppsAdmin);
|
mBadge.setDisabledByAdmin(mSuspendedAppsAdmin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,26 +189,12 @@ public class ChannelNotificationSettings extends NotificationSettingsBase {
|
|||||||
|
|
||||||
protected void setupBlockAndImportance() {
|
protected void setupBlockAndImportance() {
|
||||||
mBlock.setDisabledByAdmin(mSuspendedAppsAdmin);
|
mBlock.setDisabledByAdmin(mSuspendedAppsAdmin);
|
||||||
mBlock.setChecked(!mChannel.isAllowed());
|
mBlock.setChecked(mChannel.getImportance() == NotificationManager.IMPORTANCE_NONE);
|
||||||
mBlock.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
mBlock.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
final boolean value = (Boolean) newValue;
|
final boolean value = (Boolean) newValue;
|
||||||
mChannel.setAllowed(!value);
|
int importance = value ? IMPORTANCE_NONE : IMPORTANCE_LOW;
|
||||||
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;
|
|
||||||
mImportance.setValue(String.valueOf(importance));
|
mImportance.setValue(String.valueOf(importance));
|
||||||
mChannel.setImportance(importance);
|
mChannel.setImportance(importance);
|
||||||
mChannel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE);
|
mChannel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE);
|
||||||
@@ -386,7 +369,8 @@ public class ChannelNotificationSettings extends NotificationSettingsBase {
|
|||||||
return lockscreenSecure;
|
return lockscreenSecure;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean checkCanBeVisible(int minImportanceVisible, int importance) {
|
protected boolean checkCanBeVisible(int minImportanceVisible) {
|
||||||
|
int importance = mChannel.getImportance();
|
||||||
if (importance == NotificationManager.IMPORTANCE_UNSPECIFIED) {
|
if (importance == NotificationManager.IMPORTANCE_UNSPECIFIED) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -420,23 +404,16 @@ public class ChannelNotificationSettings extends NotificationSettingsBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateDependents() {
|
private void updateDependents() {
|
||||||
boolean allowed = mChannel.isAllowed();
|
setVisible(mBadge, checkCanBeVisible(NotificationManager.IMPORTANCE_MIN));
|
||||||
int importance = mChannel.getImportance();
|
setVisible(mImportance, checkCanBeVisible(NotificationManager.IMPORTANCE_MIN));
|
||||||
setVisible(mShow, allowed);
|
setVisible(mLights, checkCanBeVisible(
|
||||||
setVisible(mBadge, allowed);
|
NotificationManager.IMPORTANCE_LOW) && canPulseLight());
|
||||||
setVisible(mImportance, allowed && importance != NotificationManager.IMPORTANCE_NONE);
|
setVisible(mVibrate, checkCanBeVisible(NotificationManager.IMPORTANCE_DEFAULT));
|
||||||
setVisible(mLights, allowed && checkCanBeVisible(
|
setVisible(mRingtone, checkCanBeVisible(NotificationManager.IMPORTANCE_DEFAULT));
|
||||||
NotificationManager.IMPORTANCE_LOW, importance) && canPulseLight());
|
setVisible(mPriority, checkCanBeVisible(NotificationManager.IMPORTANCE_DEFAULT)
|
||||||
setVisible(mVibrate, allowed
|
|| (checkCanBeVisible(NotificationManager.IMPORTANCE_LOW)
|
||||||
&& checkCanBeVisible(NotificationManager.IMPORTANCE_DEFAULT, importance));
|
&& mDndVisualEffectsSuppressed));
|
||||||
setVisible(mRingtone, allowed && checkCanBeVisible(
|
setVisible(mVisibilityOverride, checkCanBeVisible(NotificationManager.IMPORTANCE_MIN)
|
||||||
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)
|
|
||||||
&& isLockScreenSecure());
|
&& isLockScreenSecure());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -66,7 +66,6 @@ abstract public class NotificationSettingsBase extends SettingsPreferenceFragmen
|
|||||||
protected String mPkg;
|
protected String mPkg;
|
||||||
protected PackageInfo mPkgInfo;
|
protected PackageInfo mPkgInfo;
|
||||||
protected RestrictedSwitchPreference mBlock;
|
protected RestrictedSwitchPreference mBlock;
|
||||||
protected RestrictedSwitchPreference mShow;
|
|
||||||
protected RestrictedSwitchPreference mBadge;
|
protected RestrictedSwitchPreference mBadge;
|
||||||
protected EnforcedAdmin mSuspendedAppsAdmin;
|
protected EnforcedAdmin mSuspendedAppsAdmin;
|
||||||
protected boolean mDndVisualEffectsSuppressed;
|
protected boolean mDndVisualEffectsSuppressed;
|
||||||
|
Reference in New Issue
Block a user