Edit poi fixes
This commit is contained in:
parent
43939af97b
commit
ddcd80c196
4 changed files with 28 additions and 15 deletions
|
@ -97,22 +97,16 @@ public class AdvancedEditPoiFragment extends Fragment
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
mAdapter.updateViews();
|
mAdapter.updateViews();
|
||||||
|
updateName();
|
||||||
|
updatePoiType();
|
||||||
mTagsChangedListener = new EditPoiData.TagsChangedListener() {
|
mTagsChangedListener = new EditPoiData.TagsChangedListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onTagsChanged(String anyTag) {
|
public void onTagsChanged(String anyTag) {
|
||||||
String value = getData().getTagValues().get(anyTag);
|
|
||||||
if (Algorithms.objectEquals(anyTag, OSMSettings.OSMTagKey.NAME.getValue())) {
|
if (Algorithms.objectEquals(anyTag, OSMSettings.OSMTagKey.NAME.getValue())) {
|
||||||
nameTextView.setText(value);
|
updateName();
|
||||||
}
|
}
|
||||||
if (Algorithms.objectEquals(anyTag, EditPoiData.POI_TYPE_TAG)) {
|
if (Algorithms.objectEquals(anyTag, EditPoiData.POI_TYPE_TAG)) {
|
||||||
PoiType pt = getData().getPoiTypeDefined();
|
updatePoiType();
|
||||||
if (pt != null) {
|
|
||||||
amenityTagTextView.setText(pt.getOsmTag());
|
|
||||||
amenityTextView.setText(pt.getOsmValue());
|
|
||||||
} else {
|
|
||||||
amenityTagTextView.setText(getData().getPoiCategory().getDefaultTag());
|
|
||||||
amenityTextView.setText(getData().getPoiTypeString());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -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 {
|
public class TagAdapterLinearLayoutHack {
|
||||||
private final LinearLayout linearLayout;
|
private final LinearLayout linearLayout;
|
||||||
private final EditPoiData editPoiData;
|
private final EditPoiData editPoiData;
|
||||||
|
|
|
@ -257,7 +257,7 @@ public class EditPoiDialogFragment extends DialogFragment {
|
||||||
});
|
});
|
||||||
poiNameEditText.setOnEditorActionListener(mOnEditorActionListener);
|
poiNameEditText.setOnEditorActionListener(mOnEditorActionListener);
|
||||||
poiTypeEditText.setOnEditorActionListener(mOnEditorActionListener);
|
poiTypeEditText.setOnEditorActionListener(mOnEditorActionListener);
|
||||||
poiTypeEditText.setText(editPoiData.getPoiTypeString());
|
poiTypeEditText.setText(editPoiData.getPoiTypeDefined().getTranslation());
|
||||||
|
|
||||||
Button saveButton = (Button) view.findViewById(R.id.saveButton);
|
Button saveButton = (Button) view.findViewById(R.id.saveButton);
|
||||||
saveButton.setText(mOpenstreetmapUtil instanceof OpenstreetmapRemoteUtil
|
saveButton.setText(mOpenstreetmapUtil instanceof OpenstreetmapRemoteUtil
|
||||||
|
|
|
@ -16,7 +16,7 @@ public class OpenstreetmapLocalUtil implements OpenstreetmapUtil {
|
||||||
|
|
||||||
private final Context ctx;
|
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;
|
private OsmEditingPlugin plugin;
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ public class OpenstreetmapLocalUtil implements OpenstreetmapUtil {
|
||||||
Node entity = new Node(n.getLocation().getLatitude(),
|
Node entity = new Node(n.getLocation().getLatitude(),
|
||||||
n.getLocation().getLongitude(),
|
n.getLocation().getLongitude(),
|
||||||
nodeId);
|
nodeId);
|
||||||
entity.putTag(poiType.getOsmTag(), poiType.getOsmValue());
|
entity.putTag(EditPoiData.POI_TYPE_TAG, poiType.getOsmValue());
|
||||||
if(poiType.getOsmTag2() != null) {
|
if(poiType.getOsmTag2() != null) {
|
||||||
entity.putTag(poiType.getOsmTag2(), poiType.getOsmValue2());
|
entity.putTag(poiType.getOsmTag2(), poiType.getOsmValue2());
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import android.widget.Toast;
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.access.AccessibleToast;
|
import net.osmand.access.AccessibleToast;
|
||||||
import net.osmand.data.Amenity;
|
import net.osmand.data.Amenity;
|
||||||
|
import net.osmand.osm.PoiType;
|
||||||
import net.osmand.osm.edit.Entity;
|
import net.osmand.osm.edit.Entity;
|
||||||
import net.osmand.osm.edit.Entity.EntityId;
|
import net.osmand.osm.edit.Entity.EntityId;
|
||||||
import net.osmand.osm.edit.Entity.EntityType;
|
import net.osmand.osm.edit.Entity.EntityType;
|
||||||
|
@ -361,6 +362,9 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil {
|
||||||
entityInfo = st.getRegisteredEntityInfo().get(id);
|
entityInfo = st.getRegisteredEntityInfo().get(id);
|
||||||
// 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) {
|
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 entity;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Reference in a new issue