Search in sources :

Example 6 with ListPreferenceEx

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;
}
Also used : ListPreferenceEx(net.osmand.plus.settings.preferences.ListPreferenceEx)

Example 7 with ListPreferenceEx

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);
    }
}
Also used : FragmentManager(androidx.fragment.app.FragmentManager) ListPreferenceEx(net.osmand.plus.settings.preferences.ListPreferenceEx) MultiSelectBooleanPreference(net.osmand.plus.settings.preferences.MultiSelectBooleanPreference) ApplicationMode(net.osmand.plus.settings.backend.ApplicationMode) EditTextPreference(androidx.preference.EditTextPreference) SwitchPreferenceEx(net.osmand.plus.settings.preferences.SwitchPreferenceEx)

Example 8 with ListPreferenceEx

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) + ")");
    }
}
Also used : Context(android.content.Context) ListPreferenceEx(net.osmand.plus.settings.preferences.ListPreferenceEx)

Example 9 with ListPreferenceEx

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);
}
Also used : ListPreferenceEx(net.osmand.plus.settings.preferences.ListPreferenceEx)

Example 10 with ListPreferenceEx

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);
}
Also used : ListPreferenceEx(net.osmand.plus.settings.preferences.ListPreferenceEx) AutoZoomMap(net.osmand.plus.settings.enums.AutoZoomMap)

Aggregations

ListPreferenceEx (net.osmand.plus.settings.preferences.ListPreferenceEx)41 SpannableString (android.text.SpannableString)13 ArrayList (java.util.ArrayList)5 ApplicationMode (net.osmand.plus.settings.backend.ApplicationMode)4 SpannableStringBuilder (android.text.SpannableStringBuilder)3 Camera (android.hardware.Camera)2 MultiSelectBooleanPreference (net.osmand.plus.settings.preferences.MultiSelectBooleanPreference)2 SwitchPreferenceEx (net.osmand.plus.settings.preferences.SwitchPreferenceEx)2 RoutingParameter (net.osmand.router.GeneralRouter.RoutingParameter)2 Context (android.content.Context)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 FragmentManager (androidx.fragment.app.FragmentManager)1 EditTextPreference (androidx.preference.EditTextPreference)1 Preference (androidx.preference.Preference)1 PreferenceScreen (androidx.preference.PreferenceScreen)1 Map (java.util.Map)1 OsmandApplication (net.osmand.plus.OsmandApplication)1 BooleanPreference (net.osmand.plus.settings.backend.preferences.BooleanPreference)1 CommonPreference (net.osmand.plus.settings.backend.preferences.CommonPreference)1