Merge pull request #11430 from osmandapp/fix_export_custom_poi_types

Fix export custom poi types
This commit is contained in:
Vitaliy 2021-04-18 14:43:54 +03:00 committed by GitHub
commit 7ac56c9359
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 3 deletions

View file

@ -542,7 +542,8 @@ public class QuickSearchCustomPoiFragment extends DialogFragment implements OnFi
titleView.setText(textString); titleView.setText(textString);
Set<String> subtypes = filter.getAcceptedSubtypes(category); Set<String> subtypes = filter.getAcceptedSubtypes(category);
if (categorySelected) { if (categorySelected) {
if (subtypes == null) { LinkedHashSet<String> poiTypes = filter.getAcceptedTypes().get(category);
if (subtypes == null || (poiTypes != null && category.getPoiTypes().size() == poiTypes.size())) {
descView.setText(getString(R.string.shared_string_all)); descView.setText(getString(R.string.shared_string_all));
} else { } else {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();

View file

@ -101,7 +101,7 @@ public class QuickSearchSubCategoriesFragment extends BaseOsmAndDialogFragment {
updateAddBtnVisibility(); updateAddBtnVisibility();
} }
}); });
if (selectAll || acceptedCategories == null) { if (selectAll || acceptedCategories == null || poiCategory.getPoiTypes().size() == acceptedCategories.size()) {
adapter.setSelectedItems(poiTypeList); adapter.setSelectedItems(poiTypeList);
selectAll = true; selectAll = true;
} else { } else {

View file

@ -10,6 +10,7 @@ import com.google.gson.reflect.TypeToken;
import net.osmand.osm.MapPoiTypes; import net.osmand.osm.MapPoiTypes;
import net.osmand.osm.PoiCategory; import net.osmand.osm.PoiCategory;
import net.osmand.osm.PoiType;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.poi.PoiUIFilter; import net.osmand.plus.poi.PoiUIFilter;
@ -148,7 +149,21 @@ public class PoiUiFiltersSettingsItem extends CollectionSettingsItem<PoiUIFilter
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("name", filter.getName()); jsonObject.put("name", filter.getName());
jsonObject.put("filterId", filter.getFilterId()); jsonObject.put("filterId", filter.getFilterId());
jsonObject.put("acceptedTypes", gson.toJson(filter.getAcceptedTypes(), type));
Map<PoiCategory, LinkedHashSet<String>> acceptedTypes = filter.getAcceptedTypes();
for (PoiCategory category : acceptedTypes.keySet()) {
LinkedHashSet<String> poiTypes = acceptedTypes.get(category);
if (poiTypes == null) {
poiTypes = new LinkedHashSet<>();
List<PoiType> types = category.getPoiTypes();
for (PoiType poiType : types) {
poiTypes.add(poiType.getKeyName());
}
acceptedTypes.put(category, poiTypes);
}
}
jsonObject.put("acceptedTypes", gson.toJson(acceptedTypes, type));
jsonArray.put(jsonObject); jsonArray.put(jsonObject);
} }
json.put("items", jsonArray); json.put("items", jsonArray);