From cdede9d97e03fa5edb7c10b239e107be8972852f Mon Sep 17 00:00:00 2001 From: Chumva Date: Wed, 16 Oct 2019 17:14:37 +0300 Subject: [PATCH] Add speed system pref --- OsmAnd/res/xml/general_profile_settings.xml | 5 +++++ .../GeneralProfileSettingsFragment.java | 20 ++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/OsmAnd/res/xml/general_profile_settings.xml b/OsmAnd/res/xml/general_profile_settings.xml index eedbd410af..bf059a374d 100644 --- a/OsmAnd/res/xml/general_profile_settings.xml +++ b/OsmAnd/res/xml/general_profile_settings.xml @@ -53,6 +53,11 @@ android:layout="@layout/preference_with_descr" android:title="@string/angular_measeurement" /> + + diff --git a/OsmAnd/src/net/osmand/plus/settings/GeneralProfileSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/GeneralProfileSettingsFragment.java index 447c5e8a36..ba5299fc04 100644 --- a/OsmAnd/src/net/osmand/plus/settings/GeneralProfileSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/GeneralProfileSettingsFragment.java @@ -48,6 +48,7 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment impleme setupUnitsOfLengthPref(); setupCoordinatesFormatPref(); setupAngularUnitsPref(); + setupSpeedSystemPref(); setupKalmanFilterPref(); setupMagneticFieldSensorPref(); @@ -202,7 +203,24 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment impleme ListPreferenceEx angularUnits = (ListPreferenceEx) findPreference(settings.ANGULAR_UNITS.getId()); angularUnits.setEntries(entries); angularUnits.setEntryValues(entryValues); - angularUnits.setIcon(getContentIcon(R.drawable.ic_action_angular_unit)); + angularUnits.setIcon(getIcon(R.drawable.ic_action_angular_unit)); + } + + private void setupSpeedSystemPref() { + OsmandSettings.SpeedConstants[] speedConstants = OsmandSettings.SpeedConstants.values(); + String[] entries = new String[speedConstants.length]; + Integer[] entryValues = new Integer[speedConstants.length]; + + for (int i = 0; i < entries.length; i++) { + entries[i] = speedConstants[i].toHumanString(app); + entryValues[i] = speedConstants[i].ordinal(); + } + + ListPreferenceEx speedSystem = (ListPreferenceEx) findPreference(settings.SPEED_SYSTEM.getId()); + speedSystem.setEntries(entries); + speedSystem.setEntryValues(entryValues); + speedSystem.setDescription(R.string.default_speed_system_descr); + speedSystem.setIcon(getContentIcon(R.drawable.ic_action_speed)); } private void setupKalmanFilterPref() {