From 7d96c9f536000eafed43cb54a8dd5741275aa744 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Wed, 3 Feb 2021 18:26:53 +0200 Subject: [PATCH 1/2] Fix image cards in plugins --- .../src/net/osmand/plus/mapillary/MapillaryPlugin.java | 8 ++++++++ .../plus/openplacereviews/OpenPlaceReviewsPlugin.java | 10 +++++++++- .../src/net/osmand/plus/wikipedia/WikipediaPlugin.java | 9 +++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java index 1996d8bed5..bc2b0dbc95 100644 --- a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java +++ b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java @@ -101,6 +101,14 @@ public class MapillaryPlugin extends OsmandPlugin { return app.getString(R.string.mapillary); } + @Override + public boolean init(@NonNull OsmandApplication app, Activity activity) { + if (activity instanceof MapActivity) { + mapActivity = (MapActivity) activity; + } + return true; + } + @Override public void registerLayers(MapActivity activity) { createLayers(); diff --git a/OsmAnd/src/net/osmand/plus/openplacereviews/OpenPlaceReviewsPlugin.java b/OsmAnd/src/net/osmand/plus/openplacereviews/OpenPlaceReviewsPlugin.java index 3bbcee9cfb..861b9ec971 100644 --- a/OsmAnd/src/net/osmand/plus/openplacereviews/OpenPlaceReviewsPlugin.java +++ b/OsmAnd/src/net/osmand/plus/openplacereviews/OpenPlaceReviewsPlugin.java @@ -1,5 +1,6 @@ package net.osmand.plus.openplacereviews; +import android.app.Activity; import android.graphics.drawable.Drawable; import androidx.annotation.NonNull; @@ -45,7 +46,6 @@ public class OpenPlaceReviewsPlugin extends OsmandPlugin { return ID; } - @Override public String getName() { return app.getString(R.string.open_place_reviews); @@ -171,6 +171,14 @@ public class OpenPlaceReviewsPlugin extends OsmandPlugin { return arr; } + @Override + public boolean init(@NonNull OsmandApplication app, Activity activity) { + if (activity instanceof MapActivity) { + mapActivity = (MapActivity) activity; + } + return true; + } + @Override public void disable(OsmandApplication app) { if (app.getSettings().OPR_USE_DEV_URL.get()) { diff --git a/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaPlugin.java b/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaPlugin.java index 6b5559c3a8..1b97f6df1c 100644 --- a/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaPlugin.java +++ b/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaPlugin.java @@ -1,5 +1,6 @@ package net.osmand.plus.wikipedia; +import android.app.Activity; import android.content.Intent; import android.view.View; import android.widget.ArrayAdapter; @@ -106,6 +107,14 @@ public class WikipediaPlugin extends OsmandPlugin { this.mapActivity = null; } + @Override + public boolean init(@NonNull OsmandApplication app, Activity activity) { + if (activity instanceof MapActivity) { + mapActivity = (MapActivity) activity; + } + return true; + } + @Override protected void registerLayerContextMenuActions(OsmandMapTileView mapView, ContextMenuAdapter adapter, From 1d2d5350abf6f6ca16a52650b192e3378d3986f8 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Wed, 3 Feb 2021 18:37:57 +0200 Subject: [PATCH 2/2] Fix opr card update --- .../openplacereviews/OpenPlaceReviewsPlugin.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/openplacereviews/OpenPlaceReviewsPlugin.java b/OsmAnd/src/net/osmand/plus/openplacereviews/OpenPlaceReviewsPlugin.java index 861b9ec971..d1ddaa0eac 100644 --- a/OsmAnd/src/net/osmand/plus/openplacereviews/OpenPlaceReviewsPlugin.java +++ b/OsmAnd/src/net/osmand/plus/openplacereviews/OpenPlaceReviewsPlugin.java @@ -88,8 +88,8 @@ public class OpenPlaceReviewsPlugin extends OsmandPlugin { @Override protected List getContextMenuImageCards(@NonNull Map params, - @Nullable Map additionalParams, - @Nullable GetImageCardsListener listener) { + @Nullable Map additionalParams, + @Nullable GetImageCardsListener listener) { List imageCards = new ArrayList<>(); if (mapActivity != null) { Object object = mapActivity.getMapLayers().getContextMenuLayer().getSelectedObject(); @@ -111,6 +111,15 @@ public class OpenPlaceReviewsPlugin extends OsmandPlugin { return imageCards; } + @Override + protected ImageCard createContextMenuImageCard(@NonNull JSONObject imageObject) { + ImageCard imageCard = null; + if (mapActivity != null && imageObject != JSONObject.NULL) { + imageCard = createCardOpr(mapActivity, imageObject); + } + return imageCard; + } + private void getPicturesForPlace(List result, String response) { try { if (!Algorithms.isEmpty(response)) {