Merge "Properly show/hide advanced settings" into oc-mr1-dev am: 12c9d6d65a

am: fa3fa3483e

Change-Id: I9cab11035c64975b45e1c3d99bd707a07b6c693e
This commit is contained in:
Julia Reynolds
2017-09-06 18:42:36 +00:00
committed by android-build-merger
2 changed files with 12 additions and 8 deletions

View File

@@ -365,17 +365,17 @@ public class ChannelNotificationSettings extends NotificationSettingsBase {
} else {
setVisible(mAdvanced, checkCanBeVisible(NotificationManager.IMPORTANCE_MIN));
setVisible(mImportance, checkCanBeVisible(NotificationManager.IMPORTANCE_MIN));
setVisible(mLights, checkCanBeVisible(
setVisible(mAdvanced, mLights, checkCanBeVisible(
NotificationManager.IMPORTANCE_DEFAULT) && canPulseLight());
setVisible(mVibrate, checkCanBeVisible(NotificationManager.IMPORTANCE_DEFAULT));
setVisible(mRingtone, checkCanBeVisible(NotificationManager.IMPORTANCE_DEFAULT));
}
setVisible(mBadge, checkCanBeVisible(NotificationManager.IMPORTANCE_MIN));
setVisible(mPriority, checkCanBeVisible(NotificationManager.IMPORTANCE_DEFAULT)
setVisible(mAdvanced, mBadge, checkCanBeVisible(NotificationManager.IMPORTANCE_MIN));
setVisible(mAdvanced, mPriority, checkCanBeVisible(NotificationManager.IMPORTANCE_DEFAULT)
|| (checkCanBeVisible(NotificationManager.IMPORTANCE_LOW)
&& mDndVisualEffectsSuppressed));
setVisible(mVisibilityOverride, checkCanBeVisible(NotificationManager.IMPORTANCE_LOW)
&& isLockScreenSecure());
setVisible(mAdvanced, mVisibilityOverride, isLockScreenSecure()
&&checkCanBeVisible(NotificationManager.IMPORTANCE_LOW));
setVisible(mBlockedDesc, mChannel.getImportance() == IMPORTANCE_NONE);
if (mAppLink != null) {
setVisible(mAppLink, checkCanBeVisible(NotificationManager.IMPORTANCE_MIN));

View File

@@ -205,12 +205,16 @@ abstract public class NotificationSettingsBase extends SettingsPreferenceFragmen
}
protected void setVisible(Preference p, boolean visible) {
final boolean isVisible = getPreferenceScreen().findPreference(p.getKey()) != null;
setVisible(getPreferenceScreen(), p, visible);
}
protected void setVisible(PreferenceGroup parent, Preference p, boolean visible) {
final boolean isVisible = parent.findPreference(p.getKey()) != null;
if (isVisible == visible) return;
if (visible) {
getPreferenceScreen().addPreference(p);
parent.addPreference(p);
} else {
getPreferenceScreen().removePreference(p);
parent.removePreference(p);
}
}