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);
}
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);
}
}
}
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());
}
}
}
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));
}
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);
}
Aggregations