From 6dfc7041b52fa80a92af34c25ebe2cf5a4f3e254 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Thu, 21 May 2015 15:04:50 +0300 Subject: [PATCH] Add translations to search --- OsmAnd-java/src/net/osmand/osm/MapPoiTypes.java | 14 +++++++++++--- .../plus/osmedit/EditingPOIDialogProvider.java | 4 ++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/OsmAnd-java/src/net/osmand/osm/MapPoiTypes.java b/OsmAnd-java/src/net/osmand/osm/MapPoiTypes.java index ada83cae23..3039427fac 100644 --- a/OsmAnd-java/src/net/osmand/osm/MapPoiTypes.java +++ b/OsmAnd-java/src/net/osmand/osm/MapPoiTypes.java @@ -126,7 +126,7 @@ public class MapPoiTypes { return null; } - public Map getAllTranslatedNames() { + public Map getAllTranslatedNames(boolean onlyTranslation) { Map translation = new TreeMap(); for(PoiCategory pc : categories) { for(PoiType pt : pc.getPoiTypes()) { @@ -134,6 +134,12 @@ public class MapPoiTypes { continue; } translation.put(pt.getTranslation(), pt); + if(!onlyTranslation) { + String kn = pt.getKeyName().replace('_', ' '); + if(!pt.getTranslation().toLowerCase().contains(kn)) { + translation.put(Algorithms.capitalizeFirstLetterAndLowercase(kn), pt); + } + } } } return translation; @@ -169,8 +175,10 @@ public class MapPoiTypes { for (PoiType pt : pc.getPoiTypes()) { translation.put(pt.getTranslation(), pt); if (!onlyTranslation) { -// translation.put(pt.getKeyName(), pt); - translation.put(Algorithms.capitalizeFirstLetterAndLowercase(pt.getKeyName().replace('_', ' ')), pt); + String kn = pt.getKeyName().replace('_', ' '); + if(!pt.getTranslation().toLowerCase().contains(kn)) { + translation.put(Algorithms.capitalizeFirstLetterAndLowercase(kn), pt); + } } } return translation; diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditingPOIDialogProvider.java b/OsmAnd/src/net/osmand/plus/osmedit/EditingPOIDialogProvider.java index a9b538cec3..1efa1ae3f5 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditingPOIDialogProvider.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditingPOIDialogProvider.java @@ -108,7 +108,7 @@ public class EditingPOIDialogProvider implements DialogProvider { private void prepareProvider() { poiTypes = ((OsmandApplication) activity.getApplication()).getPoiTypes(); - allTranslatedSubTypes = poiTypes.getAllTranslatedNames(); + allTranslatedSubTypes = poiTypes.getAllTranslatedNames(false); settings = ((OsmandApplication) activity.getApplication()).getSettings(); isLocalEdit = true; if (settings.OFFLINE_EDITION.get() || !settings.isInternetConnectionAvailable(true)) { @@ -610,7 +610,7 @@ public class EditingPOIDialogProvider implements DialogProvider { private Map getSubCategoriesMap(PoiCategory poiCategory) { Map subCategories = new LinkedHashMap<>(poiTypes.getAllTranslatedNames(poiCategory, false)); - for (Map.Entry s : poiTypes.getAllTranslatedNames().entrySet()) { + for (Map.Entry s : allTranslatedSubTypes.entrySet()) { if (!subCategories.containsKey(s.getKey())) { subCategories.put(s.getKey(), s.getValue()); }