diff --git a/OsmAnd/src/net/osmand/plus/OsmAndFormatter.java b/OsmAnd/src/net/osmand/plus/OsmAndFormatter.java index 2076943954..49218b198c 100644 --- a/OsmAnd/src/net/osmand/plus/OsmAndFormatter.java +++ b/OsmAnd/src/net/osmand/plus/OsmAndFormatter.java @@ -26,9 +26,7 @@ import java.text.DecimalFormatSymbols; import java.text.MessageFormat; import java.text.SimpleDateFormat; import java.util.Calendar; -import java.util.LinkedHashMap; import java.util.Locale; -import java.util.Map; import java.util.Map.Entry; import static net.osmand.data.PointDescription.getLocationOlcName; @@ -276,27 +274,13 @@ public class OsmAndFormatter { } } - public static Map getDistanceData(OsmandApplication app, float meters) { - Map results = new LinkedHashMap<>(); - - String kilometersAndMeters = getFormattedDistance(meters, app, true, MetricsConstants.KILOMETERS_AND_METERS); - String milesAndFeet = getFormattedDistance(meters, app, true, MetricsConstants.MILES_AND_FEET); - String milesAndMeters = getFormattedDistance(meters, app, true, MetricsConstants.MILES_AND_METERS); - String milesAndYards = getFormattedDistance(meters, app, true, MetricsConstants.MILES_AND_YARDS); - String nauticalMiles = getFormattedDistance(meters, app, true, MetricsConstants.NAUTICAL_MILES); - - results.put(MetricsConstants.KILOMETERS_AND_METERS, kilometersAndMeters); - results.put(MetricsConstants.MILES_AND_FEET, milesAndFeet); - results.put(MetricsConstants.MILES_AND_METERS, milesAndMeters); - results.put(MetricsConstants.MILES_AND_YARDS, milesAndYards); - results.put(MetricsConstants.NAUTICAL_MILES, nauticalMiles); - - return results; - } - public static String getFormattedAlt(double alt, OsmandApplication ctx) { OsmandSettings settings = ctx.getSettings(); MetricsConstants mc = settings.METRIC_SYSTEM.get(); + return getFormattedAlt(alt, ctx, mc); + } + + public static String getFormattedAlt(double alt, OsmandApplication ctx, MetricsConstants mc) { boolean useFeet = (mc == MetricsConstants.MILES_AND_FEET) || (mc == MetricsConstants.MILES_AND_YARDS); if (!useFeet) { return ((int) (alt + 0.5)) + " " + ctx.getString(R.string.m); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java index aae282d18e..3fb8d61fa8 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java @@ -58,11 +58,13 @@ import java.util.Calendar; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; +import java.util.HashSet; import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.Set; public class AmenityMenuBuilder extends MenuBuilder { @@ -529,9 +531,16 @@ public class AmenityMenuBuilder extends MenuBuilder { if ("ele".equals(key)) { try { float distance = Float.parseFloat(vl); - vl = OsmAndFormatter.getFormattedDistance(distance, app, true, metricSystem); - Map distanceData = OsmAndFormatter.getDistanceData(app, distance); - collapsableView = getDistanceCollapsableView(new LinkedHashSet<>(distanceData.values())); + vl = OsmAndFormatter.getFormattedAlt(distance, app, metricSystem); + String collapsibleVal; + if (metricSystem == MetricsConstants.MILES_AND_FEET || metricSystem == MetricsConstants.MILES_AND_YARDS) { + collapsibleVal = OsmAndFormatter.getFormattedAlt(distance, app, MetricsConstants.KILOMETERS_AND_METERS); + } else { + collapsibleVal = OsmAndFormatter.getFormattedAlt(distance, app, MetricsConstants.MILES_AND_FEET); + } + Set elevationData = new HashSet<>(); + elevationData.add(collapsibleVal); + collapsableView = getDistanceCollapsableView(elevationData); collapsable = true; } catch (NumberFormatException ex) { LOG.error(ex);