Skip to content

Commit

Permalink
Allow Amenity OpenTrack menu for ROUTE_TRACK_POINT
Browse files Browse the repository at this point in the history
  • Loading branch information
RZR-UA committed Nov 24, 2024
1 parent 2b8cde4 commit 7fd3bbc
Showing 1 changed file with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.osmand.plus.mapcontextmenu.controllers;

import static net.osmand.osm.MapPoiTypes.ROUTE_ARTICLE_POINT;
import static net.osmand.osm.MapPoiTypes.ROUTE_TRACK_POINT;

import android.graphics.drawable.Drawable;
import android.text.TextUtils;
Expand All @@ -25,6 +26,7 @@
import net.osmand.plus.transport.TransportStopRoute;
import net.osmand.plus.wikipedia.WikipediaDialogFragment;
import net.osmand.plus.wikivoyage.data.TravelArticle;
import net.osmand.plus.wikivoyage.data.TravelGpx;
import net.osmand.plus.wikivoyage.data.TravelHelper;
import net.osmand.util.Algorithms;
import net.osmand.util.OpeningHoursParser;
Expand Down Expand Up @@ -69,7 +71,8 @@ public AmenityMenuController(@NonNull MapActivity mapActivity,
new MapMarkerMenuController(mapActivity, marker.getPointDescription(mapActivity), marker);
leftTitleButtonController = markerMenuController.getLeftTitleButtonController();
rightTitleButtonController = markerMenuController.getRightTitleButtonController();
} else if (amenity.getSubType().equals(ROUTE_ARTICLE_POINT)) {
} else if (amenity.getSubType().equals(ROUTE_ARTICLE_POINT) ||
amenity.getSubType().equals(ROUTE_TRACK_POINT)) {
TitleButtonController openTrackButtonController = new TitleButtonController() {
@Override
public void buttonPressed() {
Expand Down Expand Up @@ -101,11 +104,18 @@ public void buttonPressed() {

void openTrack(MapActivity mapActivity) {
TravelHelper travelHelper = mapActivity.getMyApplication().getTravelHelper();
String lang = amenity.getTagSuffix(Amenity.LANG_YES + ":");
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(), false);
if (amenity.getSubType().equals(ROUTE_ARTICLE_POINT)) {
String lang = amenity.getTagSuffix(Amenity.LANG_YES + ":");
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(), false);
}
} else if (amenity.getSubType().equals(ROUTE_TRACK_POINT)) {
TravelGpx travelGpx = travelHelper.searchGpx(amenity.getLocation(), amenity.getRouteId(), amenity.getRef());
if (travelGpx != null) {
travelHelper.openTrackMenu(travelGpx, mapActivity, travelGpx.getTitle(), amenity.getLocation(), false);
}
}
}

Expand Down

0 comments on commit 7fd3bbc

Please sign in to comment.