]> gitweb.fperrin.net Git - Dictionary.git/blobdiff - src/com/hughes/android/dictionary/DictionaryActivity.java
Apply theme and font selection also to HTML for web view.
[Dictionary.git] / src / com / hughes / android / dictionary / DictionaryActivity.java
index 12839caeddcf3d6c351e0a2a137fe4508c38fc1a..8d1f6fc03b3f347b33ea6c80c5521eb7df4246b5 100644 (file)
@@ -1351,7 +1351,9 @@ public class DictionaryActivity extends AppCompatActivity {
         Log.d(LOG, "searchFinished: " + searchOperation + ", searchResult=" + searchResult);
 
         currentSearchOperation = null;
-        uiHandler.postDelayed(new Runnable() {
+        // Note: it's important to post to the ListView, otherwise
+        // the jumpToRow will randomly not work.
+        getListView().post(new Runnable() {
             @Override
             public void run() {
                 if (currentSearchOperation == null) {
@@ -1370,7 +1372,7 @@ public class DictionaryActivity extends AppCompatActivity {
                     Log.d(LOG, "More coming, waiting for currentSearchOperation.");
                 }
             }
-        }, 20);
+        });
     }
 
     private void jumpToRow(final int row) {
@@ -1452,10 +1454,16 @@ public class DictionaryActivity extends AppCompatActivity {
 
     private void showHtml(final List<HtmlEntry> 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(
-                    "<html><head><meta name=\"viewport\" content=\"width=device-width\"></head><body>%s</body></html>", html),
+                    "<html><head><meta name=\"viewport\" content=\"width=device-width\"></head><body style=\"%s\">%s</body></html>", style, html),
                                               htmlTextToHighlight, false),
             0);
     }