fix export custom poi types with all categories selected

This commit is contained in:
Skalii 2021-04-15 05:30:30 +03:00
parent 9d9dd32503
commit e6ad6f3c38
3 changed files with 18 additions and 3 deletions

View file

@ -542,7 +542,8 @@ public class QuickSearchCustomPoiFragment extends DialogFragment implements OnFi
titleView.setText(textString);
Set<String> subtypes = filter.getAcceptedSubtypes(category);
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));
} else {
StringBuilder sb = new StringBuilder();

View file

@ -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 {

View file

@ -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<PoiUIFilter
JSONObject jsonObject = new JSONObject();
jsonObject.put("name", filter.getName());
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<>();
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);