From 01dd28c8d608c001c9619383a148b5056c6f10f8 Mon Sep 17 00:00:00 2001 From: sonora Date: Fri, 5 Aug 2016 11:55:31 +0200 Subject: [PATCH] fix display of towards text --- .../net/osmand/plus/helpers/AvoidSpecificRoads.java | 2 +- .../net/osmand/plus/helpers/ExternalApiHelper.java | 2 +- .../osmand/plus/routing/RouteCalculationResult.java | 2 +- .../src/net/osmand/plus/routing/RoutingHelper.java | 12 ++++-------- .../plus/views/mapwidgets/MapInfoWidgetsFactory.java | 4 ++-- 5 files changed, 9 insertions(+), 13 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/helpers/AvoidSpecificRoads.java b/OsmAnd/src/net/osmand/plus/helpers/AvoidSpecificRoads.java index 8ca27b7878..31d0c80496 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/AvoidSpecificRoads.java +++ b/OsmAnd/src/net/osmand/plus/helpers/AvoidSpecificRoads.java @@ -99,7 +99,7 @@ public class AvoidSpecificRoads { protected String getText(RouteDataObject obj) { return RoutingHelper.formatStreetName(obj.getName(app.getSettings().MAP_PREFERRED_LOCALE.get()), - obj.getRef(), obj.getDestinationName(app.getSettings().MAP_PREFERRED_LOCALE.get()), true); + obj.getRef(), obj.getDestinationName(app.getSettings().MAP_PREFERRED_LOCALE.get()), app.getString(R.string.towards)); } public void showDialog(final MapActivity mapActivity) { diff --git a/OsmAnd/src/net/osmand/plus/helpers/ExternalApiHelper.java b/OsmAnd/src/net/osmand/plus/helpers/ExternalApiHelper.java index a44e341b41..301454a2fb 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/ExternalApiHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/ExternalApiHelper.java @@ -428,7 +428,7 @@ public class ExternalApiHelper { if (ni.directionInfo != null && ni.directionInfo.getTurnType() != null) { TurnType tt = ni.directionInfo.getTurnType(); RouteDirectionInfo a = ni.directionInfo; - result.putExtra(prefix + PARAM_NT_DIRECTION_NAME, RoutingHelper.formatStreetName(a.getStreetName(), a.getRef(), a.getDestinationName(), false)); + result.putExtra(prefix + PARAM_NT_DIRECTION_NAME, RoutingHelper.formatStreetName(a.getStreetName(), a.getRef(), a.getDestinationName(), "")); result.putExtra(prefix + PARAM_NT_DIRECTION_TURN, tt.toXmlString()); if (tt.getLanes() != null) { result.putExtra(prefix + PARAM_NT_DIRECTION_LANES, Arrays.toString(tt.getLanes())); diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java b/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java index 22464f3e40..8d7e4bf37e 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java +++ b/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java @@ -261,7 +261,7 @@ public class RouteCalculationResult { } String description = toString(turn, ctx) + " " + RoutingHelper.formatStreetName(info.getStreetName(), - info.getRef(), info.getDestinationName(), true); + info.getRef(), info.getDestinationName(), ctx.getString(R.string.towards)); String[] pointNames = s.getObject().getPointNames(s.getStartPointIndex()); if(pointNames != null) { for (int t = 0; t < pointNames.length; t++) { diff --git a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java index 78e68347d1..ecfaa54875 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java +++ b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java @@ -709,7 +709,7 @@ public class RoutingHelper { } - public static String formatStreetName(String name, String ref, String destination, boolean includeTowards) { + public static String formatStreetName(String name, String ref, String destination, String towards) { //Original version returned: // 1. ref + " " + dest // 2. dest @@ -733,11 +733,7 @@ public class RoutingHelper { if (formattedStreetName.length() > 0) { formattedStreetName = formattedStreetName + " "; } - if (includeTowards) { - formattedStreetName = formattedStreetName + R.string.towards + " " + destination; - } else { - formattedStreetName = formattedStreetName + " " + destination; - } + formattedStreetName = formattedStreetName + towards + " " + destination; } return formattedStreetName; @@ -781,14 +777,14 @@ public class RoutingHelper { if(next != null) { next[0] = n.directionInfo.getTurnType(); } - return formatStreetName(nm, rf, dn, true); + return formatStreetName(nm, rf, dn, app.getString(R.string.towards)); } RouteSegmentResult rs = getCurrentSegmentResult(); if(rs != null) { String nm = rs.getObject().getName(settings.MAP_PREFERRED_LOCALE.get()); String rf = rs.getObject().getRef(); String dn = rs.getObject().getDestinationName(settings.MAP_PREFERRED_LOCALE.get()); - return formatStreetName(nm, rf, dn, true); + return formatStreetName(nm, rf, dn, app.getString(R.string.towards)); } return null; } diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java index 3219e2bf1c..43a23c8d6b 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java @@ -317,7 +317,7 @@ public class MapInfoWidgetsFactory { showNextTurn = true; RouteDirectionInfo next = routingHelper.getRouteDirections().get(di); type[0] = next.getTurnType(); - text = RoutingHelper.formatStreetName(next.getStreetName(), next.getRef(), next.getDestinationName(), true); + text = RoutingHelper.formatStreetName(next.getStreetName(), next.getRef(), next.getDestinationName(), map.getMyApplication().getString(R.string.towards)); // if (next.distance > 0) { // text += " " + OsmAndFormatter.getFormattedDistance(next.distance, map.getMyApplication()); // } @@ -332,7 +332,7 @@ public class MapInfoWidgetsFactory { RouteDataObject rt = locationProvider.getLastKnownRouteSegment(); if (rt != null) { text = RoutingHelper.formatStreetName(rt.getName(settings.MAP_PREFERRED_LOCALE.get()), - rt.getRef(), rt.getDestinationName(settings.MAP_PREFERRED_LOCALE.get()), true); + rt.getRef(), rt.getDestinationName(settings.MAP_PREFERRED_LOCALE.get()), map.getMyApplication().getString(R.string.towards)); } if (text == null) { text = "";