diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java index 13c4fffa49..a44b131a66 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java @@ -177,6 +177,8 @@ public class TravelObfHelper implements TravelHelper { res.file = file; String title = amenity.getName("en"); res.title = capitalizeFirstLetter(getGpxTitle(Algorithms.isEmpty(title) ? amenity.getName() : title)); + res.lat = amenity.getLocation().getLatitude(); + res.lon = amenity.getLocation().getLongitude(); res.routeId = Algorithms.emptyIfNull(amenity.getTagContent(Amenity.ROUTE_ID)); try { res.totalDistance = Float.parseFloat(Algorithms.emptyIfNull(amenity.getTagContent(DISTANCE))); @@ -319,6 +321,7 @@ public class TravelObfHelper implements TravelHelper { gpxFile.tracks = new ArrayList<>(); gpxFile.tracks.add(track); } + article.gpxFile = gpxFile; return gpxFile; } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java index ce6f4475af..9055acd4ed 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreTabFragment.java @@ -181,7 +181,7 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv List popularArticles = app.getTravelHelper().getPopularArticles(); for (TravelArticle article : popularArticles) { if (article instanceof TravelGpx) { - items.add(new TravelGpxCard(app, nightMode, (TravelGpx) article, activity.getSupportFragmentManager())); + items.add(new TravelGpxCard(app, nightMode, (TravelGpx) article, getActivity())); } else { items.add(new ArticleTravelCard(app, nightMode, article, activity.getSupportFragmentManager())); } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/TravelGpxCard.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/TravelGpxCard.java index ded096a260..3cfbc91c04 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/TravelGpxCard.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/TravelGpxCard.java @@ -5,13 +5,15 @@ import android.view.View; import android.widget.TextView; import androidx.annotation.NonNull; -import androidx.fragment.app.FragmentManager; +import androidx.fragment.app.FragmentActivity; import androidx.recyclerview.widget.RecyclerView; import net.osmand.AndroidUtils; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; +import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.wikipedia.WikiArticleHelper; import net.osmand.plus.wikivoyage.data.TravelGpx; import net.osmand.plus.wikivoyage.data.TravelLocalDataHelper; @@ -22,15 +24,15 @@ public class TravelGpxCard extends BaseTravelCard { private final TravelGpx article; private final Drawable readIcon; - private final FragmentManager fragmentManager; + private final FragmentActivity activity; private boolean isLastItem; public TravelGpxCard(@NonNull OsmandApplication app, boolean nightMode, @NonNull TravelGpx article, - @NonNull FragmentManager fragmentManager) { + @NonNull FragmentActivity activity) { super(app, nightMode); this.article = article; readIcon = getActiveIcon(R.drawable.ic_action_read_article); - this.fragmentManager = fragmentManager; + this.activity = activity; } @Override @@ -49,10 +51,15 @@ public class TravelGpxCard extends BaseTravelCard { View.OnClickListener readClickListener = new View.OnClickListener() { @Override public void onClick(View v) { - if (fragmentManager != null) { -// WikivoyageArticleDialogFragment.showInstance(app, fragmentManager, -// article.generateIdentifier(), article.getLang()); + if (activity != null) { app.getTravelHelper().createGpxFile(article); + final OsmandSettings settings = app.getSettings(); + settings.setMapLocationToShow(article.getLat(), article.getLon(), + settings.getLastKnownMapZoom(), + null, + false, + article.getGpxFile()); + MapActivity.launchMapActivityMoveToTop(activity); } } };