diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportStopController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportStopController.java index 1acf2d9a35..e66159672b 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportStopController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportStopController.java @@ -267,7 +267,7 @@ public class TransportStopController extends MenuController { List transportStops = findTransportStopsAt(app, loc.getLatitude(), loc.getLongitude(), SHOW_STOPS_RADIUS_METERS); if (transportStops != null) { for (TransportStop stop : transportStops) { - if (localStop == null && transportStop.getLocation().equals(stop.getLocation()) && transportStop.getName().equals(stop.getName())) { + if (localStop == null && transportStop.equals(stop)) { localStop = stop; } else { stopAggregated.addNearbyTransportStop(stop); diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/ChooseRouteFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/ChooseRouteFragment.java index 3352fd6cc2..c0cb21b422 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/ChooseRouteFragment.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/ChooseRouteFragment.java @@ -99,6 +99,7 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe private boolean wasDrawerDisabled; private int currentMenuState; private int routesCount; + private boolean paused; private boolean publicTransportMode; private boolean needAdjustMap; @@ -209,6 +210,7 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe @Override public void onResume() { super.onResume(); + paused = false; MapActivity mapActivity = getMapActivity(); if (mapActivity != null) { mapActivity.getMapLayers().getMapControlsLayer().showMapControlsIfHidden(); @@ -223,6 +225,7 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe public void onPause() { super.onPause(); + paused = true; MapRouteInfoMenu.chooseRoutesVisible = false; MapActivity mapActivity = getMapActivity(); if (mapActivity != null) { @@ -262,6 +265,10 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe return getIcon(id, nightMode ? R.color.icon_color_default_dark : R.color.icon_color_default_light); } + public boolean isPaused() { + return paused; + } + public void analyseOnMap(LatLon location, GpxDisplayItem gpxItem) { OsmandApplication app = requireMyApplication(); final OsmandSettings settings = app.getSettings(); diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java index 6e323e55f5..0daa00fd2c 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java @@ -1890,6 +1890,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener return false; } + @Nullable public WeakReference findMenuFragment() { MapActivity mapActivity = getMapActivity(); if (mapActivity != null) { @@ -1901,6 +1902,18 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener return null; } + @Nullable + public WeakReference findChooseRouteFragment() { + MapActivity mapActivity = getMapActivity(); + if (mapActivity != null) { + Fragment fragment = mapActivity.getSupportFragmentManager().findFragmentByTag(ChooseRouteFragment.TAG); + if (fragment instanceof ChooseRouteFragment && !((ChooseRouteFragment) fragment).isPaused()) { + return new WeakReference<>((ChooseRouteFragment) fragment); + } + } + return null; + } + public static void showLocationOnMap(MapActivity mapActivity, double latitude, double longitude) { RotatedTileBox tb = mapActivity.getMapView().getCurrentRotatedTileBox().copy(); int tileBoxWidthPx = 0; diff --git a/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java b/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java index 346df1df18..d8615c7399 100644 --- a/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java @@ -59,12 +59,14 @@ import net.osmand.plus.mapcontextmenu.controllers.TransportStopController; import net.osmand.plus.mapcontextmenu.other.MapMultiSelectionMenu; import net.osmand.plus.render.MapRenderRepositories; import net.osmand.plus.render.NativeOsmandLibrary; +import net.osmand.plus.routepreparationmenu.ChooseRouteFragment; import net.osmand.plus.routepreparationmenu.MapRouteInfoMenu; import net.osmand.plus.views.AddGpxPointBottomSheetHelper.NewGpxPoint; import net.osmand.plus.views.corenative.NativeCoreContext; import net.osmand.util.Algorithms; import net.osmand.util.MapUtils; +import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -962,6 +964,16 @@ public class ContextMenuLayer extends OsmandMapLayer { boolean processed = hideVisibleMenues(); processed |= menu.onSingleTapOnMap(); + if (!processed && MapRouteInfoMenu.chooseRoutesVisible) { + WeakReference chooseRouteFragmentRef = activity.getMapRouteInfoMenu().findChooseRouteFragment(); + if (chooseRouteFragmentRef != null) { + ChooseRouteFragment chooseRouteFragment = chooseRouteFragmentRef.get(); + if (chooseRouteFragment != null) { + chooseRouteFragment.dismiss(); + processed = true; + } + } + } if (!processed && activity.getMyApplication().getSettings().MAP_EMPTY_STATE_ALLOWED.get()) { activity.getMapLayers().getMapControlsLayer().switchMapControlsVisibility(true); }