From 79d70c9b3485bac02b4f45fabfd268212a59e3d1 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Wed, 16 Sep 2020 14:26:24 +0300 Subject: [PATCH] Fix translation for navigation type --- .../plus/activities/MapActivityActions.java | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index 83a470b903..ea597558e1 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -61,6 +61,7 @@ import net.osmand.plus.mapmarkers.MarkersPlanRouteContext; import net.osmand.plus.measurementtool.MeasurementToolFragment; import net.osmand.plus.measurementtool.StartPlanRouteBottomSheet; import net.osmand.plus.monitoring.OsmandMonitoringPlugin; +import net.osmand.plus.profiles.RoutingProfileDataObject; import net.osmand.plus.routepreparationmenu.MapRouteInfoMenu; import net.osmand.plus.routepreparationmenu.WaypointsFragment; import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder; @@ -86,6 +87,7 @@ import java.text.MessageFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.Map; import static net.osmand.IndexConstants.GPX_FILE_EXT; import static net.osmand.aidlapi.OsmAndCustomizationConstants.DRAWER_CONFIGURE_MAP_ID; @@ -115,6 +117,7 @@ import static net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_S import static net.osmand.plus.ContextMenuAdapter.PROFILES_CHOSEN_PROFILE_TAG; import static net.osmand.plus.ContextMenuAdapter.PROFILES_CONTROL_BUTTON_TAG; import static net.osmand.plus.ContextMenuAdapter.PROFILES_NORMAL_PROFILE_TAG; +import static net.osmand.plus.settings.fragments.NavigationFragment.getRoutingProfiles; public class MapActivityActions implements DialogProvider { @@ -731,11 +734,11 @@ public class MapActivityActions implements DialogProvider { ApplicationMode currentMode = app.getSettings().APPLICATION_MODE.get(); String modeDescription; - + + Map profilesObjects = getRoutingProfiles(app); for (final ApplicationMode appMode : activeModes) { if (appMode.isCustomProfile()) { - modeDescription = String.format(app.getString(R.string.profile_type_descr_string), - Algorithms.capitalizeFirstLetterAndLowercase(appMode.getRoutingProfile())); + modeDescription = getCustomProfileDescription(app, appMode, profilesObjects); } else { modeDescription = getString(R.string.profile_type_base_string); } @@ -1045,8 +1048,8 @@ public class MapActivityActions implements DialogProvider { ApplicationMode currentMode = app.getSettings().APPLICATION_MODE.get(); String modeDescription; if (currentMode.isCustomProfile()) { - modeDescription = String.format(app.getString(R.string.profile_type_descr_string), - Algorithms.capitalizeFirstLetterAndLowercase(currentMode.getRoutingProfile())); + Map profilesObjects = getRoutingProfiles(app); + modeDescription = getCustomProfileDescription(app, currentMode, profilesObjects); } else { modeDescription = getString(R.string.profile_type_base_string); } @@ -1081,6 +1084,21 @@ public class MapActivityActions implements DialogProvider { .createItem()); } + private String getCustomProfileDescription(OsmandApplication app, ApplicationMode mode, + Map profilesObjects){ + String description = getString(R.string.profile_type_custom_string); + + String routingProfileKey = mode.getRoutingProfile(); + if (!Algorithms.isEmpty(routingProfileKey)) { + RoutingProfileDataObject profileDataObject = profilesObjects.get(routingProfileKey); + if (profileDataObject != null) { + description = String.format(app.getString(R.string.profile_type_descr_string), + Algorithms.capitalizeFirstLetterAndLowercase(profileDataObject.getName())); + } + } + return description; + } + public void openIntermediatePointsDialog() { mapActivity.hideContextAndRouteInfoMenues(); WaypointsFragment.showInstance(mapActivity.getSupportFragmentManager());