Make method more flexible
This commit is contained in:
parent
5a3fc1b0df
commit
ffdcf19afb
5 changed files with 13 additions and 10 deletions
|
@ -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()));
|
||||
obj.getRef(), obj.getDestinationName(app.getSettings().MAP_PREFERRED_LOCALE.get()), true);
|
||||
}
|
||||
|
||||
public void showDialog(final MapActivity mapActivity) {
|
||||
|
|
|
@ -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()));
|
||||
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());
|
||||
if (tt.getLanes() != null) {
|
||||
result.putExtra(prefix + PARAM_NT_DIRECTION_LANES, Arrays.toString(tt.getLanes()));
|
||||
|
|
|
@ -261,7 +261,7 @@ public class RouteCalculationResult {
|
|||
}
|
||||
|
||||
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());
|
||||
if(pointNames != null) {
|
||||
for (int t = 0; t < pointNames.length; t++) {
|
||||
|
|
|
@ -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:
|
||||
// 1. ref + " " + dest
|
||||
// 2. dest
|
||||
|
@ -733,9 +733,12 @@ public class RoutingHelper {
|
|||
if (formattedStreetName.length() > 0) {
|
||||
formattedStreetName = formattedStreetName + " ";
|
||||
}
|
||||
//formattedStreetName = formattedStreetName + app.getString(R.string.towards) + " " + destination;
|
||||
if (includeTowards) {
|
||||
formattedStreetName = formattedStreetName + R.string.towards + " " + destination;
|
||||
} else {
|
||||
formattedStreetName = formattedStreetName + " " + destination;
|
||||
}
|
||||
}
|
||||
return formattedStreetName;
|
||||
|
||||
// if(destination != null && destination.length() > 0){
|
||||
|
@ -778,14 +781,14 @@ public class RoutingHelper {
|
|||
if(next != null) {
|
||||
next[0] = n.directionInfo.getTurnType();
|
||||
}
|
||||
return formatStreetName(nm, rf, dn);
|
||||
return formatStreetName(nm, rf, dn, true);
|
||||
}
|
||||
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);
|
||||
return formatStreetName(nm, rf, dn, true);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
text = RoutingHelper.formatStreetName(next.getStreetName(), next.getRef(), next.getDestinationName(), true);
|
||||
// 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()));
|
||||
rt.getRef(), rt.getDestinationName(settings.MAP_PREFERRED_LOCALE.get()), true);
|
||||
}
|
||||
if (text == null) {
|
||||
text = "";
|
||||
|
|
Loading…
Reference in a new issue