diff --git a/src/main/java/de/blau/android/listener/UploadListener.java b/src/main/java/de/blau/android/listener/UploadListener.java index b8bfb2b17..bcd40e689 100755 --- a/src/main/java/de/blau/android/listener/UploadListener.java +++ b/src/main/java/de/blau/android/listener/UploadListener.java @@ -4,10 +4,12 @@ import java.util.Arrays; import java.util.Collection; import java.util.HashMap; +import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.Set; import android.content.DialogInterface; import android.os.SystemClock; @@ -175,9 +177,20 @@ private Map generateAutoSummary(@NonNull List elemen Map result = new HashMap<>(); UndoStorage undoStorage = App.getDelegator().getUndo(); Preset[] presets = App.getCurrentPresets(caller); + List movedNodes = new ArrayList<>(); Actions actions = new Actions(); for (OsmElement current : elements) { - addActionsForElement(actions, undoStorage, presets, current); + addActionsForElement(actions, movedNodes, undoStorage, presets, current); + } + if (!movedNodes.isEmpty()) { + Set modifiedGeometryWays = new HashSet<>(); + for (Node n : movedNodes) { + modifiedGeometryWays.addAll(App.getLogic().getWaysForNode(n)); + } + for (Way w : modifiedGeometryWays) { + PresetItem match = Preset.findBestMatch(caller, presets, w.getTags(), null, w, true); + actions.geometryModified.add(getPresetName(match)); + } } putSummary(V_CREATED, actions.created, result); putSummary(V_MODIFIED, actions.modified, result); @@ -193,11 +206,13 @@ private Map generateAutoSummary(@NonNull List elemen * Note has the side effect of adding changes for ways if way nodes were changed * * @param actions container for the list of actions + * @param movedNodes list of Nodes that have been moved * @param undoStorage our current UndoStorage * @param presets current presets * @param element the OsmElement */ - private void addActionsForElement(@NonNull Actions actions, @NonNull UndoStorage undoStorage, @NonNull Preset[] presets, @NonNull OsmElement element) { + private void addActionsForElement(@NonNull Actions actions, @NonNull List movedNodes, @NonNull UndoStorage undoStorage, @NonNull Preset[] presets, + @NonNull OsmElement element) { final boolean hasTags = element.hasTags(); final Map currentTags = element.getTags(); @@ -224,7 +239,7 @@ private void addActionsForElement(@NonNull Actions actions, @NonNull UndoStorage actions.deleted.add(!originalTags.isEmpty() ? getPresetName(matchOriginal) : getUntaggedString(element)); return; } - addGeometryActions(actions, presets, element, original, hasTags, currentPresetName); + addGeometryActions(actions, presets, element, original, movedNodes, hasTags, currentPresetName); if (!hasTags) { return; } @@ -244,11 +259,12 @@ private void addActionsForElement(@NonNull Actions actions, @NonNull UndoStorage * @param presets current presets * @param element the current element * @param original the elements original state + * @param movedNodes list of moved nodes * @param hasTags true if element has tags * @param currentPresetName the name of the preset for element */ private void addGeometryActions(@NonNull Actions actions, @NonNull Preset[] presets, @NonNull OsmElement element, @Nullable UndoElement original, - final boolean hasTags, @NonNull final String currentPresetName) { + List movedNodes, final boolean hasTags, @NonNull final String currentPresetName) { if (original == null) { return; } @@ -257,7 +273,7 @@ private void addGeometryActions(@NonNull Actions actions, @NonNull Preset[] pres if (hasTags) { actions.geometryModified.add(caller.getString(R.string.moved, currentPresetName)); } - addModifiedWays(presets, (Node) element, actions.geometryModified); + movedNodes.add((Node) element); } if (element instanceof Way && !((UndoWay) original).getNodes().equals(((Way) element).getNodes())) { actions.geometryModified.add(currentPresetName); @@ -267,20 +283,6 @@ private void addGeometryActions(@NonNull Actions actions, @NonNull Preset[] pres } } - /** - * Add actions for all ways modified by moving a node - * - * @param presets current presets - * @param node the Node - * @param geometryModified set of actions to return - */ - private void addModifiedWays(@NonNull Preset[] presets, @NonNull Node node, @NonNull Collection geometryModified) { - for (Way w : App.getLogic().getWaysForNode(node)) { - PresetItem match = Preset.findBestMatch(caller, presets, w.getTags(), null, w, true); - geometryModified.add(getPresetName(match)); - } - } - /** * Get a string for an untagged element *