From ddcd80c19607dacce0e0038e775062c19d20adad Mon Sep 17 00:00:00 2001 From: GaidamakUA Date: Fri, 13 Nov 2015 16:44:20 +0200 Subject: [PATCH] Edit poi fixes --- .../plus/osmedit/AdvancedEditPoiFragment.java | 29 ++++++++++++------- .../plus/osmedit/EditPoiDialogFragment.java | 2 +- .../plus/osmedit/OpenstreetmapLocalUtil.java | 8 ++--- .../plus/osmedit/OpenstreetmapRemoteUtil.java | 4 +++ 4 files changed, 28 insertions(+), 15 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java index cd1e960b29..cf350d4ce4 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/AdvancedEditPoiFragment.java @@ -97,22 +97,16 @@ public class AdvancedEditPoiFragment extends Fragment public void onResume() { super.onResume(); mAdapter.updateViews(); + updateName(); + updatePoiType(); mTagsChangedListener = new EditPoiData.TagsChangedListener() { @Override public void onTagsChanged(String anyTag) { - String value = getData().getTagValues().get(anyTag); if (Algorithms.objectEquals(anyTag, OSMSettings.OSMTagKey.NAME.getValue())) { - nameTextView.setText(value); + updateName(); } if (Algorithms.objectEquals(anyTag, EditPoiData.POI_TYPE_TAG)) { - PoiType pt = getData().getPoiTypeDefined(); - if (pt != null) { - amenityTagTextView.setText(pt.getOsmTag()); - amenityTextView.setText(pt.getOsmValue()); - } else { - amenityTagTextView.setText(getData().getPoiCategory().getDefaultTag()); - amenityTextView.setText(getData().getPoiTypeString()); - } + updatePoiType(); } } }; @@ -145,6 +139,21 @@ public class AdvancedEditPoiFragment extends Fragment } } + private void updateName() { + nameTextView.setText(getData().getTag(OSMSettings.OSMTagKey.NAME.getValue())); + } + + private void updatePoiType() { + PoiType pt = getData().getPoiTypeDefined(); + if (pt != null) { + amenityTagTextView.setText(pt.getOsmTag()); + amenityTextView.setText(pt.getOsmValue()); + } else { + amenityTagTextView.setText(getData().getPoiCategory().getDefaultTag()); + amenityTextView.setText(getData().getPoiTypeString()); + } + } + public class TagAdapterLinearLayoutHack { private final LinearLayout linearLayout; private final EditPoiData editPoiData; diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java index de4eb96c23..279be74157 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java @@ -257,7 +257,7 @@ public class EditPoiDialogFragment extends DialogFragment { }); poiNameEditText.setOnEditorActionListener(mOnEditorActionListener); poiTypeEditText.setOnEditorActionListener(mOnEditorActionListener); - poiTypeEditText.setText(editPoiData.getPoiTypeString()); + poiTypeEditText.setText(editPoiData.getPoiTypeDefined().getTranslation()); Button saveButton = (Button) view.findViewById(R.id.saveButton); saveButton.setText(mOpenstreetmapUtil instanceof OpenstreetmapRemoteUtil diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapLocalUtil.java b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapLocalUtil.java index cfd2f8a38c..481080f15f 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapLocalUtil.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapLocalUtil.java @@ -16,7 +16,7 @@ public class OpenstreetmapLocalUtil implements OpenstreetmapUtil { private final Context ctx; - public final static Log log = PlatformUtil.getLog(OpenstreetmapLocalUtil.class); + public final static Log LOG = PlatformUtil.getLog(OpenstreetmapLocalUtil.class); private OsmEditingPlugin plugin; @@ -61,14 +61,14 @@ public class OpenstreetmapLocalUtil implements OpenstreetmapUtil { Node entity = new Node(n.getLocation().getLatitude(), n.getLocation().getLongitude(), nodeId); - entity.putTag(poiType.getOsmTag(), poiType.getOsmValue()); + entity.putTag(EditPoiData.POI_TYPE_TAG, poiType.getOsmValue()); if(poiType.getOsmTag2() != null) { entity.putTag(poiType.getOsmTag2(), poiType.getOsmValue2()); } entity.putTag(OSMTagKey.NAME.getValue(), n.getName()); entity.putTag(OSMTagKey.OPENING_HOURS.getValue(), n.getOpeningHours()); - - // check whether this is node (because id of node could be the same as relation) + + // check whether this is node (because id of node could be the same as relation) if(entity != null && MapUtils.getDistance(entity.getLatLon(), n.getLocation()) < 50){ return entity; } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java index e4ed76532e..89fbbd8036 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OpenstreetmapRemoteUtil.java @@ -7,6 +7,7 @@ import android.widget.Toast; import net.osmand.PlatformUtil; import net.osmand.access.AccessibleToast; import net.osmand.data.Amenity; +import net.osmand.osm.PoiType; import net.osmand.osm.edit.Entity; import net.osmand.osm.edit.Entity.EntityId; import net.osmand.osm.edit.Entity.EntityType; @@ -361,6 +362,9 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil { entityInfo = st.getRegisteredEntityInfo().get(id); // check whether this is node (because id of node could be the same as relation) if (entity != null && MapUtils.getDistance(entity.getLatLon(), n.getLocation()) < 50) { + PoiType poiType = n.getType().getPoiTypeByKeyName(n.getSubType()); + entity.removeTag(poiType.getOsmTag()); + entity.putTag(EditPoiData.POI_TYPE_TAG, poiType.getOsmValue()); return entity; } return null;