Fixed #5444
This commit is contained in:
parent
8887384bbd
commit
c896a1b22c
4 changed files with 10 additions and 2 deletions
|
@ -42,6 +42,7 @@ public class WikiArticleHelper {
|
||||||
private static final int PARTIAL_CONTENT_PHRASES = 3;
|
private static final int PARTIAL_CONTENT_PHRASES = 3;
|
||||||
private static final String PAGE_PREFIX_HTTP = "http://";
|
private static final String PAGE_PREFIX_HTTP = "http://";
|
||||||
private static final String PAGE_PREFIX_HTTPS = "https://";
|
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/";
|
private static final String WIKIVOAYAGE_DOMAIN = ".wikivoyage.org/wiki/";
|
||||||
|
|
||||||
public static final String WIKI_DOMAIN = ".wikipedia.org/wiki/";
|
public static final String WIKI_DOMAIN = ".wikipedia.org/wiki/";
|
||||||
|
@ -59,6 +60,11 @@ public class WikiArticleHelper {
|
||||||
this.nightMode = nightMode;
|
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<Void, Void, List<Amenity>> {
|
public static class WikiArticleSearchTask extends AsyncTask<Void, Void, List<Amenity>> {
|
||||||
|
|
||||||
private ProgressDialog dialog;
|
private ProgressDialog dialog;
|
||||||
|
|
|
@ -33,6 +33,7 @@ public class WikipediaWebViewClient extends WebViewClient {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||||
|
WikiArticleHelper.normalizeFileUrl(url);
|
||||||
if ((url.contains(WIKI_DOMAIN) || url.contains(WIKI_DOMAIN_COM)) && article != null) {
|
if ((url.contains(WIKI_DOMAIN) || url.contains(WIKI_DOMAIN_COM)) && article != null) {
|
||||||
wikiArticleHelper.showWikiArticle(article.getLocation(), url);
|
wikiArticleHelper.showWikiArticle(article.getLocation(), url);
|
||||||
} else if (url.startsWith(PAGE_PREFIX_HTTP) || url.startsWith(PAGE_PREFIX_HTTPS)) {
|
} else if (url.startsWith(PAGE_PREFIX_HTTP) || url.startsWith(PAGE_PREFIX_HTTPS)) {
|
||||||
|
|
|
@ -58,6 +58,7 @@ public class WikivoyageWebViewClient extends WebViewClient {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||||
|
url = WikiArticleHelper.normalizeFileUrl(url);
|
||||||
boolean isWebPage = url.startsWith(PAGE_PREFIX_HTTP) || url.startsWith(PAGE_PREFIX_HTTPS);
|
boolean isWebPage = url.startsWith(PAGE_PREFIX_HTTP) || url.startsWith(PAGE_PREFIX_HTTPS);
|
||||||
if (url.contains(WIKIVOAYAGE_DOMAIN) && isWebPage) {
|
if (url.contains(WIKIVOAYAGE_DOMAIN) && isWebPage) {
|
||||||
String lang = WikiArticleHelper.getLang(url);
|
String lang = WikiArticleHelper.getLang(url);
|
||||||
|
@ -69,7 +70,7 @@ public class WikivoyageWebViewClient extends WebViewClient {
|
||||||
WikiArticleHelper.warnAboutExternalLoad(url, activity, nightMode);
|
WikiArticleHelper.warnAboutExternalLoad(url, activity, nightMode);
|
||||||
}
|
}
|
||||||
return true;
|
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);
|
wikiArticleHelper.showWikiArticle(new LatLon(article.getLat(), article.getLon()), url);
|
||||||
} else if (isWebPage) {
|
} else if (isWebPage) {
|
||||||
WikiArticleHelper.warnAboutExternalLoad(url, activity, nightMode);
|
WikiArticleHelper.warnAboutExternalLoad(url, activity, nightMode);
|
||||||
|
|
|
@ -296,10 +296,10 @@ public class WikivoyageArticleDialogFragment extends WikiArticleBaseDialogFragme
|
||||||
if (article == null) {
|
if (article == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
webViewClient.setArticle(article);
|
||||||
articleToolbarText.setText(article.getTitle());
|
articleToolbarText.setText(article.getTitle());
|
||||||
if (article.getGpxFile() != null && article.getGpxFile().getPointsSize() > 0) {
|
if (article.getGpxFile() != null && article.getGpxFile().getPointsSize() > 0) {
|
||||||
trackButton.setText(getString(R.string.shared_string_gpx_points) + " (" + article.getGpxFile().getPointsSize() + ")");
|
trackButton.setText(getString(R.string.shared_string_gpx_points) + " (" + article.getGpxFile().getPointsSize() + ")");
|
||||||
webViewClient.setArticle(article);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TravelLocalDataHelper ldh = getMyApplication().getTravelDbHelper().getLocalDataHelper();
|
TravelLocalDataHelper ldh = getMyApplication().getTravelDbHelper().getLocalDataHelper();
|
||||||
|
|
Loading…
Reference in a new issue