Make method more flexible

This commit is contained in:
sonora 2016-08-05 10:44:07 +02:00
parent 5a3fc1b0df
commit ffdcf19afb
5 changed files with 13 additions and 10 deletions

View file

@ -99,7 +99,7 @@ public class AvoidSpecificRoads {
protected String getText(RouteDataObject obj) { protected String getText(RouteDataObject obj) {
return RoutingHelper.formatStreetName(obj.getName(app.getSettings().MAP_PREFERRED_LOCALE.get()), return RoutingHelper.formatStreetName(obj.getName(app.getSettings().MAP_PREFERRED_LOCALE.get()),
obj.getRef(), obj.getDestinationName(app.getSettings().MAP_PREFERRED_LOCALE.get())); obj.getRef(), obj.getDestinationName(app.getSettings().MAP_PREFERRED_LOCALE.get()), true);
} }
public void showDialog(final MapActivity mapActivity) { public void showDialog(final MapActivity mapActivity) {

View file

@ -428,7 +428,7 @@ public class ExternalApiHelper {
if (ni.directionInfo != null && ni.directionInfo.getTurnType() != null) { if (ni.directionInfo != null && ni.directionInfo.getTurnType() != null) {
TurnType tt = ni.directionInfo.getTurnType(); TurnType tt = ni.directionInfo.getTurnType();
RouteDirectionInfo a = ni.directionInfo; RouteDirectionInfo a = ni.directionInfo;
result.putExtra(prefix + PARAM_NT_DIRECTION_NAME, RoutingHelper.formatStreetName(a.getStreetName(), a.getRef(), a.getDestinationName())); result.putExtra(prefix + PARAM_NT_DIRECTION_NAME, RoutingHelper.formatStreetName(a.getStreetName(), a.getRef(), a.getDestinationName(), false));
result.putExtra(prefix + PARAM_NT_DIRECTION_TURN, tt.toXmlString()); result.putExtra(prefix + PARAM_NT_DIRECTION_TURN, tt.toXmlString());
if (tt.getLanes() != null) { if (tt.getLanes() != null) {
result.putExtra(prefix + PARAM_NT_DIRECTION_LANES, Arrays.toString(tt.getLanes())); result.putExtra(prefix + PARAM_NT_DIRECTION_LANES, Arrays.toString(tt.getLanes()));

View file

@ -261,7 +261,7 @@ public class RouteCalculationResult {
} }
String description = toString(turn, ctx) + " " + RoutingHelper.formatStreetName(info.getStreetName(), String description = toString(turn, ctx) + " " + RoutingHelper.formatStreetName(info.getStreetName(),
info.getRef(), info.getDestinationName()); info.getRef(), info.getDestinationName(), true);
String[] pointNames = s.getObject().getPointNames(s.getStartPointIndex()); String[] pointNames = s.getObject().getPointNames(s.getStartPointIndex());
if(pointNames != null) { if(pointNames != null) {
for (int t = 0; t < pointNames.length; t++) { for (int t = 0; t < pointNames.length; t++) {

View file

@ -709,7 +709,7 @@ public class RoutingHelper {
} }
public static String formatStreetName(String name, String ref, String destination) { public static String formatStreetName(String name, String ref, String destination, boolean includeTowards) {
//Original version returned: //Original version returned:
// 1. ref + " " + dest // 1. ref + " " + dest
// 2. dest // 2. dest
@ -733,8 +733,11 @@ public class RoutingHelper {
if (formattedStreetName.length() > 0) { if (formattedStreetName.length() > 0) {
formattedStreetName = formattedStreetName + " "; formattedStreetName = formattedStreetName + " ";
} }
//formattedStreetName = formattedStreetName + app.getString(R.string.towards) + " " + destination; if (includeTowards) {
formattedStreetName = formattedStreetName + " " + destination; formattedStreetName = formattedStreetName + R.string.towards + " " + destination;
} else {
formattedStreetName = formattedStreetName + " " + destination;
}
} }
return formattedStreetName; return formattedStreetName;
@ -778,14 +781,14 @@ public class RoutingHelper {
if(next != null) { if(next != null) {
next[0] = n.directionInfo.getTurnType(); next[0] = n.directionInfo.getTurnType();
} }
return formatStreetName(nm, rf, dn); return formatStreetName(nm, rf, dn, true);
} }
RouteSegmentResult rs = getCurrentSegmentResult(); RouteSegmentResult rs = getCurrentSegmentResult();
if(rs != null) { if(rs != null) {
String nm = rs.getObject().getName(settings.MAP_PREFERRED_LOCALE.get()); String nm = rs.getObject().getName(settings.MAP_PREFERRED_LOCALE.get());
String rf = rs.getObject().getRef(); String rf = rs.getObject().getRef();
String dn = rs.getObject().getDestinationName(settings.MAP_PREFERRED_LOCALE.get()); String dn = rs.getObject().getDestinationName(settings.MAP_PREFERRED_LOCALE.get());
return formatStreetName(nm, rf, dn); return formatStreetName(nm, rf, dn, true);
} }
return null; return null;
} }

View file

@ -317,7 +317,7 @@ public class MapInfoWidgetsFactory {
showNextTurn = true; showNextTurn = true;
RouteDirectionInfo next = routingHelper.getRouteDirections().get(di); RouteDirectionInfo next = routingHelper.getRouteDirections().get(di);
type[0] = next.getTurnType(); type[0] = next.getTurnType();
text = RoutingHelper.formatStreetName(next.getStreetName(), next.getRef(), next.getDestinationName()); text = RoutingHelper.formatStreetName(next.getStreetName(), next.getRef(), next.getDestinationName(), true);
// if (next.distance > 0) { // if (next.distance > 0) {
// text += " " + OsmAndFormatter.getFormattedDistance(next.distance, map.getMyApplication()); // text += " " + OsmAndFormatter.getFormattedDistance(next.distance, map.getMyApplication());
// } // }
@ -332,7 +332,7 @@ public class MapInfoWidgetsFactory {
RouteDataObject rt = locationProvider.getLastKnownRouteSegment(); RouteDataObject rt = locationProvider.getLastKnownRouteSegment();
if (rt != null) { if (rt != null) {
text = RoutingHelper.formatStreetName(rt.getName(settings.MAP_PREFERRED_LOCALE.get()), text = RoutingHelper.formatStreetName(rt.getName(settings.MAP_PREFERRED_LOCALE.get()),
rt.getRef(), rt.getDestinationName(settings.MAP_PREFERRED_LOCALE.get())); rt.getRef(), rt.getDestinationName(settings.MAP_PREFERRED_LOCALE.get()), true);
} }
if (text == null) { if (text == null) {
text = ""; text = "";