Fix poi editing

This commit is contained in:
Victor Shcherb 2015-11-18 22:03:55 +01:00
parent f3584ea58a
commit 64345810e0
4 changed files with 22 additions and 9 deletions

View file

@ -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
-->
-->
<string name="access_from_map_description">Places a dashboard button on the map screen</string>
<string name="access_from_map">Access from map</string>
<string name="show_on_start_description">\'Off\' directly launches the map screen</string>

View file

@ -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);
}

View file

@ -316,14 +316,16 @@ public class EditPoiDialogFragment extends DialogFragment {
HashSet<String> 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() {

View file

@ -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<String> 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<String> 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();