Add the controller for the top switch.
Bug: 302189945 Change-Id: Ie43ac181e643a8b215ca830afc6ef670d91a5762
This commit is contained in:
@@ -16,26 +16,35 @@
|
||||
|
||||
package com.android.settings.security;
|
||||
|
||||
import android.content.Context;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserManager;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.SwitchPreference;
|
||||
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
@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);
|
||||
@@ -44,7 +53,14 @@ public class ContentProtectionPreferenceFragment extends DashboardFragment {
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
// TODO(b/304681048): Update the toggles' behavior according to user's profile
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user