Merge pull request #9859 from osmandapp/plan_route_fixes
Plan route fixes
This commit is contained in:
commit
1cc690ecf5
3 changed files with 71 additions and 36 deletions
|
@ -138,6 +138,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
private boolean pointsListOpened;
|
private boolean pointsListOpened;
|
||||||
private boolean planRouteMode = false;
|
private boolean planRouteMode = false;
|
||||||
private boolean directionMode = false;
|
private boolean directionMode = false;
|
||||||
|
private boolean followTrackMode = false;
|
||||||
private boolean approximationApplied = false;
|
private boolean approximationApplied = false;
|
||||||
private boolean portrait;
|
private boolean portrait;
|
||||||
private boolean nightMode;
|
private boolean nightMode;
|
||||||
|
@ -174,6 +175,10 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
this.directionMode = directionMode;
|
this.directionMode = directionMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setFollowTrackMode(boolean followTrackMode) {
|
||||||
|
this.followTrackMode = followTrackMode;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
@ -441,8 +446,12 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
toolBarController.setOnSaveViewClickListener(new OnClickListener() {
|
toolBarController.setOnSaveViewClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
if (followTrackMode) {
|
||||||
|
startTrackNavigation();
|
||||||
|
} else {
|
||||||
saveChanges(FinalSaveAction.SHOW_SNACK_BAR_AND_CLOSE, false);
|
saveChanges(FinalSaveAction.SHOW_SNACK_BAR_AND_CLOSE, false);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
updateToolbar();
|
updateToolbar();
|
||||||
|
|
||||||
|
@ -486,7 +495,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInEditMode() {
|
public boolean isInEditMode() {
|
||||||
return !planRouteMode && !editingCtx.isNewData() && !directionMode;
|
return !planRouteMode && !editingCtx.isNewData() && !directionMode && !followTrackMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFileName(String fileName) {
|
public void setFileName(String fileName) {
|
||||||
|
@ -628,7 +637,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
toolBarController.setTitle(getString(R.string.route_between_points));
|
toolBarController.setTitle(getString(R.string.route_between_points));
|
||||||
mapActivity.refreshMap();
|
mapActivity.refreshMap();
|
||||||
|
|
||||||
if (editingCtx.isNewData() || editingCtx.hasRoutePoints() || editingCtx.hasRoute() || editingCtx.getPointsCount() < 2) {
|
if (editingCtx.isNewData() || editingCtx.hasRoutePoints() || editingCtx.hasRoute() || editingCtx.getPointsCount() <= 2) {
|
||||||
RouteBetweenPointsBottomSheetDialogFragment.showInstance(mapActivity.getSupportFragmentManager(),
|
RouteBetweenPointsBottomSheetDialogFragment.showInstance(mapActivity.getSupportFragmentManager(),
|
||||||
this, RouteBetweenPointsDialogType.WHOLE_ROUTE_CALCULATION,
|
this, RouteBetweenPointsDialogType.WHOLE_ROUTE_CALCULATION,
|
||||||
editingCtx.getLastCalculationMode() == CalculationMode.NEXT_SEGMENT
|
editingCtx.getLastCalculationMode() == CalculationMode.NEXT_SEGMENT
|
||||||
|
@ -749,7 +758,13 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
private void runNavigation(final GPXFile gpx, final ApplicationMode appMode) {
|
private void runNavigation(final GPXFile gpx, final ApplicationMode appMode) {
|
||||||
MapActivity mapActivity = getMapActivity();
|
MapActivity mapActivity = getMapActivity();
|
||||||
if (mapActivity != null) {
|
if (mapActivity != null) {
|
||||||
if (mapActivity.getMyApplication().getRoutingHelper().isFollowingMode()) {
|
OsmandApplication app = mapActivity.getMyApplication();
|
||||||
|
if (app.getRoutingHelper().isFollowingMode()) {
|
||||||
|
if (followTrackMode) {
|
||||||
|
mapActivity.getMapActions().setGPXRouteParams(gpx);
|
||||||
|
app.getTargetPointsHelper().updateRouteAndRefresh(true);
|
||||||
|
app.getRoutingHelper().recalculateRouteDueToSettingsChange();
|
||||||
|
} else {
|
||||||
mapActivity.getMapActions().stopNavigationActionConfirm(new Runnable() {
|
mapActivity.getMapActions().stopNavigationActionConfirm(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -759,6 +774,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
mapActivity.getMapActions().stopNavigationWithoutConfirm();
|
mapActivity.getMapActions().stopNavigationWithoutConfirm();
|
||||||
mapActivity.getMapActions().enterRoutePlanningModeGivenGpx(gpx, appMode, null, null, true, true, MenuState.HEADER_ONLY);
|
mapActivity.getMapActions().enterRoutePlanningModeGivenGpx(gpx, appMode, null, null, true, true, MenuState.HEADER_ONLY);
|
||||||
|
@ -1675,7 +1691,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
break;
|
break;
|
||||||
case SHOW_IS_SAVED_FRAGMENT:
|
case SHOW_IS_SAVED_FRAGMENT:
|
||||||
SavedTrackBottomSheetDialogFragment.showInstance(mapActivity.getSupportFragmentManager(),
|
SavedTrackBottomSheetDialogFragment.showInstance(mapActivity.getSupportFragmentManager(),
|
||||||
toSave.getName());
|
toSave.getAbsolutePath());
|
||||||
dismiss(mapActivity);
|
dismiss(mapActivity);
|
||||||
break;
|
break;
|
||||||
case SHOW_TOAST:
|
case SHOW_TOAST:
|
||||||
|
@ -1843,8 +1859,16 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
cancelAddPointBeforeOrAfterMode();
|
cancelAddPointBeforeOrAfterMode();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (followTrackMode) {
|
||||||
|
MapActivity mapActivity = getMapActivity();
|
||||||
|
if (mapActivity != null) {
|
||||||
|
mapActivity.getMapLayers().getMapControlsLayer().showRouteInfoControlDialog();
|
||||||
|
dismiss(mapActivity);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
showQuitDialog(hidePointsListFirst);
|
showQuitDialog(hidePointsListFirst);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void showQuitDialog(boolean hidePointsListFirst) {
|
private void showQuitDialog(boolean hidePointsListFirst) {
|
||||||
final MapActivity mapActivity = getMapActivity();
|
final MapActivity mapActivity = getMapActivity();
|
||||||
|
@ -1909,11 +1933,10 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean showInstance(FragmentManager fragmentManager, MeasurementEditingContext editingCtx,
|
public static boolean showInstance(FragmentManager fragmentManager, MeasurementEditingContext editingCtx,
|
||||||
boolean planRoute, boolean directionMode) {
|
boolean followTrackMode) {
|
||||||
MeasurementToolFragment fragment = new MeasurementToolFragment();
|
MeasurementToolFragment fragment = new MeasurementToolFragment();
|
||||||
fragment.setEditingCtx(editingCtx);
|
fragment.setEditingCtx(editingCtx);
|
||||||
fragment.setPlanRouteMode(planRoute);
|
fragment.setFollowTrackMode(followTrackMode);
|
||||||
fragment.setDirectionMode(directionMode);
|
|
||||||
return showFragment(fragment, fragmentManager);
|
return showFragment(fragment, fragmentManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2010,8 +2033,13 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
exitApproximationMode();
|
exitApproximationMode();
|
||||||
doAddOrMovePointCommonStuff();
|
doAddOrMovePointCommonStuff();
|
||||||
updateSnapToRoadControls();
|
updateSnapToRoadControls();
|
||||||
if (directionMode) {
|
if (directionMode || followTrackMode) {
|
||||||
directionMode = false;
|
directionMode = false;
|
||||||
|
startTrackNavigation();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startTrackNavigation() {
|
||||||
MapActivity mapActivity = getMapActivity();
|
MapActivity mapActivity = getMapActivity();
|
||||||
if (mapActivity != null) {
|
if (mapActivity != null) {
|
||||||
if (editingCtx.hasRoute()) {
|
if (editingCtx.hasRoute()) {
|
||||||
|
@ -2029,7 +2057,6 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCancelGpxApproximation() {
|
public void onCancelGpxApproximation() {
|
||||||
|
|
|
@ -1,21 +1,26 @@
|
||||||
package net.osmand.plus.measurementtool;
|
package net.osmand.plus.measurementtool;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.fragment.app.FragmentActivity;
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
|
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.UiUtilities;
|
import net.osmand.plus.UiUtilities;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
import net.osmand.plus.activities.TrackActivity;
|
||||||
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||||
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemButton;
|
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemButton;
|
||||||
import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
|
import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
|
||||||
import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerItem;
|
import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerItem;
|
||||||
import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerSpaceItem;
|
import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerSpaceItem;
|
||||||
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
public class SavedTrackBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
|
public class SavedTrackBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
|
||||||
|
|
||||||
|
@ -34,7 +39,7 @@ public class SavedTrackBottomSheetDialogFragment extends MenuBottomSheetDialogFr
|
||||||
View mainView = View.inflate(UiUtilities.getThemedContext(getMyApplication(), nightMode),
|
View mainView = View.inflate(UiUtilities.getThemedContext(getMyApplication(), nightMode),
|
||||||
R.layout.measure_track_is_saved, null);
|
R.layout.measure_track_is_saved, null);
|
||||||
TextView fileNameView = mainView.findViewById(R.id.file_name);
|
TextView fileNameView = mainView.findViewById(R.id.file_name);
|
||||||
fileNameView.setText(fileName);
|
fileNameView.setText(Algorithms.getFileWithoutDirs(fileName));
|
||||||
items.add(new SimpleBottomSheetItem.Builder()
|
items.add(new SimpleBottomSheetItem.Builder()
|
||||||
.setCustomView(mainView)
|
.setCustomView(mainView)
|
||||||
.create());
|
.create());
|
||||||
|
@ -51,10 +56,13 @@ public class SavedTrackBottomSheetDialogFragment extends MenuBottomSheetDialogFr
|
||||||
.setOnClickListener(new View.OnClickListener() {
|
.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
Activity activity = getActivity();
|
FragmentActivity activity = getActivity();
|
||||||
if (activity instanceof MapActivity) {
|
if (activity != null && !Algorithms.isEmpty(fileName)) {
|
||||||
MeasurementToolFragment.showInstance(((MapActivity) activity).getSupportFragmentManager(),
|
OsmandApplication app = ((OsmandApplication) activity.getApplication());
|
||||||
fileName);
|
Intent newIntent = new Intent(activity, app.getAppCustomization().getTrackActivity());
|
||||||
|
newIntent.putExtra(TrackActivity.TRACK_FILE_NAME, fileName);
|
||||||
|
newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||||
|
activity.startActivity(newIntent);
|
||||||
}
|
}
|
||||||
dismiss();
|
dismiss();
|
||||||
}
|
}
|
||||||
|
|
|
@ -542,7 +542,7 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca
|
||||||
if (useAppMode) {
|
if (useAppMode) {
|
||||||
editingContext.setAppMode(app.getRoutingHelper().getAppMode());
|
editingContext.setAppMode(app.getRoutingHelper().getAppMode());
|
||||||
}
|
}
|
||||||
MeasurementToolFragment.showInstance(mapActivity.getSupportFragmentManager(), editingContext, true, true);
|
MeasurementToolFragment.showInstance(mapActivity.getSupportFragmentManager(), editingContext, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue