use of net.osmand.plus.settings.preferences.ListPreferenceEx in project Osmand by osmandapp.
the class BaseSettingsFragment method createListPreferenceEx.
public ListPreferenceEx createListPreferenceEx(String prefId, String[] names, Object[] values, String title, int layoutId) {
ListPreferenceEx listPreference = new ListPreferenceEx(getContext());
listPreference.setKey(prefId);
listPreference.setTitle(title);
listPreference.setDialogTitle(title);
listPreference.setEntries(names);
listPreference.setEntryValues(values);
listPreference.setIconSpaceReserved(true);
if (layoutId != 0) {
listPreference.setLayoutResource(layoutId);
}
return listPreference;
}
use of net.osmand.plus.settings.preferences.ListPreferenceEx in project Osmand by osmandapp.
the class BaseSettingsFragment method onDisplayPreferenceDialog.
@Override
public void onDisplayPreferenceDialog(Preference preference) {
FragmentManager fragmentManager = getFragmentManager();
if (fragmentManager == null) {
return;
}
ApplicationMode appMode = getSelectedAppMode();
if (preference instanceof ListPreferenceEx) {
SingleSelectPreferenceBottomSheet.showInstance(fragmentManager, preference.getKey(), this, false, appMode, isProfileDependent(), false);
} else if (preference instanceof SwitchPreferenceEx) {
BooleanPreferenceBottomSheet.showInstance(fragmentManager, preference.getKey(), this, false, appMode, getApplyQueryType(), isProfileDependent());
} else if (preference instanceof EditTextPreference) {
EditTextPreferenceBottomSheet.showInstance(fragmentManager, preference.getKey(), this, false, appMode);
} else if (preference instanceof MultiSelectBooleanPreference) {
MultiSelectPreferencesBottomSheet.showInstance(fragmentManager, preference.getKey(), this, false, appMode, isProfileDependent());
} else {
super.onDisplayPreferenceDialog(preference);
}
}
use of net.osmand.plus.settings.preferences.ListPreferenceEx in project Osmand by osmandapp.
the class GlobalSettingsFragment method setupPreferredLocalePref.
private void setupPreferredLocalePref() {
Context ctx = getContext();
if (ctx == null) {
return;
}
ListPreferenceEx preferredLocale = (ListPreferenceEx) findPreference(settings.PREFERRED_LOCALE.getId());
preferredLocale.setIcon(getActiveIcon(R.drawable.ic_action_map_language));
preferredLocale.setSummary(settings.PREFERRED_LOCALE.get());
Pair<String[], String[]> preferredLocaleInfo = getPreferredLocaleIdsAndValues(ctx);
if (preferredLocaleInfo != null) {
preferredLocale.setEntries(preferredLocaleInfo.first);
preferredLocale.setEntryValues(preferredLocaleInfo.second);
}
// 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))) {
preferredLocale.setTitle(getString(R.string.preferred_locale) + " (" + getString(R.string.preferred_locale_no_translate) + ")");
}
}
use of net.osmand.plus.settings.preferences.ListPreferenceEx in project Osmand by osmandapp.
the class MapDuringNavigationFragment method setupAutoFollowPref.
private void setupAutoFollowPref() {
Integer[] entryValues = new Integer[] { 0, 5, 10, 15, 20, 25, 30, 45, 60, 90 };
String[] entries = new String[entryValues.length];
entries[0] = getString(R.string.shared_string_never);
for (int i = 1; i < entryValues.length; i++) {
entries[i] = (int) entryValues[i] + " " + getString(R.string.int_seconds);
}
ListPreferenceEx autoFollowRoute = (ListPreferenceEx) findPreference(settings.AUTO_FOLLOW_ROUTE.getId());
autoFollowRoute.setEntries(entries);
autoFollowRoute.setEntryValues(entryValues);
}
use of net.osmand.plus.settings.preferences.ListPreferenceEx in project Osmand by osmandapp.
the class MapDuringNavigationFragment method setupAutoZoomMapPref.
private void setupAutoZoomMapPref() {
Integer[] entryValues = new Integer[AutoZoomMap.values().length + 1];
String[] entries = new String[entryValues.length];
int i = 0;
int selectedIndex = -1;
entries[i] = getString(R.string.auto_zoom_none);
entryValues[0] = 0;
if (!settings.AUTO_ZOOM_MAP.getModeValue(getSelectedAppMode())) {
selectedIndex = 0;
}
i++;
for (AutoZoomMap autoZoomMap : AutoZoomMap.values()) {
entries[i] = getString(autoZoomMap.name);
entryValues[i] = i;
if (selectedIndex == -1 && settings.AUTO_ZOOM_MAP_SCALE.getModeValue(getSelectedAppMode()) == autoZoomMap) {
selectedIndex = i;
}
i++;
}
if (selectedIndex == -1) {
selectedIndex = 0;
}
ListPreferenceEx autoZoomMapPref = (ListPreferenceEx) findPreference(settings.AUTO_ZOOM_MAP.getId());
autoZoomMapPref.setEntries(entries);
autoZoomMapPref.setEntryValues(entryValues);
autoZoomMapPref.setValue(selectedIndex);
autoZoomMapPref.setPersistent(false);
}
Aggregations