Fix #9085
This commit is contained in:
parent
436b7e685e
commit
3a16a63520
2 changed files with 16 additions and 23 deletions
|
@ -26,9 +26,7 @@ import java.text.DecimalFormatSymbols;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import static net.osmand.data.PointDescription.getLocationOlcName;
|
import static net.osmand.data.PointDescription.getLocationOlcName;
|
||||||
|
@ -276,27 +274,13 @@ public class OsmAndFormatter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<MetricsConstants, String> getDistanceData(OsmandApplication app, float meters) {
|
|
||||||
Map<MetricsConstants, String> 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) {
|
public static String getFormattedAlt(double alt, OsmandApplication ctx) {
|
||||||
OsmandSettings settings = ctx.getSettings();
|
OsmandSettings settings = ctx.getSettings();
|
||||||
MetricsConstants mc = settings.METRIC_SYSTEM.get();
|
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);
|
boolean useFeet = (mc == MetricsConstants.MILES_AND_FEET) || (mc == MetricsConstants.MILES_AND_YARDS);
|
||||||
if (!useFeet) {
|
if (!useFeet) {
|
||||||
return ((int) (alt + 0.5)) + " " + ctx.getString(R.string.m);
|
return ((int) (alt + 0.5)) + " " + ctx.getString(R.string.m);
|
||||||
|
|
|
@ -58,11 +58,13 @@ import java.util.Calendar;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class AmenityMenuBuilder extends MenuBuilder {
|
public class AmenityMenuBuilder extends MenuBuilder {
|
||||||
|
|
||||||
|
@ -529,9 +531,16 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
||||||
if ("ele".equals(key)) {
|
if ("ele".equals(key)) {
|
||||||
try {
|
try {
|
||||||
float distance = Float.parseFloat(vl);
|
float distance = Float.parseFloat(vl);
|
||||||
vl = OsmAndFormatter.getFormattedDistance(distance, app, true, metricSystem);
|
vl = OsmAndFormatter.getFormattedAlt(distance, app, metricSystem);
|
||||||
Map<MetricsConstants, String> distanceData = OsmAndFormatter.getDistanceData(app, distance);
|
String collapsibleVal;
|
||||||
collapsableView = getDistanceCollapsableView(new LinkedHashSet<>(distanceData.values()));
|
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<String> elevationData = new HashSet<>();
|
||||||
|
elevationData.add(collapsibleVal);
|
||||||
|
collapsableView = getDistanceCollapsableView(elevationData);
|
||||||
collapsable = true;
|
collapsable = true;
|
||||||
} catch (NumberFormatException ex) {
|
} catch (NumberFormatException ex) {
|
||||||
LOG.error(ex);
|
LOG.error(ex);
|
||||||
|
|
Loading…
Reference in a new issue