diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java index 52e6fd576e..820ccb5df1 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java @@ -20,10 +20,13 @@ import android.webkit.WebView; import android.widget.TextView; import net.osmand.AndroidUtils; +import net.osmand.IndexConstants; import net.osmand.plus.R; import net.osmand.plus.wikivoyage.data.WikivoyageArticle; import net.osmand.plus.wikivoyage.data.WikivoyageSearchResult; +import java.io.File; + public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragment { public static final String TAG = "WikivoyageArticleDialogFragment"; @@ -34,7 +37,7 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen private static final String HEADER_INNER = "\n" + "\n" + "\n" + - "\n" + + "\n" + "\n" + "
\n"; private static final String FOOTER_INNER = "
"; @@ -152,9 +155,19 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen } String content = HEADER_INNER + article.getContent() + FOOTER_INNER; - contentWebView.loadDataWithBaseURL(null, content, "text/html", "UTF-8", null); + contentWebView.loadDataWithBaseURL(getBaseUrl(), content, "text/html", "UTF-8", null); } + @NonNull + private String getBaseUrl() { + File wikivoyageDir = getMyApplication().getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR); + if (new File(wikivoyageDir, "article_style.css").exists()) { + return "file://" + wikivoyageDir.getAbsolutePath() + "/"; + } + return "file:///android_asset/"; + } + + @NonNull private Drawable getSelectedLangIcon() { Drawable normal = getContentIcon(R.drawable.ic_action_map_language); if (Build.VERSION.SDK_INT >= 21) {