diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java index 7fa8fdd95f..6a1b3958b7 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/WikipediaDialogFragment.java @@ -271,17 +271,17 @@ public class WikipediaDialogFragment extends DialogFragment { return (OsmandApplication) getActivity().getApplication(); } - public static boolean showInstance(AppCompatActivity activity, Amenity amenity) { + public static boolean showInstance(AppCompatActivity activity, Amenity amenity, String lang) { try { if (!amenity.getType().isWiki()) { return false; } OsmandApplication app = (OsmandApplication) activity.getApplication(); - String lang = app.getSettings().MAP_PREFERRED_LOCALE.get(); WikipediaDialogFragment wikipediaDialogFragment = new WikipediaDialogFragment(); wikipediaDialogFragment.setAmenity(amenity); - wikipediaDialogFragment.setLanguage(lang); + wikipediaDialogFragment.setLanguage(lang == null ? + app.getSettings().MAP_PREFERRED_LOCALE.get() : lang); wikipediaDialogFragment.setRetainInstance(true); wikipediaDialogFragment.show(activity.getSupportFragmentManager(), TAG); return true; @@ -289,4 +289,8 @@ public class WikipediaDialogFragment extends DialogFragment { return false; } } + + public static boolean showInstance(AppCompatActivity activity, Amenity amenity) { + return showInstance(activity, amenity, null); + } } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageWebViewClient.java b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageWebViewClient.java index 00ad198b8d..74982c22e1 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageWebViewClient.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageWebViewClient.java @@ -91,8 +91,9 @@ public class WikivoyageWebViewClient extends WebViewClient implements RegionCall } return true; } else if (url.contains(WIKI_DOMAIN)) { - String articleName = getArticleNameFromUrl(url, getLang(url)); - getWikiArticle(articleName, url); + String lang = getLang(url); + String articleName = getArticleNameFromUrl(url, lang); + getWikiArticle(articleName, lang, url); } else if (url.startsWith(PAGE_PREFIX_HTTP) || url.startsWith(PAGE_PREFIX_HTTPS)) { warnAboutExternalLoad(url, context, nightMode); } else if (url.startsWith(PREFIX_GEO)) { @@ -181,14 +182,14 @@ public class WikivoyageWebViewClient extends WebViewClient implements RegionCall } } - private void getWikiArticle(String name, String url) { + private void getWikiArticle(String name, String lang, String url) { List indexes = app.getResourceManager() .getWikiAmenityRepository(article.getLat(), article.getLon()); if (indexes.isEmpty()) { WikivoyageArticleWikiLinkFragment.showInstance(fragmentManager, regionName == null ? "" : regionName, url); } else { - articleSearchTask = new WikiArticleSearchTask(name, indexes, (MapActivity) context, nightMode, url); + articleSearchTask = new WikiArticleSearchTask(name, lang, indexes, (MapActivity) context, nightMode, url); articleSearchTask.execute(); } @@ -274,10 +275,12 @@ public class WikivoyageWebViewClient extends WebViewClient implements RegionCall private WeakReference weakContext; private boolean isNightMode; private String url; + private String lang; - WikiArticleSearchTask(String articleName, List indexes, + WikiArticleSearchTask(String articleName, String lang, List indexes, MapActivity context, boolean isNightMode, String url) { name = articleName; + this.lang = lang; this.indexes = indexes; weakContext = new WeakReference<>(context); dialog = createProgressDialog(); @@ -317,7 +320,7 @@ public class WikivoyageWebViewClient extends WebViewClient implements RegionCall if (activity != null && !activity.isActivityDestroyed() && dialog != null) { dialog.dismiss(); if (!found.isEmpty()) { - WikipediaDialogFragment.showInstance(activity, found.get(0)); + WikipediaDialogFragment.showInstance(activity, found.get(0), lang); } else { warnAboutExternalLoad(url, weakContext.get(), isNightMode); }