From c4bf936b60f68890b6381a665b31b2184320a8ba Mon Sep 17 00:00:00 2001 From: Chumva Date: Wed, 21 Mar 2018 13:15:06 +0200 Subject: [PATCH] added check for name of category --- .../src/net/osmand/osm/AbstractPoiType.java | 7 ----- .../src/net/osmand/osm/MapPoiTypes.java | 12 --------- .../src/net/osmand/plus/AppInitializer.java | 26 ------------------- .../plus/search/QuickSearchListAdapter.java | 16 +++++++----- 4 files changed, 9 insertions(+), 52 deletions(-) diff --git a/OsmAnd-java/src/net/osmand/osm/AbstractPoiType.java b/OsmAnd-java/src/net/osmand/osm/AbstractPoiType.java index c56e70dd84..e3372f551d 100644 --- a/OsmAnd-java/src/net/osmand/osm/AbstractPoiType.java +++ b/OsmAnd-java/src/net/osmand/osm/AbstractPoiType.java @@ -84,13 +84,6 @@ public abstract class AbstractPoiType { return synonyms; } - public String getEnSynonyms() { - if(enSynonyms == null) { - enSynonyms = registry.getEnSynonyms(this); - } - return enSynonyms; - } - public String getEnTranslation() { if(enTranslation == null) { diff --git a/OsmAnd-java/src/net/osmand/osm/MapPoiTypes.java b/OsmAnd-java/src/net/osmand/osm/MapPoiTypes.java index e32ace4ea0..2ad32c681f 100644 --- a/OsmAnd-java/src/net/osmand/osm/MapPoiTypes.java +++ b/OsmAnd-java/src/net/osmand/osm/MapPoiTypes.java @@ -60,8 +60,6 @@ public class MapPoiTypes { String getSynonyms(AbstractPoiType type); String getSynonyms(String keyName); - String getEnSynonyms(AbstractPoiType type); - String getEnSynonyms(String keyName); } public static MapPoiTypes getDefaultNoInit() { @@ -714,16 +712,6 @@ public class MapPoiTypes { return ""; } - public String getEnSynonyms(AbstractPoiType abstractPoiType) { - if (poiTranslator != null) { - String translation = poiTranslator.getEnSynonyms(abstractPoiType); - if (!Algorithms.isEmpty(translation)) { - return translation; - } - } - return ""; - } - public String getEnTranslation(AbstractPoiType abstractPoiType) { if (poiTranslator != null) { String translation = poiTranslator.getEnTranslation(abstractPoiType); diff --git a/OsmAnd/src/net/osmand/plus/AppInitializer.java b/OsmAnd/src/net/osmand/plus/AppInitializer.java index 120bee7d58..348a91897c 100644 --- a/OsmAnd/src/net/osmand/plus/AppInitializer.java +++ b/OsmAnd/src/net/osmand/plus/AppInitializer.java @@ -364,14 +364,6 @@ public class AppInitializer implements IProgress { return getSynonyms(type.getIconKeyName()); } - @Override - public String getEnSynonyms(AbstractPoiType type) { - if (type.getBaseLangType() != null) { - return getSynonyms(type.getBaseLangType()); - } - return getEnSynonyms(type.getIconKeyName()); - } - @Override public String getSynonyms(String keyName) { try { @@ -386,24 +378,6 @@ public class AppInitializer implements IProgress { return ""; } - @Override - public String getEnSynonyms(String keyName) { - if (en == null) { - return Algorithms.capitalizeFirstLetter( - keyName.replace('_', ' ')); - } - try { - Field f = R.string.class.getField("synonyms_poi_" + keyName); - if (f != null) { - Integer in = (Integer) f.get(null); - return en.getString(in); - } - } catch (Exception e) { - LOG.debug("No translation for " + keyName + " " + e.getMessage()); - } - return ""; - } - @Override public String getEnTranslation(AbstractPoiType type) { if (type.getBaseLangType() != null) { diff --git a/OsmAnd/src/net/osmand/plus/search/QuickSearchListAdapter.java b/OsmAnd/src/net/osmand/plus/search/QuickSearchListAdapter.java index 872cc51097..67c0e400be 100644 --- a/OsmAnd/src/net/osmand/plus/search/QuickSearchListAdapter.java +++ b/OsmAnd/src/net/osmand/plus/search/QuickSearchListAdapter.java @@ -374,16 +374,18 @@ public class QuickSearchListAdapter extends ArrayAdapter { SearchUICore searchUICore = searchHelper.getCore(); String searchPhrase = searchUICore.getPhrase().getText(true); SearchPhrase.NameStringMatcher nm = new SearchPhrase.NameStringMatcher(searchPhrase, - CollatorStringMatcher.StringMatcherMode.CHECK_EQUALS_FROM_SPACE); + CollatorStringMatcher.StringMatcherMode.CHECK_STARTS_FROM_SPACE); - for (String syn : synonyms) { + if (!nm.matches(abstractPoiType.getTranslation())) { if (nm.matches(abstractPoiType.getEnTranslation())) { desc = listItem.getTypeName() + " (" + abstractPoiType.getEnTranslation() + ")"; - break; - } - if (nm.matches(syn)) { - desc = listItem.getTypeName() + " (" + syn + ")"; - break; + } else { + for (String syn : synonyms) { + if (nm.matches(syn)) { + desc = listItem.getTypeName() + " (" + syn + ")"; + break; + } + } } } }