Search in sources :

Example 51 with ListPreference

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));
}
Also used : ListPreference(androidx.preference.ListPreference)

Example 52 with ListPreference

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;
}
Also used : ListPreference(androidx.preference.ListPreference)

Example 53 with ListPreference

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;
        });
    }
}
Also used : ListPreference(androidx.preference.ListPreference)

Example 54 with ListPreference

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;
        });
    }
}
Also used : LocaleHelper(org.odk.collect.android.utilities.LocaleHelper) ArrayList(java.util.ArrayList) ListPreference(androidx.preference.ListPreference)

Example 55 with ListPreference

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)]);
}
Also used : ListPreference(androidx.preference.ListPreference)

Aggregations

ListPreference (androidx.preference.ListPreference)170 Test (org.junit.Test)24 Before (org.junit.Before)23 Preference (androidx.preference.Preference)20 EditTextPreference (androidx.preference.EditTextPreference)10 PreferenceScreen (androidx.preference.PreferenceScreen)10 SwitchPreference (androidx.preference.SwitchPreference)9 Context (android.content.Context)8 ContentResolver (android.content.ContentResolver)7 Intent (android.content.Intent)7 PersistableBundle (android.os.PersistableBundle)6 MultiSelectListPreference (androidx.preference.MultiSelectListPreference)6 Resources (android.content.res.Resources)5 Bundle (android.os.Bundle)5 RemoteException (android.os.RemoteException)5 RestrictionEntry (android.content.RestrictionEntry)4 OverlayInfo (android.content.om.OverlayInfo)4 ApplicationInfo (android.content.pm.ApplicationInfo)4 PackageInfo (android.content.pm.PackageInfo)4 WifiConfiguration (android.net.wifi.WifiConfiguration)4