Search in sources :

Example 6 with ListPreference

use of android.preference.ListPreference in project Sudoku by mrbananasoup.

the class SettingsActivity method updatePreference.

private void updatePreference(Preference preference, String key) {
    if (preference == null)
        return;
    if (preference instanceof ListPreference) {
        ListPreference listPreference = (ListPreference) preference;
        listPreference.setSummary(listPreference.getEntry());
        return;
    }
    SharedPreferences sharedPrefs = getPreferenceManager().getSharedPreferences();
    preference.setSummary(sharedPrefs.getString(key, "Default"));
}
Also used : SharedPreferences(android.content.SharedPreferences) ListPreference(android.preference.ListPreference)

Example 7 with ListPreference

use of android.preference.ListPreference in project collect by opendatakit.

the class ServerPreferences method initProtocolPrefs.

private void initProtocolPrefs() {
    ListPreference protocolPref = (ListPreference) findPreference(KEY_PROTOCOL);
    protocolPref.setSummary(protocolPref.getEntry());
    protocolPref.setOnPreferenceChangeListener(createChangeListener());
    addPreferencesResource(protocolPref.getValue());
}
Also used : ListPreference(android.preference.ListPreference)

Example 8 with ListPreference

use of android.preference.ListPreference in project collect by opendatakit.

the class UserInterfacePreferences method initMapPrefs.

private void initMapPrefs() {
    final ListPreference mapSdk = (ListPreference) findPreference(KEY_MAP_SDK);
    final ListPreference mapBasemap = (ListPreference) findPreference(KEY_MAP_BASEMAP);
    if (mapSdk == null || mapBasemap == null) {
        return;
    }
    mapSdk.setSummary(mapSdk.getEntry());
    mapSdk.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {

        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            int index = ((ListPreference) preference).findIndexOfValue(newValue.toString());
            if (index == 0) {
                mapBasemap.setEntryValues(R.array.map_google_basemap_selector_entry_values);
                mapBasemap.setEntries(R.array.map_google_basemap_selector_entries);
                mapBasemap.setValue(GOOGLE_MAPS_BASEMAP_DEFAULT);
                mapBasemap.setSummary(mapBasemap.getEntry());
            } else {
                // Else its OSM Maps
                mapBasemap.setEntryValues(R.array.map_osm_basemap_selector_entry_values);
                mapBasemap.setEntries(R.array.map_osm_basemap_selector_entries);
                mapBasemap.setValue(OSM_MAPS_BASEMAP_DEFAULT);
                mapBasemap.setSummary(mapBasemap.getEntry());
            }
            String entry = (String) ((ListPreference) preference).getEntries()[index];
            preference.setSummary(entry);
            return true;
        }
    });
    if (mapSdk.getValue().equals(OSM_BASEMAP_KEY)) {
        mapBasemap.setEntryValues(R.array.map_osm_basemap_selector_entry_values);
        mapBasemap.setEntries(R.array.map_osm_basemap_selector_entries);
    } else {
        mapBasemap.setEntryValues(R.array.map_google_basemap_selector_entry_values);
        mapBasemap.setEntries(R.array.map_google_basemap_selector_entries);
    }
    mapBasemap.setSummary(mapBasemap.getEntry());
    mapBasemap.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {

        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            int index = ((ListPreference) preference).findIndexOfValue(newValue.toString());
            String entry = (String) ((ListPreference) preference).getEntries()[index];
            preference.setSummary(entry);
            return true;
        }
    });
}
Also used : ListPreference(android.preference.ListPreference) Preference(android.preference.Preference) ListPreference(android.preference.ListPreference)

Example 9 with ListPreference

use of android.preference.ListPreference in project collect by opendatakit.

the class UserInterfacePreferences method initFontSizePref.

private void initFontSizePref() {
    final ListPreference pref = (ListPreference) findPreference(KEY_FONT_SIZE);
    if (pref != null) {
        pref.setSummary(pref.getEntry());
        pref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {

            @Override
            public boolean onPreferenceChange(Preference preference, Object newValue) {
                int index = ((ListPreference) preference).findIndexOfValue(newValue.toString());
                CharSequence entry = ((ListPreference) preference).getEntries()[index];
                preference.setSummary(entry);
                return true;
            }
        });
    }
}
Also used : ListPreference(android.preference.ListPreference) Preference(android.preference.Preference) ListPreference(android.preference.ListPreference)

Example 10 with ListPreference

use of android.preference.ListPreference in project collect by opendatakit.

the class UserInterfacePreferences method initNavigationPrefs.

private void initNavigationPrefs() {
    final ListPreference pref = (ListPreference) findPreference(KEY_NAVIGATION);
    if (pref != null) {
        pref.setSummary(pref.getEntry());
        pref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {

            @Override
            public boolean onPreferenceChange(Preference preference, Object newValue) {
                int index = ((ListPreference) preference).findIndexOfValue(newValue.toString());
                String entry = (String) ((ListPreference) preference).getEntries()[index];
                preference.setSummary(entry);
                return true;
            }
        });
    }
}
Also used : ListPreference(android.preference.ListPreference) Preference(android.preference.Preference) ListPreference(android.preference.ListPreference)

Aggregations

ListPreference (android.preference.ListPreference)152 Preference (android.preference.Preference)76 CheckBoxPreference (android.preference.CheckBoxPreference)47 EditTextPreference (android.preference.EditTextPreference)32 PreferenceScreen (android.preference.PreferenceScreen)20 ArrayList (java.util.ArrayList)18 SharedPreferences (android.content.SharedPreferences)17 Intent (android.content.Intent)14 PreferenceCategory (android.preference.PreferenceCategory)14 SuppressLint (android.annotation.SuppressLint)13 MultiSelectListPreference (android.preference.MultiSelectListPreference)8 OnPreferenceChangeListener (android.preference.Preference.OnPreferenceChangeListener)8 OnPreferenceClickListener (android.preference.Preference.OnPreferenceClickListener)8 File (java.io.File)8 Bundle (android.os.Bundle)7 SwitchPreference (android.preference.SwitchPreference)7 View (android.view.View)7 Context (android.content.Context)6 DialogInterface (android.content.DialogInterface)6 RingtonePreference (android.preference.RingtonePreference)6