Add the dialog when clicking on the diabled switch.

Bug: 302189945
Change-Id: I0bf7774b80a59c70a2ea1725e0adba522854adde
This commit is contained in:
Wa Gao
2023-11-08 06:09:27 +00:00
parent b75a956c10
commit 6b9e20d32d
5 changed files with 252 additions and 91 deletions

View File

@@ -34,17 +34,11 @@ import com.android.settingslib.search.SearchIndexable;
public class ContentProtectionPreferenceFragment extends DashboardFragment {
private static final String TAG = "ContentProtectionPreferenceFragment";
@VisibleForTesting
static final String KEY_WORK_PROFILE_SWITCH =
"content_protection_preference_user_consent_work_profile_switch";
// Required by @SearchIndexable to make the fragment and preferences to be indexed.
// Do not rename.
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider(R.layout.content_protection_preference_fragment);
private SwitchPreference mWorkProfileSwitch;
@Override
public void onAttach(Context context) {
super.onAttach(context);
@@ -53,14 +47,6 @@ public class ContentProtectionPreferenceFragment extends DashboardFragment {
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mWorkProfileSwitch = getPreferenceScreen().findPreference(KEY_WORK_PROFILE_SWITCH);
// If any work profile on the device, display the disable toggle unchecked
if (Utils.getManagedProfile(getContext().getSystemService(UserManager.class)) != null) {
mWorkProfileSwitch.setVisible(true);
mWorkProfileSwitch.setEnabled(false);
mWorkProfileSwitch.setChecked(false);
}
}
@Override