diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java index bfdf8c0c57..6d00340d0d 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; @@ -55,6 +54,7 @@ import java.util.LinkedList; import java.util.List; import static android.util.TypedValue.COMPLEX_UNIT_DIP; +import static net.osmand.plus.mapcontextmenu.builders.cards.ImageCard.GetImageCardsTask.*; public class MenuBuilder { @@ -349,7 +349,7 @@ public class MenuBuilder { @Override public void onCollapseExpand(boolean collapsed) { if (!collapsed && onlinePhotoCards == null) { - startLoadingImages(MenuBuilder.this); + startLoadingImages(); } } }); @@ -359,18 +359,22 @@ 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(); +<<<<<<< HEAD execute(new GetImageCardsTask(mapActivity, menuBuilder.getLatLon(), +======= + execute(new GetImageCardsTask(mapActivity, getLatLon(), getAdditionalCardParams(), +>>>>>>> dbb72952c7... Fix osm image/mapillary processing new GetImageCardsListener() { @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 9a65b98354..842b0bb94b 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/AmenityMenuBuilder.java @@ -506,6 +506,24 @@ public class AmenityMenuBuilder extends MenuBuilder { } } +<<<<<<< HEAD +======= + @Override + protected Map getAdditionalCardParams() { + Map params = new HashMap<>(); + Map additionalInfo = amenity.getAdditionalInfo(); + String imageValue = additionalInfo.get("image"); + String mapillaryValue = additionalInfo.get("mapillary"); + if (!Algorithms.isEmpty(imageValue)) { + params.put("osm_image", imageValue); + } + if (!Algorithms.isEmpty(mapillaryValue)) { + params.put("osm_mapillary_key", mapillaryValue); + } + return params; + } + +>>>>>>> dbb72952c7... Fix osm image/mapillary processing private static class AmenityInfoRow { private String key; private Drawable icon; 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 1c265960f2..fdf91efcb2 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/cards/AbstractCard.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/cards/AbstractCard.java @@ -14,6 +14,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; @@ -83,6 +84,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(); /* settings.setDefaultTextEncodingName("utf-8"); 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 343a875060..cc099508b7 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/cards/ImageCard.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/cards/ImageCard.java @@ -85,6 +85,7 @@ public abstract class ImageCard extends AbstractCard { public ImageCard(MapActivity mapActivity, JSONObject imageObject) { super(mapActivity); +<<<<<<< HEAD try { if (imageObject.has("type")) { this.type = imageObject.getString("type"); @@ -102,6 +103,58 @@ public abstract class ImageCard extends AbstractCard { this.timestamp = DATE_FORMAT.parse(imageObject.getString("timestamp")); } catch (ParseException e) { e.printStackTrace(); +======= + if (imageObject != null) { + try { + if (imageObject.has("type")) { + this.type = imageObject.getString("type"); + } + if (imageObject.has("ca") && !imageObject.isNull("ca")) { + this.ca = imageObject.getDouble("ca"); + } + 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); + } + if (imageObject.has("timestamp")) { + try { + this.timestamp = DATE_FORMAT.parse(imageObject.getString("timestamp")); + } catch (ParseException e) { + e.printStackTrace(); + } + } + if (imageObject.has("key")) { + this.key = imageObject.getString("key"); + } + if (imageObject.has("title") && !imageObject.isNull("title")) { + this.title = imageObject.getString("title"); + } + if (imageObject.has("username") && !imageObject.isNull("username")) { + this.userName = imageObject.getString("username"); + } + if (imageObject.has("url") && !imageObject.isNull("url")) { + this.url = imageObject.getString("url"); + } + if (imageObject.has("imageUrl") && !imageObject.isNull("imageUrl")) { + this.imageUrl = imageObject.getString("imageUrl"); + } + if (imageObject.has("imageHiresUrl") && !imageObject.isNull("imageHiresUrl")) { + this.imageHiresUrl = imageObject.getString("imageHiresUrl"); + } + if (imageObject.has("externalLink") && !imageObject.isNull("externalLink")) { + this.externalLink = imageObject.getBoolean("externalLink"); + } + if (imageObject.has("topIcon") && !imageObject.isNull("topIcon")) { + this.topIconId = getDrawableId(imageObject.getString("topIcon")); + } + if (imageObject.has("buttonIcon") && !imageObject.isNull("buttonIcon")) { + this.buttonIconId = getDrawableId(imageObject.getString("buttonIcon")); + } + if (imageObject.has("buttonText") && !imageObject.isNull("buttonText")) { + this.buttonText = imageObject.getString("buttonText"); +>>>>>>> dbb72952c7... Fix osm image/mapillary processing } } if (imageObject.has("key")) { @@ -465,6 +518,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 cae773173b..d2055c52c0 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/cards/UrlImageCard.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/cards/UrlImageCard.java @@ -12,11 +12,22 @@ public class UrlImageCard extends ImageCard { public UrlImageCard(MapActivity mapActivity, JSONObject imageObject) { super(mapActivity, imageObject); +<<<<<<< HEAD if (!Algorithms.isEmpty(getUrl())) { OnClickListener onClickListener = new OnClickListener() { @Override public void onClick(View v) { openUrl(getMapActivity(), getMyApplication(), "", getUrl(), isExternalLink()); +======= + + if (!Algorithms.isEmpty(getSuitableUrl())) { + OnClickListener onClickListener = new OnClickListener() { + @Override + public void onClick(View v) { + openUrl(getMapActivity(), getMyApplication(), getTitle(), getSuitableUrl(), + isExternalLink() || Algorithms.isEmpty(getImageHiresUrl()), + !Algorithms.isEmpty(getImageHiresUrl())); +>>>>>>> dbb72952c7... Fix osm image/mapillary processing } }; if (!Algorithms.isEmpty(buttonText)) { @@ -26,4 +37,14 @@ public class UrlImageCard extends ImageCard { } } } + + private String getSuitableUrl() { + final String url; + if (Algorithms.isEmpty(getImageHiresUrl())) { + url = getUrl(); + } else { + url = getImageHiresUrl(); + } + return url; + } }