diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java index f58a4b72ec..022f9fdb98 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java @@ -42,7 +42,6 @@ import net.osmand.plus.mapcontextmenu.builders.cards.AbstractCard; import net.osmand.plus.mapcontextmenu.builders.cards.CardsRowBuilder; import net.osmand.plus.mapcontextmenu.builders.cards.ImageCard; import net.osmand.plus.mapcontextmenu.builders.cards.ImageCard.GetImageCardsTask; -import net.osmand.plus.mapcontextmenu.builders.cards.ImageCard.GetImageCardsTask.GetImageCardsListener; import net.osmand.plus.mapcontextmenu.builders.cards.NoImagesCard; import net.osmand.plus.render.RenderingIcons; import net.osmand.util.Algorithms; @@ -56,6 +55,7 @@ import java.util.List; import java.util.Map; import static android.util.TypedValue.COMPLEX_UNIT_DIP; +import static net.osmand.plus.mapcontextmenu.builders.cards.ImageCard.GetImageCardsTask.*; public class MenuBuilder { @@ -350,7 +350,7 @@ public class MenuBuilder { @Override public void onCollapseExpand(boolean collapsed) { if (!collapsed && onlinePhotoCards == null) { - startLoadingImages(MenuBuilder.this); + startLoadingImages(); } } }); @@ -360,14 +360,14 @@ public class MenuBuilder { if (needUpdateOnly && onlinePhotoCards != null) { onlinePhotoCardsRow.setCards(onlinePhotoCards); } else if (!collapsableView.isCollapsed()) { - startLoadingImages(this); + startLoadingImages(); } } - private void startLoadingImages(final MenuBuilder menuBuilder) { + private void startLoadingImages() { onlinePhotoCards = new ArrayList<>(); onlinePhotoCardsRow.setProgressCard(); - execute(new GetImageCardsTask(mapActivity, menuBuilder.getLatLon(), getAdditionalCardParams(), + execute(new GetImageCardsTask(mapActivity, getLatLon(), getAdditionalCardParams(), new GetImageCardsListener() { @Override public void onPostProcess(List cardList) { @@ -376,7 +376,7 @@ public class MenuBuilder { @Override public void onFinish(List cardList) { - if (!menuBuilder.isHidden()) { + if (!isHidden()) { List cards = new ArrayList<>(); cards.addAll(cardList); if (cardList.size() == 0) { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java index 8330458ee4..8d1bdeef6d 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java @@ -518,10 +518,10 @@ public class AmenityMenuBuilder extends MenuBuilder { String imageValue = additionalInfo.get("image"); String mapillaryValue = additionalInfo.get("mapillary"); if (!Algorithms.isEmpty(imageValue)) { - params.put("image", imageValue); + params.put("osm_image", imageValue); } if (!Algorithms.isEmpty(mapillaryValue)) { - params.put("mapillary", mapillaryValue); + params.put("osm_mapillary_key", mapillaryValue); } return params; } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/cards/AbstractCard.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/cards/AbstractCard.java index c0b9de5795..5669cb1fd7 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/cards/AbstractCard.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/cards/AbstractCard.java @@ -16,6 +16,7 @@ import android.view.LayoutInflater; import android.view.View; import android.webkit.WebSettings; import android.webkit.WebView; +import android.webkit.WebViewClient; import android.widget.LinearLayout; import net.osmand.plus.OsmandApplication; @@ -89,6 +90,13 @@ public abstract class AbstractCard { }); final WebView wv = new WebView(ctx); + wv.setWebViewClient(new WebViewClient() { + @Override + public boolean shouldOverrideUrlLoading(WebView view, String url) { + return false; + } + }); + WebSettings settings = wv.getSettings(); if (hasImageUrl) { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/cards/ImageCard.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/cards/ImageCard.java index e960ebd774..4e3d69b652 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/cards/ImageCard.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/cards/ImageCard.java @@ -98,7 +98,8 @@ public abstract class ImageCard extends AbstractCard { if (imageObject.has("ca") && !imageObject.isNull("ca")) { this.ca = imageObject.getDouble("ca"); } - if (imageObject.has("lat") && imageObject.has("lon")) { + if (imageObject.has("lat") && imageObject.has("lon") + && !imageObject.isNull("lat") && !imageObject.isNull("lon")) { double latitude = imageObject.getDouble("lat"); double longitude = imageObject.getDouble("lon"); this.location = new LatLon(latitude, longitude); @@ -113,19 +114,19 @@ public abstract class ImageCard extends AbstractCard { if (imageObject.has("key")) { this.key = imageObject.getString("key"); } - if (imageObject.has("title")) { + if (imageObject.has("title") && !imageObject.isNull("title")) { this.title = imageObject.getString("title"); } - if (imageObject.has("username")) { + if (imageObject.has("username") && !imageObject.isNull("username")) { this.userName = imageObject.getString("username"); } - if (imageObject.has("url")) { + if (imageObject.has("url") && !imageObject.isNull("url")) { this.url = imageObject.getString("url"); } - if (imageObject.has("imageUrl")) { + if (imageObject.has("imageUrl") && !imageObject.isNull("imageUrl")) { this.imageUrl = imageObject.getString("imageUrl"); } - if (imageObject.has("imageHiresUrl")) { + if (imageObject.has("imageHiresUrl") && !imageObject.isNull("imageHiresUrl")) { this.imageHiresUrl = imageObject.getString("imageHiresUrl"); } if (imageObject.has("externalLink") && !imageObject.isNull("externalLink")) { @@ -498,6 +499,9 @@ public abstract class ImageCard extends AbstractCard { downloading = false; downloaded = true; ImageCard.this.bitmap = bitmap; + if (bitmap != null && Algorithms.isEmpty(getImageHiresUrl())) { + ImageCard.this.imageHiresUrl = getUrl(); + } update(); } } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/cards/UrlImageCard.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/cards/UrlImageCard.java index 27d8525c04..313305cf67 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/cards/UrlImageCard.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/cards/UrlImageCard.java @@ -13,21 +13,13 @@ public class UrlImageCard extends ImageCard { public UrlImageCard(MapActivity mapActivity, JSONObject imageObject) { super(mapActivity, imageObject); - final String url; - final boolean hasImageUrl; - if (Algorithms.isEmpty(getImageHiresUrl())) { - url = getUrl(); - hasImageUrl = false; - } else { - url = getImageHiresUrl(); - hasImageUrl = true; - } - - if (!Algorithms.isEmpty(url)) { + if (!Algorithms.isEmpty(getSuitableUrl())) { OnClickListener onClickListener = new OnClickListener() { @Override public void onClick(View v) { - openUrl(getMapActivity(), getMyApplication(), getTitle(), url, isExternalLink(), hasImageUrl); + openUrl(getMapActivity(), getMyApplication(), getTitle(), getSuitableUrl(), + isExternalLink() || Algorithms.isEmpty(getImageHiresUrl()), + !Algorithms.isEmpty(getImageHiresUrl())); } }; if (!Algorithms.isEmpty(buttonText)) { @@ -37,4 +29,14 @@ public class UrlImageCard extends ImageCard { } } } + + private String getSuitableUrl() { + final String url; + if (Algorithms.isEmpty(getImageHiresUrl())) { + url = getUrl(); + } else { + url = getImageHiresUrl(); + } + return url; + } }