Show attach roads dialog from follow track

This commit is contained in:
Vitaliy 2020-08-17 23:35:51 +03:00
parent 26d88ccef2
commit ba3fe6f35c
2 changed files with 22 additions and 7 deletions

View file

@ -131,6 +131,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
private boolean progressBarVisible; private boolean progressBarVisible;
private boolean pointsListOpened; private boolean pointsListOpened;
private boolean planRouteMode = false; private boolean planRouteMode = false;
private boolean attachToRoads;
private Boolean saved; private Boolean saved;
private boolean portrait; private boolean portrait;
private boolean nightMode; private boolean nightMode;
@ -158,6 +159,10 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
this.planRouteMode = planRouteMode; this.planRouteMode = planRouteMode;
} }
public void setAttachToRoads(boolean attachToRoads) {
this.attachToRoads = attachToRoads;
}
@Nullable @Nullable
@Override @Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@ -460,10 +465,15 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
initMeasurementMode(newGpxData); initMeasurementMode(newGpxData);
if (editingCtx.isNewData() && planRouteMode && savedInstanceState == null) { if (savedInstanceState == null) {
if (editingCtx.isNewData() && planRouteMode) {
StartPlanRouteBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), StartPlanRouteBottomSheet.showInstance(mapActivity.getSupportFragmentManager(),
createStartPlanRouteListener()); createStartPlanRouteListener());
} else if (attachToRoads && !(editingCtx.isNewData() || editingCtx.hasRoutePoints() || editingCtx.isInSnapToRoadMode())) {
SnapTrackWarningBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), this);
} }
}
return view; return view;
} }
@ -1793,10 +1803,12 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
return showFragment(fragment, fragmentManager); return showFragment(fragment, fragmentManager);
} }
public static boolean showInstance(FragmentManager fragmentManager, MeasurementEditingContext editingCtx, boolean planRoute) { public static boolean showInstance(FragmentManager fragmentManager, MeasurementEditingContext editingCtx,
boolean planRoute, boolean attachToRoads) {
MeasurementToolFragment fragment = new MeasurementToolFragment(); MeasurementToolFragment fragment = new MeasurementToolFragment();
fragment.setEditingCtx(editingCtx); fragment.setEditingCtx(editingCtx);
fragment.setPlanRouteMode(planRoute); fragment.setPlanRouteMode(planRoute);
fragment.setAttachToRoads(attachToRoads);
return showFragment(fragment, fragmentManager); return showFragment(fragment, fragmentManager);
} }

View file

@ -345,10 +345,13 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca
if (card instanceof ImportTrackCard) { if (card instanceof ImportTrackCard) {
importTrack(); importTrack();
} else if (card instanceof TrackEditCard) { } else if (card instanceof TrackEditCard) {
editTrack(); openPlanRoute(false);
close(); close();
} else if (card instanceof SelectTrackCard) { } else if (card instanceof SelectTrackCard) {
updateSelectionMode(true); updateSelectionMode(true);
} else if (card instanceof AttachTrackToRoadsCard) {
openPlanRoute(true);
close();
} else if (card instanceof ReverseTrackCard } else if (card instanceof ReverseTrackCard
|| card instanceof NavigateTrackOptionsCard) { || card instanceof NavigateTrackOptionsCard) {
updateMenu(); updateMenu();
@ -446,7 +449,7 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca
} }
} }
public void editTrack() { public void openPlanRoute(boolean attachToRoads) {
MapActivity mapActivity = getMapActivity(); MapActivity mapActivity = getMapActivity();
if (mapActivity != null && gpxFile != null) { if (mapActivity != null && gpxFile != null) {
QuadRect rect = gpxFile.getRect(); QuadRect rect = gpxFile.getRect();
@ -456,7 +459,7 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca
MeasurementEditingContext editingContext = new MeasurementEditingContext(); MeasurementEditingContext editingContext = new MeasurementEditingContext();
editingContext.setNewGpxData(newGpxData); editingContext.setNewGpxData(newGpxData);
MeasurementToolFragment.showInstance(mapActivity.getSupportFragmentManager(), editingContext, true); MeasurementToolFragment.showInstance(mapActivity.getSupportFragmentManager(), editingContext, true, attachToRoads);
} }
} }