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() {
|
||||
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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue