From 276e07bc958bd80e802fbe83876d1137fd064440 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Sun, 6 Sep 2020 21:16:58 +0300 Subject: [PATCH] Fix route menu state after follow track --- .../osmand/plus/activities/MapActivity.java | 5 ----- .../FollowTrackFragment.java | 15 +++++++++++++++ .../MapRouteInfoMenu.java | 19 ++++++++++++++++--- .../RouteOptionsBottomSheet.java | 5 +++-- 4 files changed, 34 insertions(+), 10 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index a855bbab9d..f71a6c0fb6 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -127,7 +127,6 @@ import net.osmand.plus.quickaction.QuickActionListFragment; import net.osmand.plus.render.RendererRegistry; import net.osmand.plus.resources.ResourceManager; import net.osmand.plus.routepreparationmenu.ChooseRouteFragment; -import net.osmand.plus.routepreparationmenu.FollowTrackFragment; import net.osmand.plus.routepreparationmenu.MapRouteInfoMenu; import net.osmand.plus.routepreparationmenu.MapRouteInfoMenuFragment; import net.osmand.plus.routing.IRouteInformationListener; @@ -2330,10 +2329,6 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven return getFragment(GpxApproximationFragment.TAG); } - public FollowTrackFragment getFollowTrackFragment() { - return getFragment(FollowTrackFragment.TAG); - } - private SnapTrackWarningBottomSheet getSnapTrackWarningBottomSheet() { return getFragment(SnapTrackWarningBottomSheet.TAG); } diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java index 54747b068e..a23ecd6dd3 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java @@ -297,6 +297,7 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca public void onDestroyView() { super.onDestroyView(); exitTrackAppearanceMode(); + onDismiss(); } @Override @@ -554,4 +555,18 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca log.error(e); } } + + private void onDismiss() { + try { + MapActivity mapActivity = getMapActivity(); + if (mapActivity != null) { + if (!mapActivity.isChangingConfigurations()) { + mapActivity.getMapRouteInfoMenu().cancelSelectionFromTracks(); + } + mapActivity.getMapLayers().getMapControlsLayer().showRouteInfoControlDialog(); + } + } catch (Exception e) { + log.error(e); + } + } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java index 1d57fae5e1..138f0a20ee 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java @@ -147,6 +147,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener private PointType selectFromMapPointType; private int selectFromMapMenuState = MenuState.HEADER_ONLY; private boolean selectFromMapWaypoints; + private boolean selectFromTracks; private boolean showMenu = false; private int showMenuState = DEFAULT_MENU_STATE; @@ -1563,8 +1564,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener if (mapActivity != null) { GPXRouteParamsBuilder routeParams = mapActivity.getRoutingHelper().getCurrentGPXRoute(); if (routeParams != null) { - FollowTrackFragment trackOptionsFragment = new FollowTrackFragment(); - FollowTrackFragment.showInstance(mapActivity, trackOptionsFragment); + selectTrack(); } } } @@ -1950,6 +1950,19 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener } } + public void selectTrack() { + selectFromTracks = true; + MapActivity mapActivity = getMapActivity(); + if (mapActivity != null) { + FollowTrackFragment trackOptionsFragment = new FollowTrackFragment(); + FollowTrackFragment.showInstance(mapActivity, trackOptionsFragment); + } + } + + public void cancelSelectionFromTracks() { + selectFromTracks = false; + } + public void setupFields(PointType pointType) { View mainView = getMainView(); if (mainView != null) { @@ -2249,7 +2262,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener if (switched) { mapActivity.getMapLayers().getMapControlsLayer().switchToRouteFollowingLayout(); } - if (mapActivity.getPointToNavigate() == null && !selectFromMapTouch && mapActivity.getFollowTrackFragment() == null) { + if (mapActivity.getPointToNavigate() == null && !selectFromMapTouch && !selectFromTracks) { mapActivity.getMapActions().stopNavigationWithoutConfirm(); } mapActivity.updateStatusBarColor(); diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteOptionsBottomSheet.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteOptionsBottomSheet.java index c6d3df05ca..5e4ee7722a 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteOptionsBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteOptionsBottomSheet.java @@ -367,8 +367,9 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment { .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - FollowTrackFragment trackOptionsFragment = new FollowTrackFragment(); - FollowTrackFragment.showInstance(mapActivity, trackOptionsFragment); + MapRouteInfoMenu mapRouteInfoMenu = mapActivity.getMapRouteInfoMenu(); + mapRouteInfoMenu.hide(); + mapRouteInfoMenu.selectTrack(); dismiss(); } })