diff --git a/OsmAnd/src/net/osmand/plus/wikipedia/WikiArticleHelper.java b/OsmAnd/src/net/osmand/plus/wikipedia/WikiArticleHelper.java index 0b467b1d80..34637e9cdf 100644 --- a/OsmAnd/src/net/osmand/plus/wikipedia/WikiArticleHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikipedia/WikiArticleHelper.java @@ -42,6 +42,7 @@ public class WikiArticleHelper { private static final int PARTIAL_CONTENT_PHRASES = 3; private static final String PAGE_PREFIX_HTTP = "http://"; private static final String PAGE_PREFIX_HTTPS = "https://"; + private static final String PAGE_PREFIX_FILE = "file://"; private static final String WIKIVOAYAGE_DOMAIN = ".wikivoyage.org/wiki/"; public static final String WIKI_DOMAIN = ".wikipedia.org/wiki/"; @@ -59,6 +60,11 @@ public class WikiArticleHelper { this.nightMode = nightMode; } + public static String normalizeFileUrl(String url) { + return url.startsWith(PAGE_PREFIX_FILE) ? + url.replace(PAGE_PREFIX_FILE, PAGE_PREFIX_HTTPS) : url; + } + public static class WikiArticleSearchTask extends AsyncTask> { private ProgressDialog dialog; diff --git a/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaWebViewClient.java b/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaWebViewClient.java index ce36a9d8b3..4a4ed76517 100644 --- a/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaWebViewClient.java +++ b/OsmAnd/src/net/osmand/plus/wikipedia/WikipediaWebViewClient.java @@ -33,6 +33,7 @@ public class WikipediaWebViewClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { + url = WikiArticleHelper.normalizeFileUrl(url); if ((url.contains(WIKI_DOMAIN) || url.contains(WIKI_DOMAIN_COM)) && article != null) { wikiArticleHelper.showWikiArticle(article.getLocation(), url); } else if (url.startsWith(PAGE_PREFIX_HTTP) || url.startsWith(PAGE_PREFIX_HTTPS)) { diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageWebViewClient.java b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageWebViewClient.java index 981968517f..2e91785896 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageWebViewClient.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageWebViewClient.java @@ -58,6 +58,7 @@ public class WikivoyageWebViewClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { + url = WikiArticleHelper.normalizeFileUrl(url); boolean isWebPage = url.startsWith(PAGE_PREFIX_HTTP) || url.startsWith(PAGE_PREFIX_HTTPS); if (url.contains(WIKIVOAYAGE_DOMAIN) && isWebPage) { String lang = WikiArticleHelper.getLang(url); @@ -69,7 +70,7 @@ public class WikivoyageWebViewClient extends WebViewClient { WikiArticleHelper.warnAboutExternalLoad(url, activity, nightMode); } return true; - } else if (url.contains(WIKI_DOMAIN) && isWebPage) { + } else if (url.contains(WIKI_DOMAIN) && isWebPage && article != null) { wikiArticleHelper.showWikiArticle(new LatLon(article.getLat(), article.getLon()), url); } else if (isWebPage) { WikiArticleHelper.warnAboutExternalLoad(url, activity, nightMode); diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java index 71ae0aad83..3f6b611952 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java @@ -296,10 +296,10 @@ public class WikivoyageArticleDialogFragment extends WikiArticleBaseDialogFragme if (article == null) { return; } + webViewClient.setArticle(article); articleToolbarText.setText(article.getTitle()); if (article.getGpxFile() != null && article.getGpxFile().getPointsSize() > 0) { trackButton.setText(getString(R.string.shared_string_gpx_points) + " (" + article.getGpxFile().getPointsSize() + ")"); - webViewClient.setArticle(article); } TravelLocalDataHelper ldh = getMyApplication().getTravelDbHelper().getLocalDataHelper();