From ec40767031ea3af1abbdb496d124466447b8cfa2 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Sun, 29 Jun 2014 00:49:30 +0200 Subject: [PATCH] Support poi additional tags in special phrases --- OsmAnd/src/net/osmand/plus/OsmAndFormatter.java | 11 +++++++++-- OsmAnd/src/net/osmand/plus/SpecialPhrases.java | 8 ++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/OsmAndFormatter.java b/OsmAnd/src/net/osmand/plus/OsmAndFormatter.java index 582a958f5e..09536e02e0 100644 --- a/OsmAnd/src/net/osmand/plus/OsmAndFormatter.java +++ b/OsmAnd/src/net/osmand/plus/OsmAndFormatter.java @@ -9,6 +9,7 @@ import net.osmand.data.Amenity; import net.osmand.data.AmenityType; import net.osmand.data.City.CityType; import net.osmand.plus.OsmandSettings.MetricsConstants; +import net.osmand.util.Algorithms; import android.content.Context; public class OsmAndFormatter { @@ -201,6 +202,7 @@ public class OsmAndFormatter { StringBuilder d = new StringBuilder(); for(Entry e : amenity.getAdditionalInfo().entrySet()) { String key = e.getKey(); + String vl = e.getValue(); if(Amenity.DESCRIPTION.equals(key)) { if(amenity.getType() == AmenityType.OSMWIKI && shortDescription) { continue; @@ -215,9 +217,14 @@ public class OsmAndFormatter { } d.append(ctx.getString(R.string.website) + ": "); } else { - d.append(e.getKey() + ": "); + vl = SpecialPhrases.getSpecialPhrase(e.getKey() + "_" + e.getValue(), null); + if(vl == null){ + vl = SpecialPhrases.getSpecialPhrase(e.getKey(), + Algorithms.capitalizeFirstLetterAndLowercase(e.getKey())) + ": "; + vl += SpecialPhrases.getSpecialPhrase(e.getValue(), e.getValue()); + } } - d.append(e.getValue()).append('\n'); + d.append(vl).append('\n'); } return d.toString().trim(); } diff --git a/OsmAnd/src/net/osmand/plus/SpecialPhrases.java b/OsmAnd/src/net/osmand/plus/SpecialPhrases.java index 4313c06c6d..f2544998ba 100644 --- a/OsmAnd/src/net/osmand/plus/SpecialPhrases.java +++ b/OsmAnd/src/net/osmand/plus/SpecialPhrases.java @@ -30,17 +30,17 @@ public class SpecialPhrases { */ public static String getSpecialPhrase(String value, String defValue) { if (m == null) { - // do not throw exception because OsmAndApplication is not always initiliazed before + // do not throw exception because OsmAndApplication is not always initiliazed before // this call log.warn("The language has not been set for special phrases"); return value; - + } String specialValue = m.get(value); - if(Algorithms.isEmpty(specialValue)) { + if (Algorithms.isEmpty(specialValue)) { specialValue = defValue; } - return specialValue.replace('_', ' '); + return specialValue == null ? null : specialValue.replace('_', ' '); } /**