commit
2866e6a5eb
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 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<Void, Void, List<Amenity>> {
|
||||
|
||||
private ProgressDialog dialog;
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue