use of android.preference.ListPreference in project Osmand by osmandapp.
the class SettingsRasterMapsActivity method addTileSourcePrefs.
@SuppressWarnings("unused")
private void addTileSourcePrefs(OnPreferenceChangeListener listener, PreferenceCategory cat) {
CheckBoxPreference mapVectorData = createCheckBoxPreference(settings.MAP_ONLINE_DATA, R.string.map_online_data, R.string.map_online_data_descr);
cat.addPreference(mapVectorData);
tileSourcePreference = new ListPreference(this);
tileSourcePreference.setSummary(R.string.map_tile_source_descr);
tileSourcePreference.setTitle(R.string.map_tile_source);
tileSourcePreference.setOnPreferenceChangeListener(listener);
cat.addPreference(tileSourcePreference);
}
use of android.preference.ListPreference in project Osmand by osmandapp.
the class SettingsGeneralActivity method addLocalPrefs.
private void addLocalPrefs(PreferenceGroup screen) {
drivingRegionPreference.setTitle(R.string.driving_region);
drivingRegionPreference.setSummary(R.string.driving_region_descr);
drivingRegionPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
final AlertDialog.Builder b = new AlertDialog.Builder(SettingsGeneralActivity.this);
b.setTitle(getString(R.string.driving_region));
final List<DrivingRegion> drs = new ArrayList<>();
drs.add(null);
drs.addAll(Arrays.asList(DrivingRegion.values()));
int sel = -1;
DrivingRegion selectedDrivingRegion = settings.DRIVING_REGION.get();
if (settings.DRIVING_REGION_AUTOMATIC.get()) {
sel = 0;
}
for (int i = 1; i < drs.size(); i++) {
if (sel == -1 && drs.get(i) == selectedDrivingRegion) {
sel = i;
break;
}
}
final int selected = sel;
final ArrayAdapter<DrivingRegion> singleChoiceAdapter = new ArrayAdapter<DrivingRegion>(SettingsGeneralActivity.this, R.layout.single_choice_description_item, R.id.text1, drs) {
@NonNull
@Override
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
View v = convertView;
if (v == null) {
LayoutInflater inflater = SettingsGeneralActivity.this.getLayoutInflater();
v = inflater.inflate(R.layout.single_choice_description_item, parent, false);
}
DrivingRegion item = getItem(position);
AppCompatCheckedTextView title = (AppCompatCheckedTextView) v.findViewById(R.id.text1);
TextView desc = (TextView) v.findViewById(R.id.description);
if (item != null) {
title.setText(getString(item.name));
desc.setVisibility(View.VISIBLE);
desc.setText(item.getDescription(v.getContext()));
} else {
title.setText(getString(R.string.driving_region_automatic));
desc.setVisibility(View.GONE);
}
title.setChecked(position == selected);
return v;
}
};
b.setAdapter(singleChoiceAdapter, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (drs.get(which) == null) {
settings.DRIVING_REGION_AUTOMATIC.set(true);
MapViewTrackingUtilities mapViewTrackingUtilities = MapActivity.getSingleMapViewTrackingUtilities();
if (mapViewTrackingUtilities != null) {
mapViewTrackingUtilities.resetDrivingRegionUpdate();
}
} else {
settings.DRIVING_REGION_AUTOMATIC.set(false);
settings.DRIVING_REGION.set(drs.get(which));
}
updateAllSettings();
}
});
b.setNegativeButton(R.string.shared_string_cancel, null);
b.show();
return true;
}
});
String[] entries;
String[] entrieValues;
MetricsConstants[] mvls = MetricsConstants.values();
entries = new String[mvls.length];
for (int i = 0; i < entries.length; i++) {
entries[i] = mvls[i].toHumanString(getMyApplication());
}
registerListPreference(settings.METRIC_SYSTEM, screen, entries, mvls);
Integer[] cvls = new Integer[5];
cvls[0] = PointDescription.FORMAT_DEGREES;
cvls[1] = PointDescription.FORMAT_MINUTES;
cvls[2] = PointDescription.FORMAT_SECONDS;
cvls[3] = PointDescription.UTM_FORMAT;
cvls[4] = PointDescription.OLC_FORMAT;
entries = new String[5];
entries[0] = PointDescription.formatToHumanString(this, PointDescription.FORMAT_DEGREES);
entries[1] = PointDescription.formatToHumanString(this, PointDescription.FORMAT_MINUTES);
entries[2] = PointDescription.formatToHumanString(this, PointDescription.FORMAT_SECONDS);
entries[3] = PointDescription.formatToHumanString(this, PointDescription.UTM_FORMAT);
entries[4] = PointDescription.formatToHumanString(this, PointDescription.OLC_FORMAT);
registerListPreference(settings.COORDINATES_FORMAT, screen, entries, cvls);
// See language list and statistics at: https://hosted.weblate.org/projects/osmand/main/
// Hardy maintenance 2016-05-29:
// - Include languages if their translation is >= ~10% (but any language will be visible if it is the device's system locale)
// - Mark as "incomplete" if < ~80%
String incompleteSuffix = " (" + getString(R.string.incomplete_locale) + ")";
// Add " (Device language)" to system default entry in Latin letters, so it can be more easily identified if a foreign language has been selected by mistake
String latinSystemDefaultSuffix = " (" + getString(R.string.system_locale_no_translate) + ")";
// getResources().getAssets().getLocales();
entrieValues = new String[] { "", "en", "af", "ar", "ast", "az", "be", "be_BY", "bg", "ca", "cs", "cy", "da", "de", "el", "en_GB", "eo", "es", "es_AR", "es_US", "eu", "fa", "fi", "fr", "gl", "he", "hr", "hsb", "hu", "hy", "is", "it", "ja", "ka", "kab", "kn", "ko", "lt", "lv", "ml", "mr", "nb", "nl", "nn", "pl", "pt", "pt_BR", "ro", "ru", "sc", "sk", "sl", "sr", "sr+Latn", "sv", "tr", "uk", "vi", "zh_CN", "zh_TW" };
entries = new String[] { getString(R.string.system_locale) + latinSystemDefaultSuffix, getString(R.string.lang_en), getString(R.string.lang_af) + incompleteSuffix, getString(R.string.lang_ar), getString(R.string.lang_ast) + incompleteSuffix, getString(R.string.lang_az), getString(R.string.lang_be), getString(R.string.lang_be_by), getString(R.string.lang_bg), getString(R.string.lang_ca), getString(R.string.lang_cs), getString(R.string.lang_cy) + incompleteSuffix, getString(R.string.lang_da), getString(R.string.lang_de), getString(R.string.lang_el) + incompleteSuffix, getString(R.string.lang_en_gb), getString(R.string.lang_eo), getString(R.string.lang_es), getString(R.string.lang_es_ar), getString(R.string.lang_es_us), getString(R.string.lang_eu) + incompleteSuffix, getString(R.string.lang_fa), getString(R.string.lang_fi) + incompleteSuffix, getString(R.string.lang_fr), getString(R.string.lang_gl) + incompleteSuffix, getString(R.string.lang_he) + incompleteSuffix, getString(R.string.lang_hr) + incompleteSuffix, getString(R.string.lang_hsb) + incompleteSuffix, getString(R.string.lang_hu), getString(R.string.lang_hy), getString(R.string.lang_is) + incompleteSuffix, getString(R.string.lang_it), getString(R.string.lang_ja), getString(R.string.lang_ka) + incompleteSuffix, getString(R.string.lang_kab) + incompleteSuffix, getString(R.string.lang_kn) + incompleteSuffix, getString(R.string.lang_ko), getString(R.string.lang_lt), getString(R.string.lang_lv), getString(R.string.lang_ml) + incompleteSuffix, getString(R.string.lang_mr) + incompleteSuffix, getString(R.string.lang_nb), getString(R.string.lang_nl), getString(R.string.lang_nn) + incompleteSuffix, getString(R.string.lang_pl), getString(R.string.lang_pt), getString(R.string.lang_pt_br), getString(R.string.lang_ro) + incompleteSuffix, getString(R.string.lang_ru), getString(R.string.lang_sc), getString(R.string.lang_sk), getString(R.string.lang_sl), getString(R.string.lang_sr) + incompleteSuffix, getString(R.string.lang_sr_latn) + incompleteSuffix, getString(R.string.lang_sv), getString(R.string.lang_tr), getString(R.string.lang_uk), getString(R.string.lang_vi) + incompleteSuffix, getString(R.string.lang_zh_cn) + incompleteSuffix, getString(R.string.lang_zh_tw) };
String[] valuesPl = ConfigureMapMenu.getSortedMapNamesIds(this, entries, entries);
String[] idsPl = ConfigureMapMenu.getSortedMapNamesIds(this, entrieValues, entries);
registerListPreference(settings.PREFERRED_LOCALE, screen, valuesPl, idsPl);
// Add " (Display language)" to menu title in Latin letters for all non-en languages
if (!getResources().getString(R.string.preferred_locale).equals(getResources().getString(R.string.preferred_locale_no_translate))) {
((ListPreference) screen.findPreference(settings.PREFERRED_LOCALE.getId())).setTitle(getString(R.string.preferred_locale) + " (" + getString(R.string.preferred_locale_no_translate) + ")");
}
// This setting now only in "Confgure map" menu
// String[] values = ConfigureMapMenu.getMapNamesValues(this, ConfigureMapMenu.mapNamesIds);
// String[] ids = ConfigureMapMenu.getSortedMapNamesIds(this, ConfigureMapMenu.mapNamesIds, values);
// registerListPreference(settings.MAP_PREFERRED_LOCALE, screen, ConfigureMapMenu.getMapNamesValues(this, ids), ids);
}
use of android.preference.ListPreference in project Osmand by osmandapp.
the class SettingsBaseActivity method createListPreference.
public <T> ListPreference createListPreference(OsmandPreference<T> b, String[] names, T[] values, String title, String summary) {
ListPreference p = new ListPreference(this);
p.setTitle(title);
p.setKey(b.getId());
p.setDialogTitle(title);
p.setSummary(summary);
prepareListPreference(b, names, values, p);
return p;
}
use of android.preference.ListPreference in project Osmand by osmandapp.
the class SettingsBaseActivity method createListPreference.
public <T> ListPreference createListPreference(OsmandPreference<T> b, String[] names, T[] values, int title, int summary) {
ListPreference p = new ListPreference(this);
p.setTitle(title);
p.setKey(b.getId());
p.setDialogTitle(title);
p.setSummary(summary);
prepareListPreference(b, names, values, p);
return p;
}
use of android.preference.ListPreference in project Zom-Android by zom.
the class SettingActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
pm = getPackageManager();
mOtrMode = (ListPreference) findPreference("pref_security_otr_mode");
mOtrMode.setEntries(Preferences.getOtrModeNames());
mOtrMode.setEntryValues(Preferences.getOtrModeValues());
mOtrMode.setDefaultValue(Preferences.DEFAULT_OTR_MODE);
mAllowScreenshot = (CheckBoxPreference) findPreference("prefBlockScreenshots");
mPanicTriggerApp = (ListPreference) findPreference("pref_panic_trigger_app");
mPanicConfig = (Preference) findPreference("pref_panic_config");
mLanguage = (ListPreference) findPreference("pref_language");
// mLinkifyOnTor = (CheckBoxPreference) findPreference("pref_linkify_on_tor");
mHideOfflineContacts = (CheckBoxPreference) findPreference("pref_hide_offline_contacts");
mDeleteUnsecuredMedia = (CheckBoxPreference) findPreference("pref_delete_unsecured_media");
mEnableNotification = (CheckBoxPreference) findPreference("pref_enable_notification");
mNotificationVibrate = (CheckBoxPreference) findPreference("pref_notification_vibrate");
mNotificationSound = (CheckBoxPreference) findPreference("pref_notification_sound");
mNotificationRingtone = findPreference("pref_notification_ringtone");
Languages languages = Languages.get(this);
currentLanguage = getResources().getConfiguration().locale.getLanguage();
mLanguage.setDefaultValue(currentLanguage);
mLanguage.setEntries(languages.getAllNames());
mLanguage.setEntryValues(languages.getSupportedLocales());
mLanguage.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
String language = (String) newValue;
ImApp.resetLanguage(SettingActivity.this, language);
setResult(RESULT_OK);
return true;
}
});
mAllowScreenshot.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object o) {
setResult(RESULT_OK);
return true;
}
});
mPanicTriggerApp.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
String packageName = (String) newValue;
PanicResponder.setTriggerPackageName(SettingActivity.this, packageName);
PanicResponder.configTriggerAppListPreference(mPanicTriggerApp, R.string.panic_trigger_app_summary, R.string.panic_app_none_summary);
return true;
}
});
mPanicConfig.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
Intent intent = new Intent(SettingActivity.this, PanicSetupActivity.class);
startActivity(intent);
return true;
}
});
findPreference("pref_color_reset").setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(SettingActivity.this);
SharedPreferences.Editor pEdit = settings.edit();
pEdit.remove("themeColorBg");
pEdit.remove("themeColorText");
pEdit.remove("themeColor");
pEdit.commit();
setResult(RESULT_OK);
finish();
return true;
}
});
mNotificationRingtone.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference arg0) {
Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, getString(R.string.notification_ringtone_title));
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, Preferences.getNotificationRingtoneUri());
startActivityForResult(intent, CHOOSE_RINGTONE);
return true;
}
});
mForegroundService = (CheckBoxPreference) findPreference("pref_foreground_enable");
mForegroundService.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object o) {
((ImApp) getApplication()).forceStopImService();
return true;
}
});
mHeartbeatInterval = (EditTextPreference) findPreference("pref_heartbeat_interval");
findPreference("prefAdvancedNetworking").setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
RemoteImService.installTransports(getApplicationContext());
return true;
}
});
}
Aggregations