]> gitweb.fperrin.net Git - Dictionary.git/commitdiff
Highlight text in WebView.
authorthadh <thadh@thadh-macbookpro>
Tue, 25 Sep 2012 05:28:38 +0000 (22:28 -0700)
committerthadh <thadh@thadh-macbookpro>
Tue, 25 Sep 2012 05:28:38 +0000 (22:28 -0700)
src/com/hughes/android/dictionary/DictionaryActivity.java
src/com/hughes/android/dictionary/HtmlDisplayActivity.java
src/com/hughes/android/dictionary/engine/EntryTypeName.java

index 7a0230f0db37e5bce3b690afaf3820ce6c063de3..01933557837d462c53e2d21898ec5d267da82964 100644 (file)
@@ -1197,7 +1197,7 @@ public class DictionaryActivity extends ListActivity {
                     public void onClick(View v) {
                         final String html = HtmlEntry.htmlBody(htmlEntries);
                         startActivity(HtmlDisplayActivity.getHtmlIntent(String.format(
-                                "<html><head></head><body>%s</body></html>", html)));
+                                "<html><head></head><body>%s</body></html>", html), text));
                     }
                 });
                 tableRow.addView(button);
index 4e12ebf284529d61eafe0eb551a430dcb64c3081..f4bc8ce795661808a9dc25d372151521be492bef 100644 (file)
@@ -33,6 +33,7 @@ public final class HtmlDisplayActivity extends Activity {
   \r
   static final String HTML_RES = "html_res";\r
   static final String HTML = "html";\r
+  static final String TEXT_TO_HIGHLIGHT = "textToHighlight";\r
   \r
   public static Intent getHelpLaunchIntent() {\r
     final Intent intent = new Intent();\r
@@ -48,10 +49,11 @@ public final class HtmlDisplayActivity extends Activity {
     return intent;\r
   }\r
 \r
-  public static Intent getHtmlIntent(final String html) {\r
+  public static Intent getHtmlIntent(final String html, final String textToHighlight) {\r
     final Intent intent = new Intent();\r
     intent.setClassName(HtmlDisplayActivity.class.getPackage().getName(), HtmlDisplayActivity.class.getName());\r
     intent.putExtra(HTML, html);\r
+    intent.putExtra(TEXT_TO_HIGHLIGHT, textToHighlight);\r
     return intent;\r
   }\r
 \r
@@ -73,6 +75,11 @@ public final class HtmlDisplayActivity extends Activity {
     final WebView webView = (WebView) findViewById(R.id.webView);\r
     webView.loadData(html, "text/html", "utf-8");\r
     \r
+    final String textToHighlight = getIntent().getStringExtra(TEXT_TO_HIGHLIGHT);\r
+    if (textToHighlight != null && "".equals(textToHighlight)) {\r
+        webView.findAllAsync(textToHighlight);\r
+    }\r
+    \r
     final Button okButton = (Button) findViewById(R.id.okButton);\r
     okButton.setOnClickListener(new OnClickListener() {\r
       @Override\r
index 737ddbb4ee026728a17f25f65345e691adfe7f76..333ee2052a54d26d445c88b5f10cbc7322896407 100644 (file)
@@ -29,6 +29,7 @@ public enum EntryTypeName {
   WIKTIONARY_TITLE_MULTI_DETAIL(false, true, WIKTIONARY_TITLE_SINGLE_DETAIL),
   WIKTIONARY_TITLE_MULTI(false, true, WIKTIONARY_TITLE_SINGLE),
   WIKTIONARY_TRANSLITERATION(),
+  // How we file "casa {f}, case {pl}" under "case"
   WIKTIONARY_INFLECTED_FORM_MULTI(false, true, WIKTIONARY_INFLECTD_FORM_SINGLE),
   WIKTIONARY_ENGLISH_DEF_WIKI_LINK(),
   WIKTIONARY_ENGLISH_DEF_OTHER_LANG(),
@@ -41,11 +42,13 @@ public enum EntryTypeName {
   WIKTIONARY_TRANSLATION_WIKI_TEXT(),
   WIKTIONARY_TRANSLATION_OTHER_TEXT(),
 
+  // How we file entries like: "sono: {form of|essere}" under "sono.".
   WIKTIONARY_IS_FORM_OF_SOMETHING_ELSE(false, true, null),
 
   MULTIROW_HEAD_MANY_WORDS(),
   MULTIROW_TAIL_MANY_WORDS(),
   WIKTIONARY_EXAMPLE(),
+  // The next two are how we file entries like: "sono: {form of|essere}" under "essere".
   WIKTIONARY_BASE_FORM_SINGLE(),  // These two should be eligible for removal if the links are otherwise present.
   WIKTIONARY_BASE_FORM_MULTI(false, false, WIKTIONARY_BASE_FORM_SINGLE),
   PART_OF_HYPHENATED(),