From 5166e3939d285ef6624ac8acf49bfa07a37734d6 Mon Sep 17 00:00:00 2001 From: Julia Reynolds Date: Tue, 16 Mar 2021 14:55:18 -0400 Subject: [PATCH] Allow SettingsMainSwitchBars to be disabled Test: manual, looking at notification settings Fixes: 182859292 Change-Id: I06db2a0984b0dcbf71a69fc8f58e54b4670652a8 --- src/com/android/settings/widget/SettingsMainSwitchBar.java | 7 +++---- .../settings/widget/SettingsMainSwitchPreference.java | 1 + 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/com/android/settings/widget/SettingsMainSwitchBar.java b/src/com/android/settings/widget/SettingsMainSwitchBar.java index 733be0a6f6a..ce2dde59f19 100644 --- a/src/com/android/settings/widget/SettingsMainSwitchBar.java +++ b/src/com/android/settings/widget/SettingsMainSwitchBar.java @@ -84,9 +84,8 @@ public class SettingsMainSwitchBar extends MainSwitchBar { } /** - * If admin is not null, disables the text and switch but keeps the view clickable. - * Otherwise, calls setEnabled which will enables the entire view including - * the text and switch. + * If admin is not null, disables the text and switch but keeps the view clickable (unless the + * switch is disabled for other reasons). Otherwise, calls setEnabled. */ public void setDisabledByAdmin(RestrictedLockUtils.EnforcedAdmin admin) { mEnforcedAdmin = admin; @@ -101,7 +100,7 @@ public class SettingsMainSwitchBar extends MainSwitchBar { mDisabledByAdmin = false; mSwitch.setVisibility(View.VISIBLE); mRestrictedIcon.setVisibility(View.GONE); - setEnabled(true); + setEnabled(isEnabled()); } } diff --git a/src/com/android/settings/widget/SettingsMainSwitchPreference.java b/src/com/android/settings/widget/SettingsMainSwitchPreference.java index 80a0021e44e..f627e31cc2d 100644 --- a/src/com/android/settings/widget/SettingsMainSwitchPreference.java +++ b/src/com/android/settings/widget/SettingsMainSwitchPreference.java @@ -186,6 +186,7 @@ public class SettingsMainSwitchPreference extends TwoStatePreference { * Enable or disable the text and switch. */ public void setSwitchBarEnabled(boolean enabled) { + setEnabled(enabled); if (mMainSwitchBar != null) { mMainSwitchBar.setEnabled(enabled); }