From 64345810e025ced8978365766552cb39d7ab1211 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Wed, 18 Nov 2015 22:03:55 +0100 Subject: [PATCH] Fix poi editing --- OsmAnd/res/values/strings.xml | 2 +- .../net/osmand/plus/osmedit/EditPoiData.java | 1 + .../plus/osmedit/EditPoiDialogFragment.java | 8 +++++--- .../dialogs/PoiSubTypeDialogFragment.java | 20 ++++++++++++++----- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index aac2d4a289..ddb9821f44 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -8,7 +8,7 @@ If you are making/correcting English translations make sure: 3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy - --> + --> Places a dashboard button on the map screen Access from map \'Off\' directly launches the map screen diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiData.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiData.java index 313089dda7..731cde3284 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiData.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiData.java @@ -187,6 +187,7 @@ public class EditPoiData { if(pt != null) { tagValues.remove(pt.getOsmTag()); tagValues.remove(pt.getOsmTag2()); + category = pt.getCategory(); } notifyDatasetChanged(POI_TYPE_TAG); } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java index 9a8c05879c..e7497756ad 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java @@ -316,14 +316,16 @@ public class EditPoiDialogFragment extends DialogFragment { HashSet tagsCopy = new HashSet<>(); tagsCopy.addAll(editPoiData.getTagValues().keySet()); tagsCopy.removeAll(BASIC_TAGS); - if (tagsCopy.isEmpty() || editPoiData.getPoiCategory() == getMyApplication().getPoiTypes().getOtherPoiCategory()) { + if (tagsCopy.isEmpty()) { poiTypeEditText.setError(getResources().getString(R.string.please_specify_poi_type)); } else { new SaveWithAdvancedTagsDialogFragment().show(getChildFragmentManager(), "dialog"); } - return; + } else if(editPoiData.getPoiCategory() == getMyApplication().getPoiTypes().getOtherPoiCategory()) { + poiTypeEditText.setError(getResources().getString(R.string.please_specify_poi_type)); + } else { + save(); } - save(); } private void save() { diff --git a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/PoiSubTypeDialogFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/PoiSubTypeDialogFragment.java index c2872e6e68..f02248f683 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/dialogs/PoiSubTypeDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/dialogs/PoiSubTypeDialogFragment.java @@ -1,7 +1,5 @@ package net.osmand.plus.osmedit.dialogs; -import java.util.ArrayList; -import java.util.List; import java.util.Set; import java.util.TreeSet; @@ -27,10 +25,14 @@ public class PoiSubTypeDialogFragment extends DialogFragment { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); final PoiCategory a = poiTypes.getPoiCategoryByName((String) getArguments().getSerializable(KEY_POI_CATEGORY)); Set strings = new TreeSet<>(); - for (PoiType s : a.getPoiTypes()) { - if (!s.isReference() && !s.isNotEditableOsm() && s.getBaseLangType() == null) { - strings.add(s.getTranslation()); + if(a == poiTypes.getOtherPoiCategory()) { + for (PoiCategory category : poiTypes.getCategories(false)) { + if (!category.isNotEditableOsm()) { + addCategory(category, strings); + } } + } else { + addCategory(a, strings); } final String[] subCats = strings.toArray(new String[strings.size()]); builder.setItems(subCats, new DialogInterface.OnClickListener() { @@ -43,6 +45,14 @@ public class PoiSubTypeDialogFragment extends DialogFragment { return builder.create(); } + private void addCategory(final PoiCategory a, Set strings) { + for (PoiType s : a.getPoiTypes()) { + if (!s.isReference() && !s.isNotEditableOsm() && s.getBaseLangType() == null) { + strings.add(s.getTranslation()); + } + } + } + public static PoiSubTypeDialogFragment createInstance(PoiCategory cat) { PoiSubTypeDialogFragment fragment = new PoiSubTypeDialogFragment(); Bundle args = new Bundle();