Fix osm editing
This commit is contained in:
parent
153f98a7d7
commit
5d9962e7fb
4 changed files with 36 additions and 13 deletions
|
@ -432,6 +432,7 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
|
|||
}
|
||||
}
|
||||
String poiTypeTag = editPoiData.getTagValues().get(EditPoiData.POI_TYPE_TAG);
|
||||
String comment = "";
|
||||
if (poiTypeTag != null) {
|
||||
final PoiType poiType = editPoiData.getAllTranslatedSubTypes().get(poiTypeTag.trim().toLowerCase());
|
||||
if (poiType != null) {
|
||||
|
@ -448,8 +449,9 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
|
|||
if (offlineEdit && !Algorithms.isEmpty(poiTypeTag)) {
|
||||
node.putTagNoLC(EditPoiData.POI_TYPE_TAG, poiTypeTag);
|
||||
}
|
||||
}
|
||||
commitNode(action, node, mOpenstreetmapUtil.getEntityInfo(node.getId()), "", false,
|
||||
comment = OsmPoint.displayAction.get(action) + " " + poiTypeTag;
|
||||
}
|
||||
commitNode(action, node, mOpenstreetmapUtil.getEntityInfo(node.getId()), comment, false,
|
||||
new CallbackWithObject<Node>() {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -117,12 +117,7 @@ public class OpenstreetmapsDbHelper extends SQLiteOpenHelper {
|
|||
}
|
||||
p.setEntity(entity);
|
||||
p.setAction(query.getString(3));
|
||||
String comment = query.getString(4);
|
||||
if (comment.equals("")) {
|
||||
String action = OsmPoint.stringAction.get(p.getAction());
|
||||
comment = action.substring(0, 1).toUpperCase() + action.substring(1) + " " + entity.getTag("poi_type_tag");
|
||||
}
|
||||
p.setComment(comment);
|
||||
p.setComment(query.getString(4));
|
||||
points.add(p);
|
||||
} while (query.moveToNext());
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ public abstract class OsmPoint implements Serializable {
|
|||
public static enum Action {CREATE, MODIFY, DELETE, REOPEN};
|
||||
|
||||
public static final Map<Action, String> stringAction = new HashMap<Action, String>();
|
||||
public static final Map<Action, String> displayAction = new HashMap<Action, String>();
|
||||
public static final Map<String, Action> actionString = new HashMap<String, Action>();
|
||||
static {
|
||||
stringAction.put(Action.CREATE, "create");
|
||||
|
@ -18,6 +19,11 @@ public abstract class OsmPoint implements Serializable {
|
|||
stringAction.put(Action.DELETE, "delete");
|
||||
stringAction.put(Action.REOPEN, "reopen");
|
||||
|
||||
displayAction.put(Action.CREATE, "Add");
|
||||
displayAction.put(Action.MODIFY, "Edit");
|
||||
displayAction.put(Action.DELETE, "Delete");
|
||||
displayAction.put(Action.REOPEN, "Reopen");
|
||||
|
||||
actionString.put("create", Action.CREATE);
|
||||
actionString.put("modify", Action.MODIFY);
|
||||
actionString.put("reopen", Action.REOPEN);
|
||||
|
|
|
@ -33,7 +33,7 @@ public class SendPoiDialogFragment extends DialogFragment {
|
|||
public static final String TAG = "SendPoiDialogFragment";
|
||||
public static final String OPENSTREETMAP_POINT = "openstreetmap_point";
|
||||
public static final String POI_UPLOADER_TYPE = "poi_uploader_type";
|
||||
private static String comment;
|
||||
private String comment = "";
|
||||
|
||||
public enum PoiUploaderType {
|
||||
SIMPLE,
|
||||
|
@ -62,15 +62,36 @@ public class SendPoiDialogFragment extends DialogFragment {
|
|||
passwordEditText.setText(settings.USER_PASSWORD.get());
|
||||
boolean hasPoiGroup = false;
|
||||
assert poi != null;
|
||||
String addGroup = "";
|
||||
String editGroup = "";
|
||||
String deleteGroup = "";
|
||||
String reopenGroup = "";
|
||||
for (OsmPoint p : poi) {
|
||||
if (p.getGroup() == OsmPoint.Group.POI) {
|
||||
if (comment == null || comment.equals("")) {
|
||||
comment = ((OpenstreetmapPoint) p).getComment();
|
||||
String action = OsmPoint.displayAction.get(p.getAction());
|
||||
String type = ((OpenstreetmapPoint) p).getEntity().getTag("poi_type_tag");
|
||||
if (action.equals(OsmPoint.displayAction.get(OsmPoint.Action.CREATE))) {
|
||||
addGroup += (type + ", ");
|
||||
} else if (action.equals(OsmPoint.displayAction.get(OsmPoint.Action.MODIFY))) {
|
||||
editGroup += (type + ", ");
|
||||
} else if (action.equals(OsmPoint.displayAction.get(OsmPoint.Action.DELETE))) {
|
||||
deleteGroup += (type + ", ");
|
||||
} else if (action.equals(OsmPoint.displayAction.get(OsmPoint.Action.REOPEN))) {
|
||||
reopenGroup += (type + ", ");
|
||||
}
|
||||
hasPoiGroup = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!addGroup.equals("")) {
|
||||
comment += OsmPoint.displayAction.get(OsmPoint.Action.CREATE) + " " + addGroup.substring(0, addGroup.length() - 2) + "; ";
|
||||
} else if (!editGroup.equals("")) {
|
||||
comment += OsmPoint.displayAction.get(OsmPoint.Action.MODIFY) + " " + editGroup.substring(0, editGroup.length() - 2) + "; ";
|
||||
} else if (!deleteGroup.equals("")) {
|
||||
comment += OsmPoint.displayAction.get(OsmPoint.Action.MODIFY) + " " + deleteGroup.substring(0, deleteGroup.length() - 2) + "; ";
|
||||
} else if (!reopenGroup.equals("")) {
|
||||
comment += OsmPoint.displayAction.get(OsmPoint.Action.MODIFY) + " " + reopenGroup.substring(0, reopenGroup.length() - 2) + "; ";
|
||||
}
|
||||
comment = comment.substring(0, comment.length() - 2);
|
||||
messageEditText.setText(comment);
|
||||
final boolean hasPOI = hasPoiGroup;
|
||||
messageLabel.setVisibility(hasPOI ? View.VISIBLE : View.GONE);
|
||||
|
@ -100,7 +121,6 @@ public class SendPoiDialogFragment extends DialogFragment {
|
|||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if (progressDialogPoiUploader != null) {
|
||||
comment = messageEditText.getText().toString();
|
||||
settings.USER_NAME.set(userNameEditText.getText().toString());
|
||||
settings.USER_PASSWORD.set(passwordEditText.getText().toString());
|
||||
if (comment.length() > 0) {
|
||||
|
|
Loading…
Reference in a new issue