From c79058e796a2f2555c9f361934e733c4e31e08df Mon Sep 17 00:00:00 2001 From: Thad Hughes Date: Sat, 15 Dec 2012 15:33:22 -0800 Subject: [PATCH] Mostly work on Link spans, and upgrade the manfiest to 4.0. --- AndroidManifest.xml | 4 +- res/raw/help.html | 9 +- res/raw/whats_new.html | 133 +----------------- res/values-de/strings.xml | 4 +- res/values-it/strings.xml | 2 +- res/values-v11/themes.xml | 4 +- res/values/strings.xml | 4 +- .../dictionary/DictionaryActivity.java | 22 +-- .../dictionary/HtmlDisplayActivity.java | 1 - .../android/dictionary/engine/HtmlEntry.java | 13 +- .../android/util/NonLinkClickableSpan.java | 2 +- 11 files changed, 44 insertions(+), 154 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 17ccec8..74fbac2 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -2,8 +2,8 @@ + android:versionCode="22" + android:versionName="4.0" >

Dictionary data

-Most dictionary data comes from http://wiktionary.org (mostly from -en.wiktionary.org). If you want to add or fix an entry, please do -it there. +Most dictionary data comes from http://wiktionary.org. +If you want to add or fix an entry, please do it there.

Important notes

  • If QuickDic seems to crash when opening a dictionary @@ -36,7 +35,7 @@ multiple places, under all the relevant words.
    • Type a single word to search for it. QuickDic searches as you type, jumping to the relevant position in the list.
    • -
    • (NEW) Type multiple words separated by spaces. QuickDic finds +
    • Type multiple words separated by spaces. QuickDic finds all the rows containing all of the words and displays them.
    • QuickDic tries to sort words using a romanized transliteration, so you can try searching for non-Latin words using the Latin @@ -48,7 +47,7 @@ its contents will be replaced.
      • Click the button to the right of the search box to switch dictionary directions: EN->DE to DE->EN.
      • -
      • (NEW) Long-click the button to the right of the search box to +
      • Long-click the button to the right of the search box to pick a new dictionary.
      • Long-click any entry to bring up the context menu, from which you can: diff --git a/res/raw/whats_new.html b/res/raw/whats_new.html index 615f32b..095cc22 100644 --- a/res/raw/whats_new.html +++ b/res/raw/whats_new.html @@ -9,137 +9,18 @@ -Thanks for updating to QuickDic 3.3. +Thanks for updating to QuickDic 4.0.

        New features:

        • If QuickDic crashes on your device (especially Sony Ericsson devices), try using QuickDic's preferences to change to the "System default" font.
        • -
        • Updated all dictionaries with new enwiktionary data.
        • -
        • Several non-English dictionaries available for download -(probably lower quality but perhaps useful, in beta): -
            -
          • Arabic-Chinese|Mandarin|Cantonese
          • -
          • Arabic-French
          • -
          • Arabic-German
          • -
          • Arabic-Hebrew
          • -
          • Arabic-Italian
          • -
          • Arabic-Japanese
          • -
          • Arabic-Russian
          • -
          • Arabic-Spanish
          • -
          • Bulgarian-French
          • -
          • Catalan-German
          • -
          • Czech-French
          • -
          • Czech-German
          • -
          • English-Afrikaans
          • -
          • English-Albanian
          • -
          • English-Arabic
          • -
          • English-Armenian
          • -
          • English-Azeri
          • -
          • English-Basque
          • -
          • English-Belarusian
          • -
          • English-Bengali
          • -
          • English-Bosnian
          • -
          • English-Breton
          • -
          • English-Bulgarian
          • -
          • English-Burmese
          • -
          • English-Catalan
          • -
          • English-Chinese|Mandarin|Cantonese
          • -
          • English-Croatian
          • -
          • English-Czech
          • -
          • English-Danish
          • -
          • English-Dutch
          • -
          • English-Esperanto
          • -
          • English-Estonian
          • -
          • English-Faroese
          • -
          • English-Finnish
          • -
          • English-French
          • -
          • English-Gaelic
          • -
          • English-Galician
          • -
          • English-Georgian
          • -
          • English-Greek
          • -
          • English-Haitian Creole
          • -
          • English-Hawaiian
          • -
          • English-Hebrew
          • -
          • English-Hindi
          • -
          • English-Hungarian
          • -
          • English-Icelandic
          • -
          • English-Indonesian
          • -
          • English-Irish
          • -
          • English-Italian
          • -
          • English-Japanese
          • -
          • English-Korean
          • -
          • English-Kurdish
          • -
          • English-Latin
          • -
          • English-Latvian
          • -
          • English-Lithuanian
          • -
          • English-Luxembourgish
          • -
          • English-Macedonian
          • -
          • English-Malay
          • -
          • English-Maori
          • -
          • English-Mongolian
          • -
          • English-Nepali
          • -
          • English-Norwegian
          • -
          • English-Persian
          • -
          • English-Polish
          • -
          • English-Portuguese
          • -
          • English-Punjabi
          • -
          • English-Romanian
          • -
          • English-Russian
          • -
          • English-Sanskrit
          • -
          • English-Serbian
          • -
          • English-Slovak
          • -
          • English-Somali
          • -
          • English-Spanish
          • -
          • English-Swahili
          • -
          • English-Swedish
          • -
          • English-Tagalog
          • -
          • English-Tajik
          • -
          • English-Thai
          • -
          • English-Tibetan
          • -
          • English-Turkish
          • -
          • English-Ukrainian
          • -
          • English-Urdu
          • -
          • English-Vietnamese
          • -
          • English-Welsh
          • -
          • English-Yiddish
          • -
          • English-Zulu
          • -
          • Finnish-Norwegian
          • -
          • Finnish-Swedish
          • -
          • French-Chinese|Mandarin|Cantonese
          • -
          • French-Dutch
          • -
          • French-Italian
          • -
          • French-Japanese
          • -
          • French-Latin
          • -
          • French-Russian
          • -
          • German-Chinese|Mandarin|Cantonese
          • -
          • German-English
          • -
          • German-Esperanto
          • -
          • German-French
          • -
          • German-Hungarian
          • -
          • German-Italian
          • -
          • German-Japanese
          • -
          • German-Latin
          • -
          • German-Polish
          • -
          • German-Russian
          • -
          • German-Spanish
          • -
          • German-Swedish
          • -
          • Greek-Italian
          • -
          • Hungarian-Italian
          • -
          • Italian-Chinese|Mandarin|Cantonese
          • -
          • Italian-Dutch
          • -
          • Italian-Japanese
          • -
          • Italian-Latin
          • -
          • Italian-Latvian
          • -
          • Italian-Polish
          • -
          • Italian-Russian
          • -
          • Italian-Swedish
          • -
          • Japanese-Chinese|Mandarin|Cantonese
          • -
          • Korean-Chinese|Mandarin|Cantonese
          • -
          • Norwegian-Swedish
          • -
          • Spanish-Chinese|Mandarin|Cantonese
          • -
          • Spanish-French
          • -
          • Spanish-Italian
          • +
          • (BETA) Single-language dictionaries for English, German, Italian, and French (French is ALPHA quality).
          • +
          • Detail pages showing more Wiktionary information about the word, including Italian verb conjugations.
          • +
          • Started parsing Wiktionary data from de.wiktionary.org and it.wiktionary.org for better coverage of those languages.
          • +
          • Updated all dictionaries with latest Wiktionary data.
          • +
          • Simple text-to-speech pronunciations for main rows.
          • +
          • Several new dictionaries, by request.
        diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml index e89e4f4..edec006 100644 --- a/res/values-de/strings.xml +++ b/res/values-de/strings.xml @@ -3,7 +3,7 @@ QuickDic - QuickDic 3.3 + QuickDic 4.0 Über QuickDic… @@ -24,7 +24,7 @@ Filter Nur SD-Karte - 3.3_de_a + 4.0_de_a Suchtext diff --git a/res/values-it/strings.xml b/res/values-it/strings.xml index 137b4cb..3f16ab8 100644 --- a/res/values-it/strings.xml +++ b/res/values-it/strings.xml @@ -1,7 +1,7 @@ QuickDic -QuickDic 3.3 +QuickDic 4.0 About QuickDic… Preferenze… diff --git a/res/values-v11/themes.xml b/res/values-v11/themes.xml index 9be50db..b2f04ea 100644 --- a/res/values-v11/themes.xml +++ b/res/values-v11/themes.xml @@ -4,14 +4,14 @@ diff --git a/res/values/strings.xml b/res/values/strings.xml index 9cb903f..467cbf6 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -3,7 +3,7 @@ QuickDic - QuickDic 3.3 + QuickDic 4.0 About QuickDic… @@ -25,7 +25,7 @@ Local only - 3.3_en_e + 4.0_en_a Search Text diff --git a/src/com/hughes/android/dictionary/DictionaryActivity.java b/src/com/hughes/android/dictionary/DictionaryActivity.java index 34ea4f6..96f385e 100644 --- a/src/com/hughes/android/dictionary/DictionaryActivity.java +++ b/src/com/hughes/android/dictionary/DictionaryActivity.java @@ -32,6 +32,7 @@ import android.text.Selection; import android.text.Spannable; import android.text.TextWatcher; import android.text.method.LinkMovementMethod; +import android.text.style.ClickableSpan; import android.text.style.StyleSpan; import android.util.Log; import android.util.TypedValue; @@ -1261,6 +1262,7 @@ public class DictionaryActivity extends ListActivity { final TextViewLongClickListener textViewLongClickListenerIndex0 = new TextViewLongClickListener( 0); textView.setOnLongClickListener(textViewLongClickListenerIndex0); + result.setLongClickable(true); // Doesn't work: // textView.setTextColor(android.R.color.secondary_text_light); @@ -1278,9 +1280,16 @@ public class DictionaryActivity extends ListActivity { tableRow.addView(textView); if (!htmlEntries.isEmpty()) { - final ImageButton button = new ImageButton(context); - button.setImageResource(R.drawable.ic_menu_forward); - button.setOnClickListener(new OnClickListener() { + final ClickableSpan clickableSpan = new ClickableSpan() { + @Override + public void onClick(View widget) { + } + }; + ((Spannable) textView.getText()).setSpan(clickableSpan, 0, text.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE); + result.setClickable(true); + textView.setClickable(true); + textView.setMovementMethod(LinkMovementMethod.getInstance()); + textView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { final String html = HtmlEntry.htmlBody(htmlEntries, index.shortName); @@ -1291,14 +1300,7 @@ public class DictionaryActivity extends ListActivity { 0); } }); - tableRow.addView(button); - lp = new TableRow.LayoutParams(1); - lp.weight = 0.0f; - button.setLayoutParams(lp); - // result.setColumnStretchable(0, true); - // result.setColumnStretchable(1, false); } - result.setLongClickable(true); return result; } diff --git a/src/com/hughes/android/dictionary/HtmlDisplayActivity.java b/src/com/hughes/android/dictionary/HtmlDisplayActivity.java index 80ea18f..9ed1454 100644 --- a/src/com/hughes/android/dictionary/HtmlDisplayActivity.java +++ b/src/com/hughes/android/dictionary/HtmlDisplayActivity.java @@ -20,7 +20,6 @@ import android.os.Bundle; import android.util.Log; import android.view.View; import android.view.View.OnClickListener; -import android.webkit.WebView; import android.widget.Button; import com.hughes.util.StringUtil; diff --git a/src/com/hughes/android/dictionary/engine/HtmlEntry.java b/src/com/hughes/android/dictionary/engine/HtmlEntry.java index 86ebca2..4143fd3 100644 --- a/src/com/hughes/android/dictionary/engine/HtmlEntry.java +++ b/src/com/hughes/android/dictionary/engine/HtmlEntry.java @@ -1,6 +1,7 @@ package com.hughes.android.dictionary.engine; import android.content.Intent; +import android.net.Uri; import com.hughes.android.dictionary.C; import com.hughes.util.StringUtil; @@ -11,6 +12,10 @@ import com.ibm.icu.text.Transliterator; import java.io.IOException; import java.io.PrintStream; import java.io.RandomAccessFile; +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.net.URLDecoder; +import java.net.URLEncoder; import java.util.List; import java.util.regex.Pattern; @@ -165,7 +170,11 @@ public class HtmlEntry extends AbstractEntry implements RAFSerializable 0; - return String.format("qd:%s:%s", indexShortName, text); + try { + return String.format("qd:%s:%s", indexShortName, URLEncoder.encode(text, "UTF-8")); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException(e); + } } public static boolean isQuickdicUrl(String url) { @@ -177,7 +186,7 @@ public class HtmlEntry extends AbstractEntry implements RAFSerializable