SettingsMainSwitchPreference should display the restricted icon

if it is restricted.

- Use the RestrictedPreferenceHelper to check the restricted state.

Fix: 179245126
Test: rebotest and see the UI
Change-Id: I3c0e3bd0f3596d6fa548b6f8f10e4d12e7e50c9a
This commit is contained in:
Stanley Wang
2021-05-29 20:27:38 +08:00
parent 84084e471c
commit 9b6ead8de7
5 changed files with 90 additions and 12 deletions

View File

@@ -16,6 +16,8 @@
package com.android.settings.widget;
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.util.AttributeSet;
@@ -47,7 +49,7 @@ public class SettingsMainSwitchBar extends MainSwitchBar {
}
private ImageView mRestrictedIcon;
private RestrictedLockUtils.EnforcedAdmin mEnforcedAdmin;
private EnforcedAdmin mEnforcedAdmin;
private boolean mDisabledByAdmin;
private final MetricsFeatureProvider mMetricsFeatureProvider;
@@ -87,7 +89,7 @@ public class SettingsMainSwitchBar extends MainSwitchBar {
* 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) {
public void setDisabledByAdmin(EnforcedAdmin admin) {
mEnforcedAdmin = admin;
if (admin != null) {
super.setEnabled(true);