diff --git a/OsmAnd/src/net/osmand/plus/poi/PoiUIFilter.java b/OsmAnd/src/net/osmand/plus/poi/PoiUIFilter.java index fd9e5e6b8c..acb822cb97 100644 --- a/OsmAnd/src/net/osmand/plus/poi/PoiUIFilter.java +++ b/OsmAnd/src/net/osmand/plus/poi/PoiUIFilter.java @@ -532,7 +532,11 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable poiAdditionals.put(add.getKeyName().replace('_', ':').replace(' ', ':'), add); poiAdditionals.put(add.getTranslation().replace(' ', ':').toLowerCase(), add); } - if (pt instanceof PoiFilter && !(pt instanceof PoiCategory)) { + if (pt instanceof PoiCategory) { + for (PoiFilter pf : ((PoiCategory) pt).getPoiFilters()) { + fillPoiAdditionals(pf); + } + } else if (pt instanceof PoiFilter) { for (PoiType ps : ((PoiFilter) pt).getPoiTypes()) { fillPoiAdditionals(ps); } diff --git a/OsmAnd/src/net/osmand/plus/search/QuickSearchPoiFilterFragment.java b/OsmAnd/src/net/osmand/plus/search/QuickSearchPoiFilterFragment.java index d48b05eaed..53a9305b74 100644 --- a/OsmAnd/src/net/osmand/plus/search/QuickSearchPoiFilterFragment.java +++ b/OsmAnd/src/net/osmand/plus/search/QuickSearchPoiFilterFragment.java @@ -432,16 +432,16 @@ public class QuickSearchPoiFilterFragment extends DialogFragment { if (!excludedPoiAdditionalCategories.contains("opening_hours")) { String keyNameOpen = app.getString(R.string.shared_string_is_open).replace(' ', '_').toLowerCase(); String keyNameOpen24 = app.getString(R.string.shared_string_is_open_24_7).replace(' ', '_').toLowerCase(); - index = filterByName.indexOf(keyNameOpen); - if (index != -1) { - selectedPoiAdditionals.add(keyNameOpen); - filterByName = filterByName.replaceAll(keyNameOpen, ""); - } index = filterByName.indexOf(keyNameOpen24); if (index != -1) { selectedPoiAdditionals.add(keyNameOpen24); filterByName = filterByName.replaceAll(keyNameOpen24, ""); } + index = filterByName.indexOf(keyNameOpen); + if (index != -1) { + selectedPoiAdditionals.add(keyNameOpen); + filterByName = filterByName.replaceAll(keyNameOpen, ""); + } } if (poiAdditionals != null) { Map> additionalsMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); @@ -472,24 +472,36 @@ public class QuickSearchPoiFilterFragment extends DialogFragment { MapPoiTypes poiTypes = getMyApplication().getPoiTypes(); Set excludedPoiAdditionalCategories = new LinkedHashSet<>(); for (Entry> entry : filter.getAcceptedTypes().entrySet()) { - if (entry.getKey().getExcludedPoiAdditionalCategories() != null) { - excludedPoiAdditionalCategories.addAll(entry.getKey().getExcludedPoiAdditionalCategories()); - } + boolean needTopLevelExclude = false; + Set excluded = new LinkedHashSet<>(); if (entry.getValue() != null) { for (String keyName : entry.getValue()) { PoiType poiType = poiTypes.getPoiTypeByKey(keyName); if (poiType != null) { - collectExcludedPoiAdditionalCategories(poiType, excludedPoiAdditionalCategories); - PoiFilter poiFilter = poiType.getFilter(); - if (poiFilter != null) { - collectExcludedPoiAdditionalCategories(poiFilter, excludedPoiAdditionalCategories); - } - PoiCategory poiCategory = poiType.getCategory(); - if (poiCategory != null) { - collectExcludedPoiAdditionalCategories(poiCategory, excludedPoiAdditionalCategories); + collectExcludedPoiAdditionalCategories(poiType, excluded); + if (!poiType.isReference()) { + needTopLevelExclude = true; + PoiFilter poiFilter = poiType.getFilter(); + if (poiFilter != null) { + collectExcludedPoiAdditionalCategories(poiFilter, excluded); + } + PoiCategory poiCategory = poiType.getCategory(); + if (poiCategory != null) { + collectExcludedPoiAdditionalCategories(poiCategory, excluded); + } } } } + } else { + needTopLevelExclude = true; + } + if (excludedPoiAdditionalCategories.size() == 0) { + excludedPoiAdditionalCategories.addAll(excluded); + } else { + excludedPoiAdditionalCategories.retainAll(excluded); + } + if (needTopLevelExclude && entry.getKey().getExcludedPoiAdditionalCategories() != null) { + excludedPoiAdditionalCategories.addAll(entry.getKey().getExcludedPoiAdditionalCategories()); } } return excludedPoiAdditionalCategories;