Fix translation for navigation type

This commit is contained in:
Vitaliy 2020-09-16 14:26:24 +03:00
parent 137faffe3b
commit 79d70c9b34

View file

@ -61,6 +61,7 @@ import net.osmand.plus.mapmarkers.MarkersPlanRouteContext;
import net.osmand.plus.measurementtool.MeasurementToolFragment; import net.osmand.plus.measurementtool.MeasurementToolFragment;
import net.osmand.plus.measurementtool.StartPlanRouteBottomSheet; import net.osmand.plus.measurementtool.StartPlanRouteBottomSheet;
import net.osmand.plus.monitoring.OsmandMonitoringPlugin; import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
import net.osmand.plus.profiles.RoutingProfileDataObject;
import net.osmand.plus.routepreparationmenu.MapRouteInfoMenu; import net.osmand.plus.routepreparationmenu.MapRouteInfoMenu;
import net.osmand.plus.routepreparationmenu.WaypointsFragment; import net.osmand.plus.routepreparationmenu.WaypointsFragment;
import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder; import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder;
@ -86,6 +87,7 @@ import java.text.MessageFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map;
import static net.osmand.IndexConstants.GPX_FILE_EXT; import static net.osmand.IndexConstants.GPX_FILE_EXT;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.DRAWER_CONFIGURE_MAP_ID; 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_CHOSEN_PROFILE_TAG;
import static net.osmand.plus.ContextMenuAdapter.PROFILES_CONTROL_BUTTON_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.ContextMenuAdapter.PROFILES_NORMAL_PROFILE_TAG;
import static net.osmand.plus.settings.fragments.NavigationFragment.getRoutingProfiles;
public class MapActivityActions implements DialogProvider { public class MapActivityActions implements DialogProvider {
@ -731,11 +734,11 @@ public class MapActivityActions implements DialogProvider {
ApplicationMode currentMode = app.getSettings().APPLICATION_MODE.get(); ApplicationMode currentMode = app.getSettings().APPLICATION_MODE.get();
String modeDescription; String modeDescription;
Map<String, RoutingProfileDataObject> profilesObjects = getRoutingProfiles(app);
for (final ApplicationMode appMode : activeModes) { for (final ApplicationMode appMode : activeModes) {
if (appMode.isCustomProfile()) { if (appMode.isCustomProfile()) {
modeDescription = String.format(app.getString(R.string.profile_type_descr_string), modeDescription = getCustomProfileDescription(app, appMode, profilesObjects);
Algorithms.capitalizeFirstLetterAndLowercase(appMode.getRoutingProfile()));
} else { } else {
modeDescription = getString(R.string.profile_type_base_string); modeDescription = getString(R.string.profile_type_base_string);
} }
@ -1045,8 +1048,8 @@ public class MapActivityActions implements DialogProvider {
ApplicationMode currentMode = app.getSettings().APPLICATION_MODE.get(); ApplicationMode currentMode = app.getSettings().APPLICATION_MODE.get();
String modeDescription; String modeDescription;
if (currentMode.isCustomProfile()) { if (currentMode.isCustomProfile()) {
modeDescription = String.format(app.getString(R.string.profile_type_descr_string), Map<String, RoutingProfileDataObject> profilesObjects = getRoutingProfiles(app);
Algorithms.capitalizeFirstLetterAndLowercase(currentMode.getRoutingProfile())); modeDescription = getCustomProfileDescription(app, currentMode, profilesObjects);
} else { } else {
modeDescription = getString(R.string.profile_type_base_string); modeDescription = getString(R.string.profile_type_base_string);
} }
@ -1081,6 +1084,21 @@ public class MapActivityActions implements DialogProvider {
.createItem()); .createItem());
} }
private String getCustomProfileDescription(OsmandApplication app, ApplicationMode mode,
Map<String, RoutingProfileDataObject> 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() { public void openIntermediatePointsDialog() {
mapActivity.hideContextAndRouteInfoMenues(); mapActivity.hideContextAndRouteInfoMenues();
WaypointsFragment.showInstance(mapActivity.getSupportFragmentManager()); WaypointsFragment.showInstance(mapActivity.getSupportFragmentManager());