From 00b135d8816e5acf4f3a6aa4d438861d7fa1ade6 Mon Sep 17 00:00:00 2001 From: Chumva Date: Thu, 7 Mar 2019 11:54:26 +0200 Subject: [PATCH] Fix #6582 --- .../osmand/plus/activities/MapActivity.java | 23 ++++--- .../ShowRouteInfoDialogFragment.java | 4 +- .../plus/helpers/ExternalApiHelper.java | 2 +- .../plus/helpers/WaypointDialogHelper.java | 2 +- .../MapContextMenuFragment.java | 5 +- .../FavouritesBottomSheetMenuFragment.java | 2 +- .../other/MapMultiSelectionMenuFragment.java | 2 +- .../MapMarkerSelectionFragment.java | 2 +- .../AddPointBottomSheetDialog.java | 6 +- .../AvoidRoadsBottomSheetDialogFragment.java | 8 +-- .../MapRouteInfoMenu.java | 61 +++++++++---------- .../MapRouteInfoMenuFragment.java | 2 +- .../RouteOptionsBottomSheet.java | 8 +-- .../RoutingOptionsHelper.java | 2 +- .../WaypointsFragment.java | 2 +- .../osmand/plus/views/MapControlsLayer.java | 8 +-- .../mapwidgets/MapInfoWidgetsFactory.java | 2 +- .../mapwidgets/MapMarkersWidgetsFactory.java | 2 +- .../mapwidgets/RouteInfoWidgetsFactory.java | 4 +- 19 files changed, 74 insertions(+), 73 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index ff178b6388..1eb4f3e2c4 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -163,6 +163,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven private MapViewTrackingUtilities mapViewTrackingUtilities; private static MapContextMenu mapContextMenu = new MapContextMenu(); + private static MapRouteInfoMenu mapRouteInfoMenu = new MapRouteInfoMenu(); private static Intent prevActivityIntent = null; private List activityResultListeners = new ArrayList<>(); @@ -225,6 +226,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven landscapeLayout = !portraitMode && !largeDevice; mapViewTrackingUtilities = app.getMapViewTrackingUtilities(); mapContextMenu.setMapActivity(this); + mapRouteInfoMenu.setMapActivity(this); super.onCreate(savedInstanceState); // Full screen is not used here @@ -445,10 +447,10 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven @Override public void updateProgress(int progress) { - mapLayers.getMapControlsLayer().getMapRouteInfoMenu().updateRouteCalculationProgress(progress); + mapRouteInfoMenu.updateRouteCalculationProgress(progress); dashboardOnMap.updateRouteCalculationProgress(progress); if (findViewById(R.id.MapHudButtonsOverlay).getVisibility() == View.VISIBLE) { - if (MapRouteInfoMenu.isVisible() || dashboardOnMap.isVisible()) { + if (mapRouteInfoMenu.isVisible() || dashboardOnMap.isVisible()) { pb.setVisibility(View.GONE); return; } @@ -494,7 +496,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven @Override public void finish() { - mapLayers.getMapControlsLayer().getMapRouteInfoMenu().routeCalculationFinished(); + mapRouteInfoMenu.routeCalculationFinished(); dashboardOnMap.routeCalculationFinished(); pb.setVisibility(View.GONE); } @@ -1117,9 +1119,9 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven TrackDetailsMenu trackDetailsMenu = mapLayers.getMapControlsLayer().getTrackDetailsMenu(); trackDetailsMenu.setGpxItem((GpxDisplayItem) toShow); trackDetailsMenu.show(); - } else if (MapRouteInfoMenu.isVisible()) { + } else if (mapRouteInfoMenu.isVisible()) { mapContextMenu.showMinimized(latLonToShow, mapLabelToShow, toShow); - mapLayers.getMapControlsLayer().getMapRouteInfoMenu().updateMenu(); + mapRouteInfoMenu.updateMenu(); MapRouteInfoMenu.showLocationOnMap(this, latLonToShow.getLatitude(), latLonToShow.getLongitude()); } else if (toShow instanceof QuadRect) { QuadRect qr = (QuadRect) toShow; @@ -1258,6 +1260,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven protected void onDestroy() { super.onDestroy(); mapContextMenu.setMapActivity(null); + mapRouteInfoMenu.setMapActivity(null); unregisterReceiver(screenOffReceiver); app.getAidlApi().onDestroyMapActivity(this); FailSafeFuntions.quitRouteRestoreDialog(); @@ -1581,6 +1584,11 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven return mapContextMenu; } + @NonNull + public MapRouteInfoMenu getMapRouteInfoMenu() { + return mapRouteInfoMenu; + } + public void openDrawer() { mapActions.updateDrawerMenu(); boolean animate = !settings.DO_NOT_USE_ANIMATIONS.get(); @@ -1768,8 +1776,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven @Override public void newRouteIsCalculated(boolean newRoute, ValueHolder showToast) { - MapRouteInfoMenu routeInfoMenu = mapLayers.getMapControlsLayer().getMapRouteInfoMenu(); - if (routeInfoMenu.isSelectFromMapTouch()) { + if (mapRouteInfoMenu.isSelectFromMapTouch()) { return; } @@ -1801,7 +1808,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven int tileBoxWidthPx = 0; int tileBoxHeightPx = 0; - WeakReference fragmentRef = routeInfoMenu.findMenuFragment(); + WeakReference fragmentRef = mapRouteInfoMenu.findMenuFragment(); if (fragmentRef != null) { MapRouteInfoMenuFragment f = fragmentRef.get(); if (landscapeLayout) { diff --git a/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoDialogFragment.java b/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoDialogFragment.java index b2c22fe3f2..1f2a44a91e 100644 --- a/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoDialogFragment.java @@ -1516,8 +1516,8 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment { false, gpxItem); - final MapRouteInfoMenu mapRouteInfoMenu = activity.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu(); - if (MapRouteInfoMenu.isVisible()) { + final MapRouteInfoMenu mapRouteInfoMenu = activity.getMapRouteInfoMenu(); + if (mapRouteInfoMenu.isVisible()) { // We arrived here by the route info menu. // First, we close it and then show the details. mapRouteInfoMenu.setOnDismissListener(new OnDismissListener() { diff --git a/OsmAnd/src/net/osmand/plus/helpers/ExternalApiHelper.java b/OsmAnd/src/net/osmand/plus/helpers/ExternalApiHelper.java index c71623bef1..6bc43505bb 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/ExternalApiHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/ExternalApiHelper.java @@ -619,7 +619,7 @@ public class ExternalApiHelper { } mapActivity.getMapActions().enterRoutePlanningModeGivenGpx(gpx, from, fromDesc, true, false); if (!app.getTargetPointsHelper().checkPointToNavigateShort()) { - mapActivity.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu().show(); + mapActivity.getMapRouteInfoMenu().show(); } else { if (app.getSettings().APPLICATION_MODE.get() != routingHelper.getAppMode()) { app.getSettings().APPLICATION_MODE.set(routingHelper.getAppMode()); diff --git a/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java b/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java index 306a0b9b37..ede5bb6cca 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java @@ -234,7 +234,7 @@ public class WaypointDialogHelper { private static void updateRouteInfoMenu(Activity ctx) { if (ctx instanceof MapActivity) { - ((MapActivity) ctx).getMapLayers().getMapControlsLayer().getMapRouteInfoMenu().updateMenu(); + ((MapActivity) ctx).getMapRouteInfoMenu().updateMenu(); } } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java index 938f64992c..db2afa5e58 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java @@ -56,7 +56,6 @@ import net.osmand.plus.mapcontextmenu.MenuController.MenuState; import net.osmand.plus.mapcontextmenu.MenuController.TitleButtonController; import net.osmand.plus.mapcontextmenu.MenuController.TitleProgressController; import net.osmand.plus.mapcontextmenu.controllers.TransportStopController; -import net.osmand.plus.routepreparationmenu.MapRouteInfoMenu; import net.osmand.plus.transport.TransportStopRoute; import net.osmand.plus.views.AnimateDraggingMapThread; import net.osmand.plus.views.OsmandMapTileView; @@ -1247,11 +1246,11 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo @Override public void onResume() { super.onResume(); - if (!menu.isActive() || MapRouteInfoMenu.isVisible()) { + MapActivity mapActivity = getMapActivity(); + if (!menu.isActive() || (mapActivity != null && mapActivity.getMapRouteInfoMenu().isVisible())) { dismissMenu(); return; } - MapActivity mapActivity = getMapActivity(); if (mapActivity != null) { updateLocationViewCache = mapActivity.getMyApplication().getUIUtilities().getUpdateLocationViewCache(); mapActivity.getMapViewTrackingUtilities().setContextMenu(menu); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/FavouritesBottomSheetMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/FavouritesBottomSheetMenuFragment.java index 7e177095ac..3ba926d0d3 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/FavouritesBottomSheetMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/FavouritesBottomSheetMenuFragment.java @@ -188,7 +188,7 @@ public class FavouritesBottomSheetMenuFragment extends MenuBottomSheetDialogFrag Activity activity = getActivity(); if (activity instanceof MapActivity) { MapActivity map = ((MapActivity) activity); - return map.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu(); + return map.getMapRouteInfoMenu(); } else { return null; } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapMultiSelectionMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapMultiSelectionMenuFragment.java index 417a37ef79..7506e42774 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapMultiSelectionMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/MapMultiSelectionMenuFragment.java @@ -174,7 +174,7 @@ public class MapMultiSelectionMenuFragment extends Fragment implements MultiSele @Override public void onResume() { super.onResume(); - if (MapRouteInfoMenu.isVisible()) { + if (menu.getMapActivity().getMapRouteInfoMenu().isVisible()) { dismissMenu(); return; } diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkerSelectionFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkerSelectionFragment.java index 6cfd50ab27..bb7bb67b57 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkerSelectionFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkerSelectionFragment.java @@ -56,7 +56,7 @@ public class MapMarkerSelectionFragment extends BaseOsmAndDialogFragment { MapActivity mapActivity = getMapActivity(); OsmandApplication app = getMyApplication(); if (mapActivity != null) { - MapRouteInfoMenu routeInfoMenu = mapActivity.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu(); + MapRouteInfoMenu routeInfoMenu = mapActivity.getMapRouteInfoMenu(); onClickListener = routeInfoMenu.getOnMarkerSelectListener(); screenOrientation = app.getUIUtilities().getScreenOrientation(); diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/AddPointBottomSheetDialog.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/AddPointBottomSheetDialog.java index 424ed95980..17dec9edd5 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/AddPointBottomSheetDialog.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/AddPointBottomSheetDialog.java @@ -235,7 +235,7 @@ public class AddPointBottomSheetDialog extends MenuBottomSheetDialogFragment { public void onClick(View v) { MapActivity mapActivity = (MapActivity) getActivity(); if (mapActivity != null) { - MapRouteInfoMenu menu = mapActivity.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu(); + MapRouteInfoMenu menu = mapActivity.getMapRouteInfoMenu(); menu.selectOnScreen(pointType); } dismiss(); @@ -300,7 +300,7 @@ public class AddPointBottomSheetDialog extends MenuBottomSheetDialogFragment { public void onClick(View v) { MapActivity mapActivity = (MapActivity) getActivity(); if (mapActivity != null) { - MapRouteInfoMenu menu = mapActivity.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu(); + MapRouteInfoMenu menu = mapActivity.getMapRouteInfoMenu(); menu.selectMapMarker(-1, pointType); dismiss(); } @@ -311,7 +311,7 @@ public class AddPointBottomSheetDialog extends MenuBottomSheetDialogFragment { public void onClick(View v) { MapActivity mapActivity = (MapActivity) getActivity(); if (mapActivity != null) { - MapRouteInfoMenu menu = mapActivity.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu(); + MapRouteInfoMenu menu = mapActivity.getMapRouteInfoMenu(); menu.selectMapMarker(0, pointType); dismiss(); } diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/AvoidRoadsBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/AvoidRoadsBottomSheetDialogFragment.java index be7c2c0140..4349e50212 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/AvoidRoadsBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/AvoidRoadsBottomSheetDialogFragment.java @@ -137,7 +137,7 @@ public class AvoidRoadsBottomSheetDialogFragment extends MenuBottomSheetDialogFr MapActivity mapActivity = getMapActivity(); if (mapActivity != null) { mapActivity.getDashboard().setDashboardVisibility(false, DashboardOnMap.DashboardType.ROUTE_PREFERENCES); - mapActivity.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu().hide(); + mapActivity.getMapRouteInfoMenu().hide(); app.getAvoidSpecificRoads().selectFromMap(mapActivity); Fragment fragment = getTargetFragment(); if (fragment != null) { @@ -281,10 +281,8 @@ public class AvoidRoadsBottomSheetDialogFragment extends MenuBottomSheetDialogFr MapActivity mapActivity = getMapActivity(); if (mapActivity != null) { - final MapRouteInfoMenu mapRouteInfoMenu = mapActivity.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu(); - if (mapRouteInfoMenu != null) { - mapRouteInfoMenu.updateMenu(); - } + final MapRouteInfoMenu mapRouteInfoMenu = mapActivity.getMapRouteInfoMenu(); + mapRouteInfoMenu.updateMenu(); } dismiss(); diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java index ef9f181233..5a00aa7cba 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java @@ -9,6 +9,7 @@ import android.os.Bundle; import android.os.Handler; import android.support.annotation.DrawableRes; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.support.transition.AutoTransition; import android.support.transition.Scene; import android.support.transition.Transition; @@ -68,7 +69,6 @@ import net.osmand.plus.routing.IRouteInformationListener; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.routing.TransportRoutingHelper; import net.osmand.plus.search.QuickSearchHelper; -import net.osmand.plus.views.MapControlsLayer; import net.osmand.router.GeneralRouter; import net.osmand.router.TransportRoutePlanner.TransportRouteResult; import net.osmand.search.SearchUICore.SearchResultCollection; @@ -98,13 +98,12 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener } public static int directionInfo = -1; - private static boolean visible; public static boolean controlVisible = false; public static boolean chooseRoutesVisible = false; - private final RoutingHelper routingHelper; - private final TransportRoutingHelper transportHelper; - private final RoutingOptionsHelper routingOptionsHelper; + private RoutingHelper routingHelper; + private TransportRoutingHelper transportHelper; + private RoutingOptionsHelper routingOptionsHelper; private GeocodingLookupService geocodingLookupService; private boolean routeCalculationInProgress; @@ -116,7 +115,6 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener private MapActivity mapActivity; private OsmandApplication app; private Handler animationsHandler; - private MapControlsLayer mapControlsLayer; private boolean nightMode; private boolean switched; @@ -156,20 +154,25 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener WORK } - public MapRouteInfoMenu(MapActivity mapActivity, MapControlsLayer mapControlsLayer) { - this.mapActivity = mapActivity; - this.app = mapActivity.getMyApplication(); - this.mapControlsLayer = mapControlsLayer; - this.routingHelper = mapActivity.getRoutingHelper(); - this.transportHelper = routingHelper.getTransportRoutingHelper(); - this.routingOptionsHelper = app.getRoutingOptionsHelper(); - this.animationsHandler = new Handler(); + public MapRouteInfoMenu() { + } + public void setMapActivity(@Nullable MapActivity mapActivity) { + this.mapActivity = mapActivity; + if (mapActivity != null) { + if (app == null) { + app = mapActivity.getMyApplication(); + } + routingHelper = app.getRoutingHelper(); + transportHelper = routingHelper.getTransportRoutingHelper(); + routingOptionsHelper = app.getRoutingOptionsHelper(); + portraitMode = AndroidUiHelper.isOrientationPortrait(mapActivity); + geocodingLookupService = app.getGeocodingLookupService(); + } + animationsHandler = new Handler(); routingHelper.addListener(this); - portraitMode = AndroidUiHelper.isOrientationPortrait(mapActivity); currentMenuState = getInitialMenuState(); - geocodingLookupService = mapActivity.getMyApplication().getGeocodingLookupService(); onMarkerSelectListener = new OnMarkerSelectListener() { @Override public void onSelect(int index, PointType pointType) { @@ -1013,12 +1016,12 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener if (isTransportRouteCalculated()) { ChooseRouteFragment.showInstance(mapActivity.getSupportFragmentManager()); } else { - mapControlsLayer.startNavigation(); + mapActivity.getMapLayers().getMapControlsLayer().startNavigation(); } } private void clickRouteCancel() { - mapControlsLayer.stopNavigation(); + mapActivity.getMapLayers().getMapControlsLayer().stopNavigation(); setRouteCalculationInProgress(false); restoreCollapsedButtons(); } @@ -1234,7 +1237,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener @Override public void run() { boolean started = false; - if (visible && mainView != null) { + if (isVisible() && mainView != null) { ViewGroup container = (ViewGroup) mainView.findViewById(containerRes); View v = mainView.findViewById(viewRes); if (container != null && v != null && v.getVisibility() == View.VISIBLE) { @@ -1244,7 +1247,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener @Override public void onTransitionEnd(@NonNull Transition transition) { if (listener != null) { - listener.onButtonCollapsed(visible); + listener.onButtonCollapsed(true); } } }); @@ -1373,8 +1376,8 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener return directionInfo; } - public static boolean isVisible() { - return visible; + public boolean isVisible() { + return findMenuFragment() != null; } public WeakReference findMenuFragment() { @@ -1395,7 +1398,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener int tileBoxWidthPx = 0; int tileBoxHeightPx = 0; - MapRouteInfoMenu routeInfoMenu = mapActivity.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu(); + MapRouteInfoMenu routeInfoMenu = mapActivity.getMapRouteInfoMenu(); WeakReference fragmentRef = routeInfoMenu.findMenuFragment(); if (fragmentRef != null) { MapRouteInfoMenuFragment f = fragmentRef.get(); @@ -1499,7 +1502,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener TargetPoint finish = getTargets().getPointToNavigate(); if (finish != null) { toText.setText(getRoutePointDescription(targets.getPointToNavigate().point, - targets.getPointToNavigate().getOnlyName())); + targets.getPointToNavigate().getOnlyName())); final LatLon latLon = finish.point; final PointDescription pointDescription = finish.getOriginalPointDescription(); @@ -1536,14 +1539,13 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener } public void onDismiss() { - visible = false; cancelButtonsAnimations(); mapActivity.getMapView().setMapPositionX(0); mapActivity.getMapView().refreshMap(); AndroidUiHelper.updateVisibility(mapActivity.findViewById(R.id.map_route_land_left_margin), false); AndroidUiHelper.updateVisibility(mapActivity.findViewById(R.id.map_right_widgets_panel), true); if (switched) { - mapControlsLayer.switchToRouteFollowingLayout(); + mapActivity.getMapLayers().getMapControlsLayer().switchToRouteFollowingLayout(); } if (getTargets().getPointToNavigate() == null && !selectFromMapTouch) { mapActivity.getMapActions().stopNavigationWithoutConfirm(); @@ -1559,10 +1561,9 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener } public void show(int menuState) { - if (!visible) { + if (!isVisible()) { currentMenuState = menuState; - visible = true; - switched = mapControlsLayer.switchToRoutePlanningLayout(); + switched = mapActivity.getMapLayers().getMapControlsLayer().switchToRoutePlanningLayout(); boolean refreshMap = !switched; boolean portrait = AndroidUiHelper.isOrientationPortrait(mapActivity); if (!portrait) { @@ -1590,8 +1591,6 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener WeakReference fragmentRef = findMenuFragment(); if (fragmentRef != null) { fragmentRef.get().dismiss(); - } else { - visible = false; } routingHelper.removeListener(this); removeTargetPointListener(); diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenuFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenuFragment.java index 82c5b1e547..c1a8383666 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenuFragment.java @@ -113,7 +113,7 @@ public class MapRouteInfoMenuFragment extends BaseOsmAndFragment { portrait = AndroidUiHelper.isOrientationPortrait(mapActivity); - menu = mapActivity.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu(); + menu = mapActivity.getMapRouteInfoMenu(); shadowHeight = AndroidUtils.getStatusBarHeight(mapActivity); topScreenPosY = addStatusBarHeightIfNeeded(0); minHalfY = viewHeight - (int) (viewHeight * .75f); diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteOptionsBottomSheet.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteOptionsBottomSheet.java index cd789f21ed..d6534be555 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteOptionsBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteOptionsBottomSheet.java @@ -13,8 +13,8 @@ import android.widget.TextView; import net.osmand.AndroidUtils; import net.osmand.CallbackWithObject; -import net.osmand.plus.ApplicationMode; import net.osmand.GPXUtilities; +import net.osmand.plus.ApplicationMode; import net.osmand.plus.OsmAndLocationProvider; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; @@ -342,9 +342,9 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment { } private void updateMenu() { - final MapRouteInfoMenu mapRouteInfoMenu = getMapActivity().getMapLayers().getMapControlsLayer().getMapRouteInfoMenu(); - if (mapRouteInfoMenu != null) { - mapRouteInfoMenu.updateMenu(); + MapActivity mapActivity = getMapActivity(); + if (mapActivity != null) { + mapActivity.getMapRouteInfoMenu().updateMenu(); } } diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RoutingOptionsHelper.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RoutingOptionsHelper.java index 6cab23c49d..9a7067e272 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RoutingOptionsHelper.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RoutingOptionsHelper.java @@ -98,7 +98,7 @@ public class RoutingOptionsHelper { public void selectRestrictedRoads(final MapActivity mapActivity) { mapActivity.getDashboard().setDashboardVisibility(false, DashboardOnMap.DashboardType.ROUTE_PREFERENCES); - mapActivity.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu().hide(); + mapActivity.getMapRouteInfoMenu().hide(); mapActivity.getMyApplication().getAvoidSpecificRoads().showDialog(mapActivity); } diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/WaypointsFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/WaypointsFragment.java index fedbdcf4c2..0ee98c94c5 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/WaypointsFragment.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/WaypointsFragment.java @@ -251,7 +251,7 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS if (activeObjects.isEmpty() || isContainsOnlyStart(activeObjects)) { mapActivity.getMapActions().stopNavigationWithoutConfirm(); mapActivity.getMyApplication().getTargetPointsHelper().removeAllWayPoints(false, true); - mapActivity.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu().hide(); + mapActivity.getMapRouteInfoMenu().hide(); } } diff --git a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java index 5783fa9ebe..24c065fbb1 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java @@ -130,10 +130,6 @@ public class MapControlsLayer extends OsmandMapLayer { contextMenuLayer = mapActivity.getMapLayers().getContextMenuLayer(); } - public MapRouteInfoMenu getMapRouteInfoMenu() { - return mapRouteInfoMenu; - } - public TrackDetailsMenu getTrackDetailsMenu() { return trackDetailsMenu; } @@ -300,7 +296,7 @@ public class MapControlsLayer extends OsmandMapLayer { } private void initRouteControls() { - mapRouteInfoMenu = new MapRouteInfoMenu(mapActivity, this); + mapRouteInfoMenu = mapActivity.getMapRouteInfoMenu(); trackDetailsMenu = new TrackDetailsMenu(mapActivity); } @@ -759,7 +755,7 @@ public class MapControlsLayer extends OsmandMapLayer { routePlanningMode = true; } boolean routeFollowingMode = !routePlanningMode && rh.isFollowingMode(); - boolean routeDialogOpened = MapRouteInfoMenu.isVisible(); + boolean routeDialogOpened = mapRouteInfoMenu.isVisible(); boolean trackDialogOpened = TrackDetailsMenu.isVisible(); boolean contextMenuOpened = !mapActivity.getContextMenu().shouldShowTopControls(); boolean showRouteCalculationControls = routePlanningMode || diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java index 926dd845fb..71c71d4b3f 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java @@ -894,7 +894,7 @@ public class MapInfoWidgetsFactory { } } else { int di = MapRouteInfoMenu.getDirectionInfo(); - if (di >= 0 && MapRouteInfoMenu.isVisible() && + if (di >= 0 && map.getMapRouteInfoMenu().isVisible() && di < routingHelper.getRouteDirections().size()) { showNextTurn = true; RouteDirectionInfo next = routingHelper.getRouteDirections().get(di); diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapMarkersWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapMarkersWidgetsFactory.java index bed59baf1f..47b310b17b 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapMarkersWidgetsFactory.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapMarkersWidgetsFactory.java @@ -201,7 +201,7 @@ public class MapMarkersWidgetsFactory { || !map.getMyApplication().getSettings().MAP_MARKERS_MODE.get().isToolbar() || map.getMyApplication().getRoutingHelper().isFollowingMode() || map.getMyApplication().getRoutingHelper().isRoutePlanningMode() - || MapRouteInfoMenu.isVisible() + || map.getMapRouteInfoMenu().isVisible() || addressTopBar.getVisibility() == View.VISIBLE || map.isTopToolbarActive() || !map.getContextMenu().shouldShowTopControls() diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java index d82fc5ded4..71fe1123a3 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java @@ -755,6 +755,7 @@ public class RouteInfoWidgetsFactory { public static class LanesControl { private MapViewTrackingUtilities trackingUtilities; private OsmAndLocationProvider locationProvider; + private MapRouteInfoMenu mapRouteInfoMenu; private RoutingHelper rh; private OsmandSettings settings; private ImageView lanesView; @@ -776,6 +777,7 @@ public class RouteInfoWidgetsFactory { trackingUtilities = map.getMapViewTrackingUtilities(); locationProvider = map.getMyApplication().getLocationProvider(); settings = map.getMyApplication().getSettings(); + mapRouteInfoMenu = map.getMapRouteInfoMenu(); rh = map.getMyApplication().getRoutingHelper(); app = map.getMyApplication(); } @@ -817,7 +819,7 @@ public class RouteInfoWidgetsFactory { } } else { int di = MapRouteInfoMenu.getDirectionInfo(); - if (di >= 0 && MapRouteInfoMenu.isVisible() + if (di >= 0 && mapRouteInfoMenu.isVisible() && di < rh.getRouteDirections().size()) { RouteDirectionInfo next = rh.getRouteDirections().get(di); if (next != null) {