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"));
}
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());
}
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;
}
});
}
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;
}
});
}
}
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;
}
});
}
}
Aggregations