From e6ad6f3c38b913094749d1352f49a366b5dd268a Mon Sep 17 00:00:00 2001 From: Skalii Date: Thu, 15 Apr 2021 05:30:30 +0300 Subject: [PATCH] fix export custom poi types with all categories selected --- .../search/QuickSearchCustomPoiFragment.java | 3 ++- .../search/QuickSearchSubCategoriesFragment.java | 2 +- .../backend/backup/PoiUiFiltersSettingsItem.java | 16 +++++++++++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/search/QuickSearchCustomPoiFragment.java b/OsmAnd/src/net/osmand/plus/search/QuickSearchCustomPoiFragment.java index e211569f4c..2e2b43a943 100644 --- a/OsmAnd/src/net/osmand/plus/search/QuickSearchCustomPoiFragment.java +++ b/OsmAnd/src/net/osmand/plus/search/QuickSearchCustomPoiFragment.java @@ -542,7 +542,8 @@ public class QuickSearchCustomPoiFragment extends DialogFragment implements OnFi titleView.setText(textString); Set subtypes = filter.getAcceptedSubtypes(category); if (categorySelected) { - if (subtypes == null) { + LinkedHashSet poiTypes = filter.getAcceptedTypes().get(category); + if (subtypes == null || (poiTypes != null && category.getPoiTypes().size() == poiTypes.size())) { descView.setText(getString(R.string.shared_string_all)); } else { StringBuilder sb = new StringBuilder(); diff --git a/OsmAnd/src/net/osmand/plus/search/QuickSearchSubCategoriesFragment.java b/OsmAnd/src/net/osmand/plus/search/QuickSearchSubCategoriesFragment.java index 6b6f21aba1..a6dfbdbdec 100644 --- a/OsmAnd/src/net/osmand/plus/search/QuickSearchSubCategoriesFragment.java +++ b/OsmAnd/src/net/osmand/plus/search/QuickSearchSubCategoriesFragment.java @@ -101,7 +101,7 @@ public class QuickSearchSubCategoriesFragment extends BaseOsmAndDialogFragment { updateAddBtnVisibility(); } }); - if (selectAll || acceptedCategories == null) { + if (selectAll || acceptedCategories == null || poiCategory.getPoiTypes().size() == acceptedCategories.size()) { adapter.setSelectedItems(poiTypeList); selectAll = true; } else { diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/PoiUiFiltersSettingsItem.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/PoiUiFiltersSettingsItem.java index 16be1f26bc..3d4d1ba2c8 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/PoiUiFiltersSettingsItem.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/PoiUiFiltersSettingsItem.java @@ -10,6 +10,7 @@ import com.google.gson.reflect.TypeToken; import net.osmand.osm.MapPoiTypes; import net.osmand.osm.PoiCategory; +import net.osmand.osm.PoiType; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.poi.PoiUIFilter; @@ -148,7 +149,20 @@ public class PoiUiFiltersSettingsItem extends CollectionSettingsItem> acceptedTypes = filter.getAcceptedTypes(); + for (PoiCategory category : acceptedTypes.keySet()) { + LinkedHashSet poiTypes = acceptedTypes.get(category); + if (poiTypes == null) { + poiTypes = new LinkedHashSet<>(); + for (PoiType poiType : category.getPoiTypes()) { + poiTypes.add(poiType.getKeyName()); + } + acceptedTypes.put(category, poiTypes); + } + } + + jsonObject.put("acceptedTypes", gson.toJson(acceptedTypes, type)); jsonArray.put(jsonObject); } json.put("items", jsonArray);