From 9752fb70cd7c4851ca7a133cdaa5405921897a22 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Thu, 17 May 2018 01:21:17 +0200 Subject: [PATCH] Fix issue #5350 --- .../src/net/osmand/osm/MapPoiTypes.java | 33 ++++++++++++------- .../plus/osmedit/AdvancedEditPoiFragment.java | 5 ++- .../plus/osmedit/EditPoiDialogFragment.java | 7 +++- 3 files changed, 32 insertions(+), 13 deletions(-) diff --git a/OsmAnd-java/src/net/osmand/osm/MapPoiTypes.java b/OsmAnd-java/src/net/osmand/osm/MapPoiTypes.java index edad4ed693..1d170ce7e9 100644 --- a/OsmAnd-java/src/net/osmand/osm/MapPoiTypes.java +++ b/OsmAnd-java/src/net/osmand/osm/MapPoiTypes.java @@ -179,23 +179,34 @@ public class MapPoiTypes { if (skipNonEditable && pc.isNotEditableOsm()) { continue; } - for (PoiType pt : pc.getPoiTypes()) { - if (pt.isReference()) { + for (PoiFilter pf : pc.getPoiFilters()) { + if (skipNonEditable && pf.isNotEditableOsm()) { continue; - } - if (pt.getBaseLangType() != null) { - continue; - } - if (skipNonEditable && pt.isNotEditableOsm()) { - continue; - } - translation.put(pt.getKeyName().replace('_', ' ').toLowerCase(), pt); - translation.put(pt.getTranslation().toLowerCase(), pt); + } + addPoiTypesTranslation(skipNonEditable, translation, pf); } + addPoiTypesTranslation(skipNonEditable, translation, pc); } return translation; } + + private void addPoiTypesTranslation(boolean skipNonEditable, Map translation, PoiFilter pf) { + for (PoiType pt : pf.getPoiTypes()) { + if (pt.isReference()) { + continue; + } + if (pt.getBaseLangType() != null) { + continue; + } + if (skipNonEditable && pt.isNotEditableOsm()) { + continue; + } + translation.put(pt.getKeyName().replace('_', ' ').toLowerCase(), pt); + translation.put(pt.getTranslation().toLowerCase(), pt); + } + } + public List getAllTypesTranslatedNames(StringMatcher matcher) { List tm = new ArrayList(); for (PoiCategory pc : categories) { diff --git a/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java index 554c9a9af8..64fd505d75 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java @@ -215,6 +215,8 @@ public class AdvancedEditPoiFragment extends BaseOsmAndFragment }); valueEditText.setText(vl); + valueEditText.setAdapter(valueAdapter); + valueEditText.setThreshold(3); valueEditText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { @@ -279,7 +281,8 @@ public class AdvancedEditPoiFragment extends BaseOsmAndFragment } if (poiType.getEditOsmTag() != null && !poiType.getEditOsmTag().equals(OSMSettings.OSMTagKey.NAME.getValue())) { - stringSet.add(poiType.getEditOsmTag()); + String editOsmTag = poiType.getEditOsmTag(); + stringSet.add(editOsmTag); if (poiType.getOsmTag2() != null) { stringSet.add(poiType.getOsmTag2()); } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java index 3d137243e6..4532a1349f 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java @@ -580,11 +580,16 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment { if(!s.getKeyName().contains("osmand")) { addMapEntryAdapter(subCategories, s.getKeyName().replace('_', ' '), s); } + if(!Algorithms.isEmpty(s.getEditOsmValue())) { + addMapEntryAdapter(subCategories, s.getEditOsmValue().replace('_', ' '), s); + } } } } for (Map.Entry s : editPoiData.getAllTranslatedSubTypes().entrySet()) { - addMapEntryAdapter(subCategories, s.getKey(), s.getValue()); + if(!s.getKey().contains("osmand")) { + addMapEntryAdapter(subCategories, s.getKey(), s.getValue()); + } } final ArrayAdapter adapter; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {