Disable ability to add new points while GPX Approximation menu is using.

This commit is contained in:
Dima-1 2020-09-01 13:49:28 +03:00
parent fe36f0e8d4
commit f232395a71
3 changed files with 22 additions and 4 deletions

View file

@ -60,6 +60,7 @@ public class MeasurementEditingContext {
private WptPt originalPointToMove; private WptPt originalPointToMove;
private boolean inAddPointMode; private boolean inAddPointMode;
private boolean inApproximationMode;
private int calculatedPairs; private int calculatedPairs;
private int pointsToCalculateSize; private int pointsToCalculateSize;
private CalculationMode lastCalculationMode = WHOLE_TRACK; private CalculationMode lastCalculationMode = WHOLE_TRACK;
@ -175,6 +176,15 @@ public class MeasurementEditingContext {
this.inAddPointMode = inAddPointMode; this.inAddPointMode = inAddPointMode;
} }
public boolean isInApproximationMode() {
return inApproximationMode;
}
public void setInApproximationMode(boolean inApproximationMode) {
this.inApproximationMode = inApproximationMode;
}
@Nullable @Nullable
GpxData getGpxData() { GpxData getGpxData() {
return gpxData; return gpxData;

View file

@ -443,13 +443,18 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
StartPlanRouteBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), StartPlanRouteBottomSheet.showInstance(mapActivity.getSupportFragmentManager(),
createStartPlanRouteListener()); createStartPlanRouteListener());
} else if (!editingCtx.isNewData() && !editingCtx.hasRoutePoints() && !editingCtx.hasRoute() && editingCtx.getPointsCount() > 1) { } else if (!editingCtx.isNewData() && !editingCtx.hasRoutePoints() && !editingCtx.hasRoute() && editingCtx.getPointsCount() > 1) {
SnapTrackWarningBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), this); showSnapTrackWarning(mapActivity);
} }
} }
return view; return view;
} }
private void showSnapTrackWarning(MapActivity mapActivity) {
editingCtx.setInApproximationMode(true);
SnapTrackWarningBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), this);
}
public boolean isInEditMode() { public boolean isInEditMode() {
return !planRouteMode && !editingCtx.isNewData() && !directionMode; return !planRouteMode && !editingCtx.isNewData() && !directionMode;
} }
@ -596,7 +601,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
: RouteBetweenPointsDialogMode.ALL, : RouteBetweenPointsDialogMode.ALL,
editingCtx.getAppMode()); editingCtx.getAppMode());
} else { } else {
SnapTrackWarningBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), this); showSnapTrackWarning(mapActivity);
} }
} }
} }
@ -628,6 +633,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
case SnapTrackWarningBottomSheet.CANCEL_RESULT_CODE: case SnapTrackWarningBottomSheet.CANCEL_RESULT_CODE:
toolBarController.setSaveViewVisible(true); toolBarController.setSaveViewVisible(true);
directionMode = false; directionMode = false;
editingCtx.setInApproximationMode(false);
updateToolbar(); updateToolbar();
break; break;
case SnapTrackWarningBottomSheet.CONTINUE_RESULT_CODE: case SnapTrackWarningBottomSheet.CONTINUE_RESULT_CODE:
@ -693,7 +699,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
mapActions.enterRoutePlanningModeGivenGpx(gpx, appMode, null, null, true, true, MenuState.HEADER_ONLY); mapActions.enterRoutePlanningModeGivenGpx(gpx, appMode, null, null, true, true, MenuState.HEADER_ONLY);
} else { } else {
directionMode = true; directionMode = true;
SnapTrackWarningBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), this); showSnapTrackWarning(mapActivity);
} }
} }
} }
@ -2041,6 +2047,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
@Override @Override
public void onApplyGpxApproximation() { public void onApplyGpxApproximation() {
editingCtx.setInApproximationMode(false);
doAddOrMovePointCommonStuff(); doAddOrMovePointCommonStuff();
if (directionMode) { if (directionMode) {
directionMode = false; directionMode = false;
@ -2066,6 +2073,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
@Override @Override
public void onCancelGpxApproximation() { public void onCancelGpxApproximation() {
editingCtx.getCommandManager().undo(); editingCtx.getCommandManager().undo();
editingCtx.setInApproximationMode(false);
directionMode = false; directionMode = false;
updateSnapToRoadControls(); updateSnapToRoadControls();
updateToolbar(); updateToolbar();

View file

@ -102,7 +102,7 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL
@Override @Override
public boolean onSingleTap(PointF point, RotatedTileBox tileBox) { public boolean onSingleTap(PointF point, RotatedTileBox tileBox) {
if (inMeasurementMode && editingCtx.getSelectedPointPosition() == -1) { if (inMeasurementMode && !editingCtx.isInApproximationMode() && editingCtx.getSelectedPointPosition() == -1) {
if (!overlapped) { if (!overlapped) {
selectPoint(point.x, point.y, true); selectPoint(point.x, point.y, true);
} }