use of android.preference.ListPreference in project collect by opendatakit.
the class FormManagementPreferences method initAutoSendPrefs.
private void initAutoSendPrefs() {
final ListPreference autosend = (ListPreference) findPreference(KEY_AUTOSEND);
if (autosend == null) {
return;
}
autosend.setSummary(autosend.getEntry());
autosend.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 FormManagementPreferences method initImageSizePrefs.
private void initImageSizePrefs() {
final ListPreference imageSize = (ListPreference) findPreference(KEY_IMAGE_SIZE);
if (imageSize == null) {
return;
}
imageSize.setSummary(imageSize.getEntry());
imageSize.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 initLanguagePrefs.
private void initLanguagePrefs() {
final ListPreference pref = (ListPreference) findPreference(KEY_APP_LANGUAGE);
if (pref != null) {
final LocaleHelper localeHelper = new LocaleHelper();
TreeMap<String, String> languageList = localeHelper.getEntryListValues();
int length = languageList.size() + 1;
ArrayList<String> entryValues = new ArrayList<>();
entryValues.add(0, "");
entryValues.addAll(languageList.values());
pref.setEntryValues(entryValues.toArray(new String[length]));
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[length]));
if (pref.getValue() == null) {
// set Default value to "Use phone locale"
pref.setValueIndex(0);
}
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);
SharedPreferences.Editor edit = PreferenceManager.getDefaultSharedPreferences(getActivity()).edit();
edit.putString(KEY_APP_LANGUAGE, newValue.toString());
edit.apply();
localeHelper.updateLocale(getActivity());
Intent intent = new Intent(getActivity().getBaseContext(), MainMenuActivity.class);
getActivity().startActivity(intent);
getActivity().overridePendingTransition(0, 0);
getActivity().finishAffinity();
return true;
}
});
}
}
use of android.preference.ListPreference in project aware-client by denzilferreira.
the class Aware_Client method onSharedPreferenceChanged.
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
String value = "";
Map<String, ?> keys = sharedPreferences.getAll();
if (keys.containsKey(key)) {
Object entry = keys.get(key);
if (entry instanceof Boolean)
value = String.valueOf(sharedPreferences.getBoolean(key, false));
else if (entry instanceof String)
value = String.valueOf(sharedPreferences.getString(key, "error"));
else if (entry instanceof Integer)
value = String.valueOf(sharedPreferences.getInt(key, 0));
}
Aware.setSetting(getApplicationContext(), key, value);
Preference pref = findPreference(key);
if (CheckBoxPreference.class.isInstance(pref)) {
CheckBoxPreference check = (CheckBoxPreference) findPreference(key);
check.setChecked(Aware.getSetting(getApplicationContext(), key).equals("true"));
// update the parent to show active/inactive
new SettingsSync().execute(pref);
// Start/Stop sensor
Aware.startAWARE(getApplicationContext());
}
if (EditTextPreference.class.isInstance(pref)) {
EditTextPreference text = (EditTextPreference) findPreference(key);
text.setText(Aware.getSetting(getApplicationContext(), key));
}
if (ListPreference.class.isInstance(pref)) {
ListPreference list = (ListPreference) findPreference(key);
list.setSummary(list.getEntry());
}
}
use of android.preference.ListPreference in project Thrift-box by Sash0k.
the class SettingsFragment method getListValues.
// ============================================================================
/**
* Заполнение списков
*/
private void getListValues(String tag, int titlesId, int valuesId) {
ListPreference listprefence = (ListPreference) findPreference(tag);
if (listprefence != null) {
listprefence.setEntries(titlesId);
listprefence.setEntryValues(valuesId);
}
setPrefenceTitle(tag);
}
Aggregations