use of androidx.preference.ListPreference in project android_packages_apps_Settings by omnirom.
the class AutofillLoggingLevelPreferenceController method updateOptions.
private void updateOptions() {
if (mPreference == null) {
// TODO: there should be a hook on AbstractPreferenceController where we could
// unregister mObserver and avoid this check
Log.v(TAG, "ignoring Settings update because UI is gone");
return;
}
final int level = Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.AUTOFILL_LOGGING_LEVEL, AutofillManager.DEFAULT_LOGGING_LEVEL);
final int index;
if (level == AutofillManager.FLAG_ADD_CLIENT_DEBUG) {
index = 1;
} else if (level == AutofillManager.FLAG_ADD_CLIENT_VERBOSE) {
index = 2;
} else {
index = 0;
}
final ListPreference listPreference = (ListPreference) mPreference;
listPreference.setValue(mListValues[index]);
listPreference.setSummary(mListSummaries[index]);
}
use of androidx.preference.ListPreference in project android_packages_apps_Settings by omnirom.
the class GraphicsDriverEnableForAllAppsPreferenceController method updateState.
@Override
public void updateState(Preference preference) {
final ListPreference listPref = (ListPreference) preference;
listPref.setVisible(isAvailable());
final int currentChoice = Settings.Global.getInt(mContentResolver, Settings.Global.UPDATABLE_DRIVER_ALL_APPS, UPDATABLE_DRIVER_DEFAULT);
if (currentChoice == UPDATABLE_DRIVER_PRODUCTION_ALL_APPS) {
listPref.setValue(mPreferenceProductionDriver);
listPref.setSummary(mPreferenceProductionDriver);
} else if (currentChoice == UPDATABLE_DRIVER_PRERELEASE_ALL_APPS) {
listPref.setValue(mPreferencePrereleaseDriver);
listPref.setSummary(mPreferencePrereleaseDriver);
} else {
listPref.setValue(mPreferenceDefault);
listPref.setSummary(mPreferenceDefault);
}
}
use of androidx.preference.ListPreference in project android_packages_apps_Settings by omnirom.
the class ProfileGpuRenderingPreferenceController method updateTrackFrameTimeOptions.
private void updateTrackFrameTimeOptions() {
final String value = SystemProperties.get(ThreadedRenderer.PROFILE_PROPERTY, "");
// default
int index = 0;
for (int i = 0; i < mListValues.length; i++) {
if (TextUtils.equals(value, mListValues[i])) {
index = i;
break;
}
}
final ListPreference listPreference = (ListPreference) mPreference;
listPreference.setValue(mListValues[index]);
listPreference.setSummary(mListSummaries[index]);
}
use of androidx.preference.ListPreference in project android_packages_apps_Settings by omnirom.
the class InactiveApps method init.
private void init() {
PreferenceGroup screen = getPreferenceScreen();
screen.removeAll();
screen.setOrderingAsAdded(false);
final Context context = getActivity();
final PackageManager pm = context.getPackageManager();
final String settingsPackage = context.getPackageName();
final boolean allowRestrictedBucket = Settings.Global.getInt(getContentResolver(), Settings.Global.ENABLE_RESTRICTED_BUCKET, Settings.Global.DEFAULT_ENABLE_RESTRICTED_BUCKET) == 1;
final CharSequence[] bucketNames = allowRestrictedBucket ? FULL_SETTABLE_BUCKETS_NAMES : REDUCED_SETTABLE_BUCKETS_NAMES;
final CharSequence[] bucketValues = allowRestrictedBucket ? FULL_SETTABLE_BUCKETS_VALUES : REDUCED_SETTABLE_BUCKETS_VALUES;
Intent launcherIntent = new Intent(Intent.ACTION_MAIN);
launcherIntent.addCategory(Intent.CATEGORY_LAUNCHER);
List<ResolveInfo> apps = pm.queryIntentActivities(launcherIntent, 0);
for (ResolveInfo app : apps) {
String packageName = app.activityInfo.applicationInfo.packageName;
ListPreference p = new ListPreference(getPrefContext());
p.setTitle(app.loadLabel(pm));
p.setIcon(app.loadIcon(pm));
p.setKey(packageName);
p.setEntries(bucketNames);
p.setEntryValues(bucketValues);
updateSummary(p);
// Don't allow Settings to change its own standby bucket.
if (TextUtils.equals(packageName, settingsPackage)) {
p.setEnabled(false);
}
p.setOnPreferenceChangeListener(this);
screen.addPreference(p);
}
}
use of androidx.preference.ListPreference in project android_packages_apps_Settings by omnirom.
the class HandsFreeProfileOutputPreferenceControllerTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
mAudioManager = mContext.getSystemService(AudioManager.class);
mShadowAudioManager = ShadowAudioManager.getShadow();
ShadowBluetoothUtils.sLocalBluetoothManager = mLocalManager;
mLocalBluetoothManager = Utils.getLocalBtManager(mContext);
when(mLocalBluetoothManager.getEventManager()).thenReturn(mBluetoothEventManager);
when(mLocalBluetoothManager.getProfileManager()).thenReturn(mLocalBluetoothProfileManager);
when(mLocalBluetoothProfileManager.getHeadsetProfile()).thenReturn(mHeadsetProfile);
when(mLocalBluetoothProfileManager.getHearingAidProfile()).thenReturn(mHearingAidProfile);
mBluetoothManager = new BluetoothManager(mContext);
mBluetoothAdapter = mBluetoothManager.getAdapter();
mBluetoothDevice = spy(mBluetoothAdapter.getRemoteDevice(TEST_DEVICE_ADDRESS_1));
when(mBluetoothDevice.getName()).thenReturn(TEST_DEVICE_NAME_1);
when(mBluetoothDevice.isConnected()).thenReturn(true);
mSecondBluetoothDevice = spy(mBluetoothAdapter.getRemoteDevice(TEST_DEVICE_ADDRESS_2));
when(mSecondBluetoothDevice.getName()).thenReturn(TEST_DEVICE_NAME_2);
when(mSecondBluetoothDevice.isConnected()).thenReturn(true);
mLeftBluetoothHapDevice = spy(mBluetoothAdapter.getRemoteDevice(TEST_DEVICE_ADDRESS_3));
when(mLeftBluetoothHapDevice.getName()).thenReturn(TEST_HAP_DEVICE_NAME_1);
when(mLeftBluetoothHapDevice.isConnected()).thenReturn(true);
mRightBluetoothHapDevice = spy(mBluetoothAdapter.getRemoteDevice(TEST_DEVICE_ADDRESS_4));
when(mRightBluetoothHapDevice.getName()).thenReturn(TEST_HAP_DEVICE_NAME_2);
when(mRightBluetoothHapDevice.isConnected()).thenReturn(true);
mController = new HandsFreeProfileOutputPreferenceController(mContext, TEST_KEY);
mScreen = spy(new PreferenceScreen(mContext, null));
mPreference = new ListPreference(mContext);
mProfileConnectedDevices = new ArrayList<>();
mHearingAidActiveDevices = new ArrayList<>(2);
when(mScreen.getPreferenceManager()).thenReturn(mock(PreferenceManager.class));
when(mScreen.getContext()).thenReturn(mContext);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
mScreen.addPreference(mPreference);
mController.displayPreference(mScreen);
mController.setCallback(mAudioSwitchPreferenceCallback);
}
Aggregations