From 8d33234eb3244b7cfe8c1d68a9a1e0b173a5794d Mon Sep 17 00:00:00 2001 From: crimean Date: Mon, 18 Feb 2019 16:37:20 +0300 Subject: [PATCH] Fix menu state after selection on map --- .../AddPointBottomSheetDialog.java | 1 - .../routepreparationmenu/MapRouteInfoMenu.java | 10 ++++++++-- .../cards/PreviousRouteCard.java | 15 +++++++++++++-- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/AddPointBottomSheetDialog.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/AddPointBottomSheetDialog.java index c950f46396..424ed95980 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/AddPointBottomSheetDialog.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/AddPointBottomSheetDialog.java @@ -87,7 +87,6 @@ public class AddPointBottomSheetDialog extends MenuBottomSheetDialogFragment { createSwitchStartAndEndItem(); break; case TARGET: - createMyLocItem(); createSelectOnTheMapItem(); createFavouritesItem(); createMarkersItem(); diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java index c3488587aa..9ed2d6b214 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java @@ -92,6 +92,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener { private boolean selectFromMapTouch; private PointType selectFromMapPointType; + private int selectFromMapMenuState = MenuState.HEADER_ONLY; private boolean showMenu = false; private MapActivity mapActivity; @@ -194,7 +195,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener { targets.setWorkPoint(latlon, null); break; } - show(); + show(selectFromMapMenuState); if (selectFromMapPointType == PointType.INTERMEDIATE && targets.checkPointToNavigateShort()) { WaypointsFragment.showInstance(mapActivity); } @@ -1071,6 +1072,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener { public void selectOnScreen(PointType pointType) { selectFromMapTouch = true; selectFromMapPointType = pointType; + selectFromMapMenuState = currentMenuState; hide(); } @@ -1347,8 +1349,12 @@ public class MapRouteInfoMenu implements IRouteInformationListener { } public void show() { + show(getInitialMenuState()); + } + + public void show(int menuState) { if (!visible) { - currentMenuState = getInitialMenuState(); + currentMenuState = menuState; visible = true; switched = mapControlsLayer.switchToRoutePlanningLayout(); boolean refreshMap = !switched; diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/PreviousRouteCard.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/PreviousRouteCard.java index 58874a64fe..c6ee95bd4f 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/PreviousRouteCard.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/PreviousRouteCard.java @@ -6,6 +6,7 @@ import android.view.View; import android.widget.TextView; import net.osmand.AndroidUtils; +import net.osmand.data.PointDescription; import net.osmand.plus.R; import net.osmand.plus.TargetPointsHelper; import net.osmand.plus.TargetPointsHelper.TargetPoint; @@ -47,8 +48,18 @@ public class PreviousRouteCard extends BaseCard { } startTitle.setText(startText.toString()); TargetPoint destinationPoint = targetPointsHelper.getPointToNavigateBackup(); - destinationTitle.setText(destinationPoint != null ? - destinationPoint.getPointDescription(mapActivity).getSimpleName(mapActivity, false) : ""); + String destinationName = ""; + if (destinationPoint != null) { + PointDescription description = destinationPoint.getOriginalPointDescription(); + if (description != null && !Algorithms.isEmpty(description.getName()) && + !description.getName().equals(mapActivity.getString(R.string.no_address_found))) { + destinationName = description.getName(); + } else { + destinationName = PointDescription.getLocationName(mapActivity, + destinationPoint.point.getLatitude(), destinationPoint.point.getLongitude(), true).replace('\n', ' '); + } + } + destinationTitle.setText(destinationName); View homeButton = view.findViewById(R.id.card_button); homeButton.setOnClickListener(new View.OnClickListener() { @Override