From c928c89209a83fda06ab3da083ed1b474e74f426 Mon Sep 17 00:00:00 2001 From: sonora Date: Fri, 5 Aug 2016 09:54:27 +0200 Subject: [PATCH] Improve formatStreetName --- .../osmand/plus/routing/RoutingHelper.java | 57 ++++++++++++++----- 1 file changed, 42 insertions(+), 15 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java index 6589329fa0..f79438e31d 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java +++ b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java @@ -710,22 +710,49 @@ public class RoutingHelper { public static String formatStreetName(String name, String ref, String destination) { - if(destination != null && destination.length() > 0){ - if(ref != null && ref.length() > 0) { - destination = ref + " " + destination; - } - return destination; - } else if(name != null && name.length() > 0){ - if(ref != null && ref.length() > 0) { - name = ref + " " + name; - } - return name; - } else { - if(ref == null) { - return ""; - } - return ref; + //Original version returned: + // 1. ref + " " + dest + // 2. dest + // 3. ref + " " + name + // 4. name + // 5. ref + // 6. "" + //Now returns: (ref)+((" ")+name)+((" ")+"toward "+dest) + + String formattedStreetName = ""; + if (ref != null && ref.length() > 0) { + formattedStreetName = ref; } + if (name != null && name.length() > 0) { + if (formattedStreetName.length() > 0) { + formattedStreetName = formattedStreetName + " "; + } + formattedStreetName = formattedStreetName + name; + } + if (destination != null && destination.length() > 0) { + if (formattedStreetName.length() > 0) { + formattedStreetName = formattedStreetName + " "; + } + formattedStreetName = formattedStreetName + app.getString(R.string.towards) + " " + destination; + } + return formattedStreetName; + +// if(destination != null && destination.length() > 0){ +// if(ref != null && ref.length() > 0) { +// destination = ref + " " + destination; +// } +// return destination; +// } else if(name != null && name.length() > 0){ +// if(ref != null && ref.length() > 0) { +// name = ref + " " + name; +// } +// return name; +// } else { +// if(ref == null) { +// return ""; +// } +// return ref; +// } } // protected boolean isDistanceLess(float currentSpeed, double dist, double etalon, float defSpeed){