diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java index 6790a7068b3..a7e5bba8abf 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/AmenityMenuController.java @@ -105,7 +105,7 @@ void openTrack(MapActivity mapActivity) { String name = amenity.getTagContent(Amenity.ROUTE_NAME); TravelArticle article = travelHelper.getArticleByTitle(name, lang, true, null); if (article != null) { - travelHelper.openTrackMenu(article, mapActivity, name, amenity.getLocation()); + travelHelper.openTrackMenu(article, mapActivity, name, amenity.getLocation(), false); } } diff --git a/OsmAnd/src/net/osmand/plus/search/dialogs/QuickSearchListFragment.java b/OsmAnd/src/net/osmand/plus/search/dialogs/QuickSearchListFragment.java index ccdadc58206..b00aacdea09 100644 --- a/OsmAnd/src/net/osmand/plus/search/dialogs/QuickSearchListFragment.java +++ b/OsmAnd/src/net/osmand/plus/search/dialogs/QuickSearchListFragment.java @@ -16,7 +16,10 @@ import androidx.fragment.app.FragmentActivity; import net.osmand.IndexConstants; +import net.osmand.data.Amenity; import net.osmand.data.PointDescription; +import net.osmand.plus.wikivoyage.data.TravelGpx; +import net.osmand.plus.wikivoyage.data.TravelHelper; import net.osmand.shared.gpx.GpxFile; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; @@ -175,27 +178,42 @@ public boolean isShowResult() { public void showResult(SearchResult searchResult) { showResult = false; if (searchResult.objectType == ObjectType.GPX_TRACK) { - GPXInfo gpxInfo = (GPXInfo) searchResult.relatedObject; - if (dialogFragment.getSearchType().isTargetPoint()) { - File file = gpxInfo.getFile(); - if (file != null) { - selectTrack(file); - } - } else { - showTrackMenuFragment(gpxInfo); - } + showGpxTrackResult(searchResult); } else if (searchResult.location != null) { - Pair pair = QuickSearchListItem.getPointDescriptionObject(app, searchResult); + showResultWithLocation(searchResult); + } + } + + private void showResultWithLocation(SearchResult searchResult) { + Pair pair = QuickSearchListItem.getPointDescriptionObject(app, searchResult); - dialogFragment.hideToolbar(); - dialogFragment.hide(); + dialogFragment.hideToolbar(); + dialogFragment.hide(); + if (pair.second instanceof Amenity && ((Amenity) pair.second).isRouteTrack()) { + Amenity amenity = (Amenity) pair.second; + TravelHelper travelHelper = app.getTravelHelper(); + TravelGpx travelGpx = travelHelper.searchGpx(amenity.getLocation(), amenity.getRouteId(), amenity.getRef()); + travelHelper.openTrackMenu(travelGpx, getMapActivity(), amenity.getRouteId(), amenity.getLocation(), true); + } else { showOnMap(getMapActivity(), dialogFragment, searchResult.location.getLatitude(), searchResult.location.getLongitude(), searchResult.preferredZoom, pair.first, pair.second); } } + private void showGpxTrackResult(SearchResult searchResult) { + GPXInfo gpxInfo = (GPXInfo) searchResult.relatedObject; + if (dialogFragment.getSearchType().isTargetPoint()) { + File file = gpxInfo.getFile(); + if (file != null) { + selectTrack(file); + } + } else { + showTrackMenuFragment(gpxInfo); + } + } + private void selectTrack(@NonNull File file) { SelectedGpxFile selectedGpxFile = app.getSelectedGpxHelper().getSelectedFileByPath(file.getAbsolutePath()); if (selectedGpxFile != null) { diff --git a/OsmAnd/src/net/osmand/plus/track/helpers/GpxUiHelper.java b/OsmAnd/src/net/osmand/plus/track/helpers/GpxUiHelper.java index 4cacb0fc1a2..6a0da8d23fd 100644 --- a/OsmAnd/src/net/osmand/plus/track/helpers/GpxUiHelper.java +++ b/OsmAnd/src/net/osmand/plus/track/helpers/GpxUiHelper.java @@ -625,7 +625,8 @@ public static void saveAndOpenGpx(@NonNull MapActivity mapActivity, @NonNull GpxFile gpxFile, @NonNull WptPt selectedPoint, @Nullable GpxTrackAnalysis analyses, - @Nullable RouteKey routeKey) { + @Nullable RouteKey routeKey, + boolean adjustMapPosition) { SaveGpxHelper.saveGpx(file, gpxFile, errorMessage -> { if (errorMessage == null) { OsmandApplication app = mapActivity.getMyApplication(); @@ -634,7 +635,7 @@ public static void saveAndOpenGpx(@NonNull MapActivity mapActivity, GpxTrackAnalysis trackAnalysis = analyses != null ? analyses : selectedGpxFile.getTrackAnalysis(app); SelectedGpxPoint selectedGpxPoint = new SelectedGpxPoint(selectedGpxFile, selectedPoint); Bundle bundle = new Bundle(); - bundle.putBoolean(TrackMenuFragment.ADJUST_MAP_POSITION, false); + bundle.putBoolean(TrackMenuFragment.ADJUST_MAP_POSITION, adjustMapPosition); TrackMenuFragment.showInstance(mapActivity, selectedGpxFile, selectedGpxPoint, trackAnalysis, routeKey, bundle); } else { diff --git a/OsmAnd/src/net/osmand/plus/views/layers/NetworkRouteSelectionLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/NetworkRouteSelectionLayer.java index be9503aa55d..5d7959ef482 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/NetworkRouteSelectionLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/NetworkRouteSelectionLayer.java @@ -154,7 +154,7 @@ private void saveAndOpenGpx(@NonNull GpxFile gpxFile, @NonNull Pair