From: Reimar Döffinger Date: Sat, 18 Apr 2020 11:33:24 +0000 (+0200) Subject: Apply theme and font selection also to HTML for web view. X-Git-Url: http://gitweb.fperrin.net/?p=Dictionary.git;a=commitdiff_plain;h=934313102f9cae5e845ceae738685848a1d272cc Apply theme and font selection also to HTML for web view. --- diff --git a/src/com/hughes/android/dictionary/DictionaryActivity.java b/src/com/hughes/android/dictionary/DictionaryActivity.java index 77454f9..8d1f6fc 100644 --- a/src/com/hughes/android/dictionary/DictionaryActivity.java +++ b/src/com/hughes/android/dictionary/DictionaryActivity.java @@ -1454,10 +1454,16 @@ public class DictionaryActivity extends AppCompatActivity { private void showHtml(final List htmlEntries, final String htmlTextToHighlight) { String html = HtmlEntry.htmlBody(htmlEntries, index.shortName); + String style = ""; + if (typeface == Typeface.SERIF) { style = "font-family: serif;"; } + else if (typeface == Typeface.SANS_SERIF) { style = "font-family: sans-serif;"; } + else if (typeface == Typeface.MONOSPACE) { style = "font-family: monospace;"; } + if (application.getSelectedTheme() == DictionaryApplication.Theme.DEFAULT) + style += "background-color: black; color: white;"; // Log.d(LOG, "html=" + html); startActivityForResult( HtmlDisplayActivity.getHtmlIntent(getApplicationContext(), String.format( - "%s", html), + "%s", style, html), htmlTextToHighlight, false), 0); } diff --git a/src/com/hughes/android/dictionary/MyWebView.java b/src/com/hughes/android/dictionary/MyWebView.java index 950b8ab..d57ad0b 100644 --- a/src/com/hughes/android/dictionary/MyWebView.java +++ b/src/com/hughes/android/dictionary/MyWebView.java @@ -37,6 +37,8 @@ public class MyWebView extends WebView { super(context, attrs); getSettings().setSupportZoom(true); getSettings().setBuiltInZoomControls(true); + // TODO: check why AUTO does not work and consider using it (API 29/Android 10 only) + //getSettings().setForceDark(WebSettings.FORCE_DARK_ON); final WebViewClient webViewClient = new WebViewClient() { @Override