Search in sources :

Example 26 with ListPreferenceEx

use of net.osmand.plus.settings.preferences.ListPreferenceEx in project Osmand by osmandapp.

the class MapDuringNavigationFragment method setupMapDirectionToCompassPref.

private void setupMapDirectionToCompassPref() {
    // array size must be equal!
    Float[] valuesKmh = new Float[] { 0f, 5f, 7f, 10f, 15f, 20f };
    Float[] valuesMph = new Float[] { 0f, 3f, 5f, 7f, 10f, 15f };
    String[] names;
    if (settings.METRIC_SYSTEM.getModeValue(getSelectedAppMode()) == MetricsConstants.KILOMETERS_AND_METERS) {
        names = new String[valuesKmh.length];
        for (int i = 0; i < names.length; i++) {
            names[i] = valuesKmh[i].intValue() + " " + getString(R.string.km_h);
        }
    } else {
        names = new String[valuesMph.length];
        for (int i = 0; i < names.length; i++) {
            names[i] = valuesMph[i].intValue() + " " + getString(R.string.mile_per_hour);
        }
    }
    ListPreferenceEx switchMapDirectionToCompass = (ListPreferenceEx) findPreference(settings.SWITCH_MAP_DIRECTION_TO_COMPASS_KMH.getId());
    switchMapDirectionToCompass.setDescription(R.string.map_orientation_threshold_descr);
    switchMapDirectionToCompass.setEntries(names);
    switchMapDirectionToCompass.setEntryValues(valuesKmh);
}
Also used : ListPreferenceEx(net.osmand.plus.settings.preferences.ListPreferenceEx)

Example 27 with ListPreferenceEx

use of net.osmand.plus.settings.preferences.ListPreferenceEx in project Osmand by osmandapp.

the class VehicleParametersFragment method onBindPreferenceViewHolder.

@Override
protected void onBindPreferenceViewHolder(Preference preference, PreferenceViewHolder holder) {
    super.onBindPreferenceViewHolder(preference, holder);
    if (!DEFAULT_SPEED.equals(preference.getKey()) && preference instanceof ListPreferenceEx) {
        ImageView imageView = (ImageView) holder.findViewById(android.R.id.icon);
        if (imageView != null) {
            Object currentValue = ((ListPreferenceEx) preference).getValue();
            boolean enabled = preference.isEnabled() && !ROUTING_PARAMETER_NUMERIC_DEFAULT.equals(currentValue) && !ROUTING_PARAMETER_SYMBOLIC_DEFAULT.equals(currentValue);
            imageView.setEnabled(enabled);
        }
    } else if (preference instanceof SizePreference) {
        ImageView imageView = (ImageView) holder.findViewById(android.R.id.icon);
        if (imageView != null) {
            Object currentValue = ((SizePreference) preference).getValue();
            boolean enabled = preference.isEnabled() && !ROUTING_PARAMETER_NUMERIC_DEFAULT.equals(currentValue) && !ROUTING_PARAMETER_SYMBOLIC_DEFAULT.equals(currentValue);
            imageView.setEnabled(enabled);
        }
    }
}
Also used : ListPreferenceEx(net.osmand.plus.settings.preferences.ListPreferenceEx) ImageView(android.widget.ImageView) SizePreference(net.osmand.plus.settings.preferences.SizePreference)

Example 28 with ListPreferenceEx

use of net.osmand.plus.settings.preferences.ListPreferenceEx in project Osmand by osmandapp.

the class TurnScreenOnFragment method onBindPreferenceViewHolder.

@Override
protected void onBindPreferenceViewHolder(Preference preference, PreferenceViewHolder holder) {
    super.onBindPreferenceViewHolder(preference, holder);
    String prefId = preference.getKey();
    if (settings.TURN_SCREEN_ON_TIME_INT.getId().equals(prefId) && preference instanceof ListPreferenceEx) {
        TextView summaryView = (TextView) holder.findViewById(android.R.id.summary);
        if (summaryView != null && !preference.isEnabled()) {
            summaryView.setText(R.string.default_screen_timeout);
        }
    } else if ("turn_screen_on_info".equals(prefId) || "turn_screen_on_options_info".equals(prefId)) {
        TextView titleView = (TextView) holder.findViewById(android.R.id.title);
        if (titleView != null) {
            titleView.setTextColor(getDisabledTextColor());
        }
    }
}
Also used : ListPreferenceEx(net.osmand.plus.settings.preferences.ListPreferenceEx) TextView(android.widget.TextView)

Example 29 with ListPreferenceEx

use of net.osmand.plus.settings.preferences.ListPreferenceEx in project Osmand by osmandapp.

the class TurnScreenOnFragment method setupTurnScreenOnTimePref.

private void setupTurnScreenOnTimePref() {
    Integer[] entryValues = new Integer[] { 0, 5, 10, 15, 20, 30, 45, 60 };
    String[] entries = new String[entryValues.length];
    entries[0] = getString(R.string.keep_screen_on);
    for (int i = 1; i < entryValues.length; i++) {
        entries[i] = entryValues[i] + " " + getString(R.string.int_seconds);
    }
    ListPreferenceEx turnScreenOnTime = (ListPreferenceEx) findPreference(settings.TURN_SCREEN_ON_TIME_INT.getId());
    turnScreenOnTime.setEnabled(!settings.USE_SYSTEM_SCREEN_TIMEOUT.getModeValue(getSelectedAppMode()));
    turnScreenOnTime.setEntries(entries);
    turnScreenOnTime.setEntryValues(entryValues);
    turnScreenOnTime.setDescription(getString(R.string.turn_screen_on_wake_time_descr, getString(R.string.keep_screen_on)));
    turnScreenOnTime.setIcon(getPersistentPrefIcon(R.drawable.ic_action_time_span));
}
Also used : ListPreferenceEx(net.osmand.plus.settings.preferences.ListPreferenceEx)

Example 30 with ListPreferenceEx

use of net.osmand.plus.settings.preferences.ListPreferenceEx in project Osmand by osmandapp.

the class VoiceAnnouncesFragment method setupKeepInformingPref.

private void setupKeepInformingPref() {
    Integer[] keepInformingValues = new Integer[] { 0, 1, 2, 3, 5, 7, 10, 15, 20, 25, 30 };
    String[] keepInformingNames = new String[keepInformingValues.length];
    keepInformingNames[0] = getString(R.string.keep_informing_never);
    for (int i = 1; i < keepInformingValues.length; i++) {
        keepInformingNames[i] = keepInformingValues[i] + " " + getString(R.string.int_min);
    }
    ListPreferenceEx keepInforming = findPreference(settings.KEEP_INFORMING.getId());
    keepInforming.setEntries(keepInformingNames);
    keepInforming.setEntryValues(keepInformingValues);
}
Also used : ListPreferenceEx(net.osmand.plus.settings.preferences.ListPreferenceEx)

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