use of androidx.preference.ListPreference in project android_packages_apps_crDroidSettings by crdroidandroid.
the class VolumeSteps method updateVolumeStepPrefs.
private void updateVolumeStepPrefs(Preference pref, int steps) {
if (pref == null || !(pref instanceof ListPreference)) {
return;
}
final ListPreference listPref = (ListPreference) pref;
listPref.setSummary(String.valueOf(steps));
listPref.setValue(String.valueOf(steps));
}
use of androidx.preference.ListPreference in project collect by opendatakit.
the class PrefUtils method createListPref.
private static ListPreference createListPref(Context context, String key, String title, String[] labels, String[] values) {
ensurePrefHasValidValue(key, values);
ListPreference pref = new ListPreference(context);
pref.setKey(key);
pref.setPersistent(true);
pref.setTitle(title);
pref.setDialogTitle(title);
pref.setEntries(labels);
pref.setEntryValues(values);
pref.setSummary("%s");
return pref;
}
use of androidx.preference.ListPreference in project collect by opendatakit.
the class UserInterfacePreferencesFragment method initFontSizePref.
private void initFontSizePref() {
final ListPreference pref = findPreference(KEY_FONT_SIZE);
if (pref != null) {
pref.setSummary(pref.getEntry());
pref.setOnPreferenceChangeListener((preference, newValue) -> {
int index = ((ListPreference) preference).findIndexOfValue(newValue.toString());
CharSequence entry = ((ListPreference) preference).getEntries()[index];
preference.setSummary(entry);
return true;
});
}
}
use of androidx.preference.ListPreference in project collect by opendatakit.
the class UserInterfacePreferencesFragment method initLanguagePrefs.
private void initLanguagePrefs() {
final ListPreference pref = findPreference(KEY_APP_LANGUAGE);
if (pref != null) {
final LocaleHelper localeHelper = new LocaleHelper();
TreeMap<String, String> languageList = localeHelper.getEntryListValues();
ArrayList<String> entryValues = new ArrayList<>();
entryValues.add(0, "");
entryValues.addAll(languageList.values());
pref.setEntryValues(entryValues.toArray(new String[0]));
ArrayList<String> entries = new ArrayList<>();
entries.add(0, getActivity().getResources().getString(R.string.use_device_language));
entries.addAll(languageList.keySet());
pref.setEntries(entries.toArray(new String[0]));
if (pref.getValue() == null) {
// set Default value to "Use phone locale"
pref.setValueIndex(0);
}
pref.setSummary(pref.getEntry());
pref.setOnPreferenceChangeListener((preference, newValue) -> {
int index = ((ListPreference) preference).findIndexOfValue(newValue.toString());
String entry = (String) ((ListPreference) preference).getEntries()[index];
preference.setSummary(entry);
settingsProvider.getUnprotectedSettings().save(KEY_APP_LANGUAGE, newValue.toString());
startActivityAndCloseAllOthers(getActivity(), MainMenuActivity.class);
return true;
});
}
}
use of androidx.preference.ListPreference in project android_packages_apps_Settings by omnirom.
the class ZenRuleCallsPreferenceController method updateFromContactsValue.
private void updateFromContactsValue(Preference preference) {
if (mRule == null || mRule.getZenPolicy() == null) {
return;
}
ListPreference listPreference = (ListPreference) preference;
listPreference.setSummary(mBackend.getContactsCallsSummary(mRule.getZenPolicy()));
final String currentVal = ZenModeBackend.getKeyFromZenPolicySetting(mRule.getZenPolicy().getPriorityCallSenders());
listPreference.setValue(mListValues[getIndexOfSendersValue(currentVal)]);
}
Aggregations