From f0e9678f2202b9276c4f7274e44d1a973ddbd952 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Wed, 5 Feb 2020 16:01:41 +0200 Subject: [PATCH] Fix navigation type preference --- .../plus/settings/NavigationFragment.java | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/settings/NavigationFragment.java b/OsmAnd/src/net/osmand/plus/settings/NavigationFragment.java index 7bd28481e9..b18e8c6bd8 100644 --- a/OsmAnd/src/net/osmand/plus/settings/NavigationFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/NavigationFragment.java @@ -57,23 +57,13 @@ public class NavigationFragment extends BaseSettingsFragment { @Override protected void setupPreferences() { navigationType = findPreference(NAVIGATION_TYPE); + setupNavigationTypePref(); + Preference routeParameters = findPreference("route_parameters"); SwitchPreferenceCompat showRoutingAlarms = (SwitchPreferenceCompat) findPreference(settings.SHOW_ROUTING_ALARMS.getId()); SwitchPreferenceCompat turnScreenOn = (SwitchPreferenceCompat) findPreference(settings.TURN_SCREEN_ON_ENABLED.getId()); SwitchPreferenceEx animateMyLocation = (SwitchPreferenceEx) findPreference(settings.ANIMATE_MY_LOCATION.getId()); - if (getSelectedAppMode().getRoutingProfile() != null) { - GeneralRouter routingProfile = app.getRoutingConfig().getRouter(getSelectedAppMode().getRoutingProfile()); - if (routingProfile != null) { - String profileNameUC = routingProfile.getProfileName().toUpperCase(); - if (RoutingProfilesResources.isRpValue(profileNameUC)) { - RoutingProfilesResources routingProfilesResources = RoutingProfilesResources.valueOf(profileNameUC); - navigationType.setSummary(routingProfilesResources.getStringRes()); - navigationType.setIcon(getActiveIcon(routingProfilesResources.getIconRes())); - } else { - navigationType.setIcon(getActiveIcon(R.drawable.ic_action_gdirections_dark)); - } - } - } + routeParameters.setIcon(getContentIcon(R.drawable.ic_action_route_distance)); showRoutingAlarms.setIcon(getPersistentPrefIcon(R.drawable.ic_action_alert)); turnScreenOn.setIcon(getPersistentPrefIcon(R.drawable.ic_action_turn_screen_on)); @@ -84,6 +74,17 @@ public class NavigationFragment extends BaseSettingsFragment { animateMyLocation.setDescription(getString(R.string.animate_my_location_desc)); } + private void setupNavigationTypePref() { + String routingProfileKey = getSelectedAppMode().getRoutingProfile(); + if (!Algorithms.isEmpty(routingProfileKey)) { + RoutingProfileDataObject routingProfileDataObject = routingProfileDataObjects.get(routingProfileKey); + if (routingProfileDataObject != null) { + navigationType.setSummary(routingProfileDataObject.getName()); + navigationType.setIcon(getActiveIcon(routingProfileDataObject.getIconRes())); + } + } + } + private void setupSpeakRoutingAlarmsPref() { Drawable disabled = getContentIcon(R.drawable.ic_action_volume_mute); Drawable enabled = getActiveIcon(R.drawable.ic_action_volume_up);