Merge pull request #4668 from osmandapp/fix_measurement_tool
Fix measurement tool
This commit is contained in:
commit
f4aae01649
2 changed files with 15 additions and 2 deletions
|
@ -36,6 +36,7 @@ public class MeasurementEditingContext {
|
|||
private int selectedPointPosition = -1;
|
||||
private WptPt originalPointToMove;
|
||||
|
||||
private boolean inAddPointMode;
|
||||
private boolean inSnapToRoadMode;
|
||||
private boolean needUpdateCacheForSnap;
|
||||
private int calculatedPairs;
|
||||
|
@ -53,6 +54,10 @@ public class MeasurementEditingContext {
|
|||
return commandManager;
|
||||
}
|
||||
|
||||
boolean isInAddPointMode() {
|
||||
return inAddPointMode;
|
||||
}
|
||||
|
||||
boolean isInSnapToRoadMode() {
|
||||
return inSnapToRoadMode;
|
||||
}
|
||||
|
@ -82,6 +87,10 @@ public class MeasurementEditingContext {
|
|||
this.originalPointToMove = originalPointToMove;
|
||||
}
|
||||
|
||||
void setInAddPointMode(boolean inAddPointMode) {
|
||||
this.inAddPointMode = inAddPointMode;
|
||||
}
|
||||
|
||||
void setInSnapToRoadMode(boolean inSnapToRoadMode) {
|
||||
this.inSnapToRoadMode = inSnapToRoadMode;
|
||||
}
|
||||
|
|
|
@ -609,6 +609,7 @@ public class MeasurementToolFragment extends Fragment {
|
|||
public void addPointAfterOnClick() {
|
||||
if (measurementLayer != null) {
|
||||
measurementLayer.moveMapToPoint(editingCtx.getSelectedPointPosition());
|
||||
editingCtx.setInAddPointMode(true);
|
||||
editingCtx.splitSegments(editingCtx.getSelectedPointPosition() + 1);
|
||||
}
|
||||
((TextView) mainView.findViewById(R.id.add_point_before_after_text)).setText(mainView.getResources().getString(R.string.add_point_after));
|
||||
|
@ -620,6 +621,7 @@ public class MeasurementToolFragment extends Fragment {
|
|||
public void addPointBeforeOnClick() {
|
||||
if (measurementLayer != null) {
|
||||
measurementLayer.moveMapToPoint(editingCtx.getSelectedPointPosition());
|
||||
editingCtx.setInAddPointMode(true);
|
||||
editingCtx.splitSegments(editingCtx.getSelectedPointPosition());
|
||||
}
|
||||
((TextView) mainView.findViewById(R.id.add_point_before_after_text)).setText(mainView.getResources().getString(R.string.add_point_before));
|
||||
|
@ -875,7 +877,7 @@ public class MeasurementToolFragment extends Fragment {
|
|||
private void cancelModes() {
|
||||
if (editingCtx.getOriginalPointToMove() != null) {
|
||||
cancelMovePointMode();
|
||||
} else if (editingCtx.getSelectedPointPosition() != -1) {
|
||||
} else if (editingCtx.isInAddPointMode()) {
|
||||
cancelAddPointBeforeOrAfterMode();
|
||||
}
|
||||
}
|
||||
|
@ -900,6 +902,7 @@ public class MeasurementToolFragment extends Fragment {
|
|||
switchAddPointBeforeAfterMode(false);
|
||||
editingCtx.splitSegments(editingCtx.getBeforePoints().size() + editingCtx.getAfterPoints().size());
|
||||
editingCtx.setSelectedPointPosition(-1);
|
||||
editingCtx.setInAddPointMode(false);
|
||||
MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
||||
if (measurementLayer != null) {
|
||||
measurementLayer.refreshMap();
|
||||
|
@ -911,6 +914,7 @@ public class MeasurementToolFragment extends Fragment {
|
|||
switchAddPointBeforeAfterMode(false);
|
||||
editingCtx.splitSegments(editingCtx.getBeforePoints().size() + editingCtx.getAfterPoints().size());
|
||||
editingCtx.setSelectedPointPosition(-1);
|
||||
editingCtx.setInAddPointMode(false);
|
||||
MeasurementToolLayer measurementToolLayer = getMeasurementLayer();
|
||||
if (measurementToolLayer != null) {
|
||||
measurementToolLayer.refreshMap();
|
||||
|
@ -1397,7 +1401,7 @@ public class MeasurementToolFragment extends Fragment {
|
|||
if (editingCtx.getOriginalPointToMove() != null) {
|
||||
cancelMovePointMode();
|
||||
return;
|
||||
} else if (editingCtx.getSelectedPointPosition() != -1) {
|
||||
} else if (editingCtx.isInAddPointMode()) {
|
||||
cancelAddPointBeforeOrAfterMode();
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue