]> gitweb.fperrin.net Git - Dictionary.git/commitdiff
Long-press on lang button shows list.
authorThad Hughes <thad.hughes@gmail.com>
Tue, 24 Jan 2012 19:09:08 +0000 (11:09 -0800)
committerThad Hughes <thad.hughes@gmail.com>
Tue, 24 Jan 2012 19:09:08 +0000 (11:09 -0800)
23 files changed:
res/_values-de/arrays.xml [moved from res/values-de/arrays.xml with 100% similarity]
res/_values-de/strings.xml [moved from res/values-de/strings.xml with 77% similarity]
res/layout/download_activity.xml
res/layout/edit_activity.xml [deleted file]
res/layout/help_activity.xml [new file with mode: 0644]
res/layout/list_activity.xml
res/raw-de/whats_new.html [new file with mode: 0644]
res/raw/whats_new.html [new file with mode: 0644]
res/values/languages.xml
res/values/strings.xml
src/com/hughes/android/dictionary/C.java
src/com/hughes/android/dictionary/DictionaryActivity.java
src/com/hughes/android/dictionary/DictionaryApplication.java
src/com/hughes/android/dictionary/DictionaryInfo.java
src/com/hughes/android/dictionary/DictionaryLink.java [new file with mode: 0644]
src/com/hughes/android/dictionary/DictionaryManagerActivity.java
src/com/hughes/android/dictionary/DownloadActivity.java
src/com/hughes/android/dictionary/HelpActivity.java [new file with mode: 0644]
src/com/hughes/android/dictionary/engine/Dictionary.java
src/com/hughes/android/dictionary/engine/EntryTypeName.java
src/com/hughes/android/dictionary/engine/Language.java
src/com/hughes/android/util/IntentLauncher.java
todo.txt [deleted file]

similarity index 77%
rename from res/values-de/strings.xml
rename to res/_values-de/strings.xml
index 6257845e7c7485565f032789f39c008d0d332035..1854d92fa35602ca542fb1f0b03b36d29f942a8d 100644 (file)
@@ -3,20 +3,16 @@
 
        <string name="app_name">QuickDic</string>
  
-  <!-- DictionaryListActivity -->
-  <string name="dictionaryList">Wörterbuch-Liste</string>
-  <string name="selectADictionary"><![CDATA[Wählen Sie ein Wörterbuch.\n
-Long-drücken, um das Wörterbuch Konfiguration zu bearbeiten. Drücken Sie "Menü", um ein neues Wörterbuch hinzufügen.]]></string>
-  <string name="addDictionary">Wörterbuch hinzufügen</string>
-  <string name="addDefaultDictionaries">Default Wörterbücher hinzufügen</string>
-  <string name="removeAllDictionaries">Alle Wörterbücher entfernen</string>
-  <string name="editDictionary">Wörterbuch Config bearbeiten</string>
-  <string name="deleteDictionary">Wörterbuch entfernen</string>
-  <string name="newDictionary">Neues Wörterbuch</string>
+  <!-- DictionaryManagerActivity -->
+  <string name="dictionaryManager">Wörterbuch-Liste</string>
+  <string name="helpText">Long-drücken, um weitere Möglichkeiten zu sehen.</string>
+  <string name="downloadButton">Herunterladen</string>
+  <string name="updateButton">Neuladen</string>
   <string name="moveToTop">Nach Anfang ziehen</string>
-  <string name="notOnDevice">%s (nicht auf dem Gerät)</string>
+  <string name="deleteDictionary">Wörterbuch entfernen</string>
+  <string name="nameFormat2">%1$s (%2$s=%3$d, %4$s=%5$d Einträge)</string>
 
-  <string name="thanksForUpdatingVersion">3.0.1k</string>
+  <string name="thanksForUpdatingVersion">3.1</string>
   <!-- Don't use links in the text below, it crashes the app. -->
   <string name="thanksForUpdating"><![CDATA[
 <html>
@@ -24,8 +20,8 @@ Long-drücken, um das Wörterbuch Konfiguration zu bearbeiten. Drücken Sie "Men
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> 
 </head>
 <body>
-  Danke, da&szlig; Sie QuickDic 3.0.1 heruntergeladen haben.
-  <p> neue Funktionen:
+  Danke, da&szlig; Sie QuickDic 3.1 heruntergeladen haben.
+  <p> Neue Funktionen:
   <ul>
     <li> QuickDic ist Open-Source!
     <li> Neue Einstellungen:
@@ -44,7 +40,7 @@ Long-drücken, um das Wörterbuch Konfiguration zu bearbeiten. Drücken Sie "Men
   <!-- DictionaryEditActivity -->
   <string name="dictionaryName">Wörterbuch Name</string>
   <string name="downloadUrl">Wörterbuch URL</string>
-  <string name="downloadButton">Herunterladen</string>
+  
   <string name="openButton">Öffnen</string>
   <string name="dictionaryInfo">Wörterbuch Info:</string>
   <string name="localFile">Wörterbuch Datei</string>
@@ -52,17 +48,16 @@ Long-drücken, um das Wörterbuch Konfiguration zu bearbeiten. Drücken Sie "Men
   <string name="fileNotFound">Datei nicht gefunden: \'%s\'</string>
   <string name="invalidDictionary">Ungültige Wörterbuch: file=%1$s, error=%2$s</string>
   <string name="numPairEntries">Einträge: %,d</string>
-  <string name="numTokens">Tokens: %,d</string>
-  <string name="numRows">Reihe: %,d</string>
 
  
-       <!-- Main -->
-       <string name="searchText">Suchtext</string>
-       <string name="downloadDictionary">Wörterbuch herunterladen…</string>
-       <string name="switchToLanguage">Zu %s wechseln</string>
-       <string name="preferences">Einstellungen…</string>
-       <string name="about">Über QuickDic…</string>
-       <string name="addToWordList">Zum Wortliste hinzufügen: %s</string>
+  <!-- Main -->
+  <string name="searchText">Suchtext</string>
+  <string name="downloadDictionary">Wörterbuch herunterladen…</string>
+  <string name="switchToLanguage">Zu %s wechseln</string>
+  <string name="preferences">Einstellungen…</string>
+  <string name="about">Über QuickDic…</string>
+  <string name="addToWordList">Zum Wortliste hinzufügen: %s</string>
+  <string name="searchForSelection">Suche: %s</string>
   <string name="failedAddingToWordList">Fehler beim Hinzufügen zur Wortliste: %s</string>
   <string name="unzippingDictionary">Wörterbuch entpacken…</string>
   <string name="failedToUnzipDictionary">Fehler beim Entpackung der Wörterbuch…</string>
@@ -97,7 +92,7 @@ Long-drücken, um das Wörterbuch Konfiguration zu bearbeiten. Drücken Sie "Men
 
   <string name="fontSizeKey">fontSize</string>
   <string name="fontSizeTitle">Schriftgröße</string>
-  <string name="fontSizeSummary">Die Größe der Schriftart für die Wörterbuch-Reihen (Neustart erforderlich).</string>
+  <string name="fontSizeSummary">Die Größe der Schriftart für die Wörterbuch-Reihen.</string>
 
   <string name="saveOnlyFirstSubentryKey">saveOnlyFirstSubentry</string>
   <string name="saveOnlyFirstSubentryTitle">Speichern nur erste Sub-Eintrag</string>
@@ -113,6 +108,6 @@ Long-drücken, um das Wörterbuch Konfiguration zu bearbeiten. Drücken Sie "Men
 
   <string name="themeKey">theme</string>
   <string name="themeTitle">UI Theme</string>
-  <string name="themeSummary">User-Interface Farbschema (Neustart erforderlich).</string>
+  <string name="themeSummary">User-Interface Farbschema.</string>
   
 </resources>
index 13457b81c0f7c4cc23cd87858a2390db46c37e63..39bebce2eeb2583f697fc05289f148e025e2cbf1 100755 (executable)
@@ -28,7 +28,9 @@
                android:layout_width="fill_parent" android:layout_height="wrap_content" android:indeterminate="false"/>
 
   <TextView android:id="@+id/downloadMessage" android:layout_width="wrap_content"
-    android:layout_height="wrap_content" android:visibility="visible" android:text="Download message."/>
+    android:layout_height="wrap_content" android:visibility="visible" android:text="Download message."
+    android:layout_marginTop="10dip"
+    android:layout_marginBottom="10dip"/>
  
        <TextView android:id="@+id/downloadStatus" android:layout_width="wrap_content"
                android:layout_height="wrap_content" android:visibility="visible" android:text="Download status."/>
diff --git a/res/layout/edit_activity.xml b/res/layout/edit_activity.xml
deleted file mode 100755 (executable)
index 00474ec..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-<ScrollView android:id="@+id/ScrollView01"
-       xmlns:android="http://schemas.android.com/apk/res/android"
-       android:layout_width="fill_parent" 
-       android:layout_height="fill_parent">
-       
-<LinearLayout 
-       android:id="@+id/LinearLayout01"
-       android:orientation="vertical"
-       android:layout_width="fill_parent"
-       android:layout_height="wrap_content"
-       >
-
-<!--     android:textAppearance="?android:attr/textAppearanceLarge"  -->
-
-  <!-- Name. --> 
-  <TextView 
-    android:id="@+id/dictionaryNameTitle" 
-    android:text="@string/dictionaryName"
-    android:layout_width="wrap_content" 
-    android:layout_height="wrap_content" />
-  <EditText 
-    android:id="@+id/dictionaryName"
-    android:inputType="textNoSuggestions" 
-    android:layout_width="fill_parent" 
-    android:layout_height="wrap_content" />
-
-  <!-- Local file. --> 
-  <TextView 
-    android:id="@+id/localFileTitle" 
-    android:text="@string/localFile"
-    android:layout_width="wrap_content" 
-    android:layout_height="wrap_content"
-    android:paddingTop="5dip" />
-  <EditText 
-    android:id="@+id/localFile"
-    android:inputType="textUri"
-    android:layout_width="fill_parent" 
-    android:layout_height="wrap_content" />
-
-  <!-- Download URL. --> 
-  <TextView 
-    android:id="@+id/downloadUrlTitle" 
-    android:text="@string/downloadUrl"
-    android:layout_width="wrap_content" 
-    android:layout_height="wrap_content"
-    android:paddingTop="5dip" />
-  <EditText 
-    android:id="@+id/downloadUrl" 
-    android:inputType="textUri"
-    android:layout_width="fill_parent" 
-    android:layout_height="wrap_content" />
-
- <LinearLayout 
-   android:id="@+id/LinearLayout03"
-   android:orientation="horizontal"
-   android:layout_width="wrap_content"
-   android:layout_height="wrap_content"
-   >
-
-  <Button
-    android:id="@+id/downloadButton"
-    android:text="@string/downloadButton"
-    android:layout_width="wrap_content" 
-    android:layout_height="wrap_content"
-   />
-  <Button
-    android:id="@+id/openButton"
-    android:text="@string/openButton"
-    android:layout_width="wrap_content" 
-    android:layout_height="wrap_content"
-   />
- </LinearLayout>
-
-  <TextView 
-    android:id="@+id/dictionaryInfoTitle" 
-    android:text="@string/dictionaryInfo"
-    android:layout_width="wrap_content" 
-    android:layout_height="wrap_content"
-    android:paddingTop="5dip" />
-  <TextView 
-    android:id="@+id/dictionaryInfo" 
-    android:text=""
-    android:layout_width="wrap_content" 
-    android:layout_height="wrap_content"
-    android:paddingTop="20dip" />
-
-</LinearLayout>
-
-</ScrollView>
\ No newline at end of file
diff --git a/res/layout/help_activity.xml b/res/layout/help_activity.xml
new file mode 100644 (file)
index 0000000..751e4ec
--- /dev/null
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical" >
+    
+  <WebView
+      android:id="@+id/helpWebView"
+      android:layout_width="match_parent"
+      android:layout_height="match_parent" />
+
+</LinearLayout>
\ No newline at end of file
index 662942eb80696c76f2925e728266b0561d55d7e0..0957b5e7a9b5be418a7f2a8d72addbd278e6842d 100644 (file)
@@ -17,7 +17,7 @@
 
    <TextView 
      android:id="@+id/DictionaryListHeader"
-     android:hint="@string/selectADictionary"
+     android:hint="@string/helpText"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content" 
      android:imeOptions="actionSearch|flagNoEnterAction|flagNoExtractUi"
diff --git a/res/raw-de/whats_new.html b/res/raw-de/whats_new.html
new file mode 100644 (file)
index 0000000..1f4440a
--- /dev/null
@@ -0,0 +1,18 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> 
+</head>
+<body>
+  <!-- Don't use links in the text below, it crashes the app. -->
+
+  Thanks for updating to QuickDic 3.1.
+  <p> New features:
+  <ul>
+    <li> Long-press any word in a dictionary to lookup that word.
+    <li> Long-press the search text to see search history. 
+    <li> Long-press the switch-language button to change dictionaries.
+    <li> New English dictionaries: Tagalog, Urdu. (based on enwiktionary.com data).
+    <li> All dictionaries updated (mostly with better formatting), and can be re-downloaded at your leisure (previously downloaded dictionaries will still work).
+  </ul>
+</body>
+</html>
diff --git a/res/raw/whats_new.html b/res/raw/whats_new.html
new file mode 100644 (file)
index 0000000..7f3562a
--- /dev/null
@@ -0,0 +1,18 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> 
+</head>
+<body>
+  <!-- Don't use links in the text below, it crashes the app. -->
+
+  Thanks for updating to QuickDic 3.1.
+  <p> New features:
+  <ul>
+    <li> Long-press any word in a dictionary to lookup that word.
+    <li> Long-press the search text to see search history. 
+    <li> Long-press the switch-language button to change dictionaries.
+    <li> New English dictionaries: Tagalog, Urdu. (based on enwiktionary.com data).
+    <li> All dictionaries updated (mostly with better formatting), and can be re-downloaded at your leisure (previously downloaded dictionaries will still work).
+  </ul>
+</body>
+</html>
\ No newline at end of file
index 28bc91b3722d7a8212dc19fc69f85791ee295e32..de73d3c80d9d0aa17ae4230c6496d429b5f6d39d 100644 (file)
@@ -12,7 +12,7 @@
   <string name="CA">Catalan</string>
   <string name="HR">Croatian</string>
   <string name="CS">Czech</string>
-  <string name="ZH">Chinese|Mandarin|Cantonese</string>
+  <string name="ZH">Chinese (Mandarin, Cantonese)</string>
   <string name="DA">Danish</string>
   <string name="NL">Dutch</string>
   <string name="EN">English</string>
@@ -54,6 +54,7 @@
   <string name="ES">Spanish</string>
   <string name="SW">Swahili</string>
   <string name="SV">Swedish</string>
+  <string name="TL">Tagalog</string>
   <string name="TG">Tajik</string>
   <string name="TH">Thai</string>
   <string name="BO">Tibetan</string>
index 4ccaafa16b1b804f20058ae7b6eeb0b3f7882865..cef3cc492d4fc1446ce7a4dc81ed2f69048bc481 100644 (file)
@@ -5,65 +5,44 @@
  
   <!-- DictionaryManagerActivity -->
   <string name="dictionaryManager">Dictionary manager</string>
-  <string name="selectADictionary"><![CDATA[Select a dictionary.
-\nLong-press to edit the dictionary config. Press "menu" to add a new dictionary.]]></string>
-  <string name="dictionaryConfig">Dictionary config</string>
+  <string name="helpText">Long-press for more options.</string>
+  <string name="downloadButton">Download</string>
+  <string name="updateButton">Update</string>
   <string name="moveToTop">Move to top</string>
   <string name="deleteDictionary">Delete dictionary</string>
-  <string name="notOnDevice">%s (not on device)</string>
+  <string name="nameFormat2">%1$s (%2$s=%3$d, %4$s=%5$d entries)</string>
+  
 
-  <string name="thanksForUpdatingVersion">3.0.1h</string>
-  <!-- Don't use links in the text below, it crashes the app. -->
-  <string name="thanksForUpdating"><![CDATA[
-<html>
-<body>
-  Thanks for updating to QuickDic 3.0.1.
-  <p> New features:
-  <ul>
-    <li> QuickDic is open-source!
-    <li> New preferences:
-    <ul>
-      <li> Dictionary font size is adjustable.
-      <li> Short clicks on dictionary entries no longer open context menu by default.
-    </ul>
-    <li> 17 new English dictionaries: Albanian, Armenian, Belarusian, Bengali, Bosnian, Bulgarian, Catalan, Esperanto, Estonian, Hungarian, Indonesian, Latin, Latvian, Polish, Punjabi, Slovak, Swahili. (based on enwiktionary.com data).
-    <li> All dictionaries updated (mostly with better formatting), and can be re-downloaded at your leisure (previously downloaded dictionaries will still work).
-  </ul>
-</body>
-</html> 
-]]>
-  </string>
+  <string name="thanksForUpdatingVersion">3.1</string>
  
   <!-- DictionaryEditActivity -->
+  <!-- 
   <string name="dictionaryName">Dictionary name</string>
   <string name="downloadUrl">Dictionary download URL</string>
-  <string name="downloadButton">Download</string>
   <string name="openButton">Open</string>
   <string name="dictionaryInfo">Dictionary info:</string>
   <string name="indexInfo">Index %1$s, %2$d words</string>
   <string name="localFile">Dictionary file</string>
   <string name="wordListFile">Word list file</string>
   <string name="fileNotFound">File not found: \'%s\'</string>
-  <string name="invalidDictionary">Invalid dictionary: file=%1$s, error=%2$s</string>
   <string name="numPairEntries">Entries: %,d</string>
-
+ -->
  
-       <!-- Main -->
-       <string name="searchText">Search Text</string>
-       <string name="downloadDictionary">Download dictionary…</string>
-       <string name="switchToLanguage">Switch to %s</string>
-       <string name="preferences">Preferences…</string>
-       <string name="about">About QuickDic…</string> 
-       <string name="addToWordList">Add to word list: %s</string>
+  <!-- DictionaryActivity -->
+  <string name="searchText">Search Text</string>
+  <string name="selectDictionary">Select dictionary…</string>
+  <string name="switchToLanguage">Switch to %s</string>
+  <string name="preferences">Preferences…</string>
+  <string name="about">About QuickDic…</string> 
+  <string name="addToWordList">Add to word list: %s</string>
   <string name="searchForSelection">Find: %s</string>
-       <string name="failedAddingToWordList">Failure adding to word list: %s</string>
-  
-  <!--  do we need? -->
+  <string name="failedAddingToWordList">Failure adding to word list: %s</string>
   <string name="unzippingDictionary">Unzipping dictionary…</string>
   <string name="failedToUnzipDictionary">Failed to unzip dictionary…</string>
-
+  <string name="invalidDictionary">Invalid dictionary: file=%1$s, error=%2$s</string>
+  
        <!-- About. -->
-       <string name="titleWithVersion">QuickDic 3.0.1</string>
+       <string name="titleWithVersion">QuickDic 3.1</string>
        <string name="thadHughes">Thad Hughes</string>
        <string name="contactMe">If you\'re using QuickDic, I\'d love to hear from you.  Unfortunately, I cannot take responsibility for dictionary content (other than formatting), as it is generated from other sources. Please send comments, suggestions, bug reports, or just a quick hello to:</string>
        <string name="myEmail" formatted="false">thad.hughes@gmail.com</string>
@@ -88,7 +67,7 @@
 
   <string name="fontSizeKey">fontSize</string>
   <string name="fontSizeTitle">Font size</string>
-  <string name="fontSizeSummary">The size of the font for dictionary rows (restart required).</string>
+  <string name="fontSizeSummary">The size of the font for dictionary rows.</string>
 
   <string name="saveOnlyFirstSubentryKey">saveOnlyFirstSubentry</string>
   <string name="saveOnlyFirstSubentryTitle">Save only first sub-entry</string>
 
   <string name="themeKey">theme</string>
   <string name="themeTitle">UI theme</string>
-  <string name="themeSummary">User-interface color theme (restart required).</string>
+  <string name="themeSummary">User-interface color theme.</string>
   
 </resources>
index fc28a15dab4f8e44defd9fbbcf89d2e45c2db2fe..fa407b4d18fbcddd236be2aa966624bee2b863dd 100644 (file)
@@ -16,7 +16,7 @@ package com.hughes.android.dictionary;
 
 public class C {
 
-  static final String DICTIONARY_CONFIGS = "dictionaryConfigs";
+  static final String DICTIONARY_CONFIGS = "dictionaryConfigs2";
 
   static final String DICT_FILE = "dictFile";
   static final String INDEX_INDEX = "indexIndex";
@@ -31,7 +31,7 @@ public class C {
         R.drawable.theme_default_token_row_other_bg,
         R.drawable.theme_default_other_lang_bg),
         
-        LIGHT(R.style.Theme_Light,
+    LIGHT(R.style.Theme_Light,
         R.style.Theme_Light_TokenRow_Fg,
         R.drawable.theme_light_token_row_main_bg,
         R.drawable.theme_light_token_row_other_bg,
index 6c69e9b5be350ebd98a2e182e1aee69a20b1af71..428f3a0dad20fed329e131a4e51e94aa925fde90 100644 (file)
@@ -73,6 +73,7 @@ import android.widget.TableRow;
 import android.widget.TextView;\r
 import android.widget.Toast;\r
 \r
+import com.hughes.android.dictionary.DictionaryInfo.IndexInfo;\r
 import com.hughes.android.dictionary.engine.Dictionary;\r
 import com.hughes.android.dictionary.engine.Index;\r
 import com.hughes.android.dictionary.engine.PairEntry;\r
@@ -80,12 +81,14 @@ import com.hughes.android.dictionary.engine.PairEntry.Pair;
 import com.hughes.android.dictionary.engine.RowBase;\r
 import com.hughes.android.dictionary.engine.TokenRow;\r
 import com.hughes.android.dictionary.engine.TransliteratorManager;\r
+import com.hughes.android.util.IntentLauncher;\r
 \r
 public class DictionaryActivity extends ListActivity {\r
 \r
   static final String LOG = "QuickDic";\r
   \r
-  String dictFile = null;\r
+  DictionaryApplication application;\r
+  File dictFile = null;\r
   RandomAccessFile dictRaf = null;\r
   Dictionary dictionary = null;\r
   int indexIndex = 0;\r
@@ -116,15 +119,13 @@ public class DictionaryActivity extends ListActivity {
   \r
   final SearchTextWatcher searchTextWatcher = new SearchTextWatcher();\r
 \r
-  //private Vibrator vibrator = null;\r
-  \r
   public DictionaryActivity() {\r
   }\r
   \r
-  public static Intent getLaunchIntent(final String dictFile, final int indexIndex, final String searchToken) {\r
+  public static Intent getLaunchIntent(final File dictFile, final int indexIndex, final String searchToken) {\r
     final Intent intent = new Intent();\r
     intent.setClassName(DictionaryActivity.class.getPackage().getName(), DictionaryActivity.class.getName());\r
-    intent.putExtra(C.DICT_FILE, dictFile);\r
+    intent.putExtra(C.DICT_FILE, dictFile.getPath());\r
     intent.putExtra(C.INDEX_INDEX, indexIndex);\r
     intent.putExtra(C.SEARCH_TOKEN, searchToken);\r
     return intent;\r
@@ -142,24 +143,23 @@ public class DictionaryActivity extends ListActivity {
     setSearchText(outState.getString(C.SEARCH_TOKEN));\r
   }\r
 \r
-  public DictionaryApplication getDictionaryApplication() {\r
-    return (DictionaryApplication) super.getApplication();\r
-  }\r
-  \r
   @Override\r
-  public void onCreate(Bundle savedInstanceState) {\r
+  public void onCreate(Bundle savedInstanceState) {    \r
+    Log.d(LOG, "onCreate:" + this);\r
+    super.onCreate(savedInstanceState);\r
+\r
+    application = (DictionaryApplication) getApplication();\r
+    theme = application.getSelectedTheme();\r
+\r
     // Clear them so that if something goes wrong, we won't relaunch.\r
     clearDictionaryPrefs(this);\r
     \r
-    Log.d(LOG, "onCreate:" + this);\r
-    theme = ((DictionaryApplication)getApplication()).getSelectedTheme();\r
-    super.onCreate(savedInstanceState);\r
     \r
     final Intent intent = getIntent();\r
-    dictFile = intent.getStringExtra(C.DICT_FILE);\r
+    dictFile = new File(intent.getStringExtra(C.DICT_FILE));\r
 \r
     try {\r
-      final String name = getDictionaryApplication().getDictionaryName(dictFile);\r
+      final String name = application.getDictionaryName(dictFile.getName());\r
       this.setTitle("QuickDic: " + name);\r
       dictRaf = new RandomAccessFile(dictFile, "r");\r
       dictionary = new Dictionary(dictRaf); \r
@@ -256,7 +256,7 @@ public class DictionaryActivity extends ListActivity {
     langButton.setOnLongClickListener(new OnLongClickListener() {\r
       @Override\r
       public boolean onLongClick(View v) {\r
-        onLanguageButtonLongClick();\r
+        onLanguageButtonLongClick(v.getContext());\r
         return true;\r
       }\r
     });\r
@@ -325,9 +325,9 @@ public class DictionaryActivity extends ListActivity {
   }\r
   \r
   private static void setDictionaryPrefs(final Context context,\r
-      final String dictFile, final int indexIndex, final String searchToken) {\r
+      final File dictFile, final int indexIndex, final String searchToken) {\r
     final SharedPreferences.Editor prefs = PreferenceManager.getDefaultSharedPreferences(context).edit();\r
-    prefs.putString(C.DICT_FILE, dictFile);\r
+    prefs.putString(C.DICT_FILE, dictFile.getPath());\r
     prefs.putInt(C.INDEX_INDEX, indexIndex);\r
     prefs.putString(C.SEARCH_TOKEN, searchToken);\r
     prefs.commit();\r
@@ -403,14 +403,12 @@ public class DictionaryActivity extends ListActivity {
   static class OpenIndexButton extends Button implements OnClickListener {\r
 \r
     final Activity activity;\r
-    final String dictFile;\r
-    final int indexIndex;\r
+    final Intent intent;\r
 \r
-    public OpenIndexButton(final Context context, final Activity activity, final String text, final String dictFile, final int indexIndex) {\r
+    public OpenIndexButton(final Context context, final Activity activity, final String text, final Intent intent) {\r
       super(context);\r
       this.activity = activity;\r
-      this.dictFile = dictFile;\r
-      this.indexIndex = indexIndex;\r
+      this.intent = intent;\r
       setOnClickListener(this);\r
       setText(text, BufferType.NORMAL);\r
     }\r
@@ -418,29 +416,47 @@ public class DictionaryActivity extends ListActivity {
     @Override\r
     public void onClick(View v) {\r
       activity.finish();\r
-      getContext().startActivity(DictionaryActivity.getLaunchIntent(dictFile, indexIndex, ""));\r
+      getContext().startActivity(intent);\r
     }\r
     \r
   }\r
 \r
-  void onLanguageButtonLongClick() {\r
-    Context mContext = getApplicationContext();\r
-    Dialog dialog = new Dialog(mContext);\r
-    \r
+  void onLanguageButtonLongClick(final Context context) {\r
+    final Dialog dialog = new Dialog(context);\r
     dialog.setContentView(R.layout.select_dictionary_dialog);\r
-    dialog.setTitle(R.string.selectADictionary);\r
+    dialog.setTitle(R.string.selectDictionary);\r
 \r
-    ListView listView = (ListView) dialog.findViewById(android.R.id.list);\r
-    \r
     final List<DictionaryInfo> installedDicts = ((DictionaryApplication)getApplication()).getUsableDicts();\r
-\r
+    ListView listView = (ListView) dialog.findViewById(android.R.id.list);\r
     listView.setAdapter(new BaseAdapter() {\r
-      \r
       @Override\r
       public View getView(int position, View convertView, ViewGroup parent) {\r
         final LinearLayout result = new LinearLayout(parent.getContext());\r
-        //result.addView(new Butt)\r
-        // TODO: me\r
+        final DictionaryInfo dictionaryInfo = getItem(position);\r
+        for (int i = 0; i < dictionaryInfo.indexInfos.size(); ++i) {\r
+          final IndexInfo indexInfo = dictionaryInfo.indexInfos.get(i);\r
+          final Button button = new Button(parent.getContext());\r
+          String name = application.getLanguageName(indexInfo.shortName);\r
+          if (name == null) {\r
+            name = indexInfo.shortName;\r
+          }\r
+          button.setText(name);\r
+          final IntentLauncher intentLauncher = new IntentLauncher(parent.getContext(), getLaunchIntent(application.getPath(dictionaryInfo.uncompressedFilename), i, "")) {\r
+            @Override\r
+            protected void onGo() {\r
+              dialog.dismiss();\r
+              DictionaryActivity.this.finish();\r
+            };\r
+          };\r
+          button.setOnClickListener(intentLauncher);\r
+          \r
+          final LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);\r
+          layoutParams.width = 0;\r
+          layoutParams.weight = 1.0f;\r
+          button.setLayoutParams(layoutParams);\r
+\r
+          result.addView(button);\r
+        }\r
         return result;\r
       }\r
       \r
@@ -459,6 +475,8 @@ public class DictionaryActivity extends ListActivity {
         return installedDicts.size();\r
       }\r
     });\r
+    \r
+    dialog.show();\r
   }\r
 \r
 \r
index a16ad0e163dafa3112ce9c8740af40a97f373461..297e704fc15b6fc7147f63f157d395d1d94e2707 100644 (file)
@@ -53,12 +53,21 @@ public class DictionaryApplication extends Application {
   static Map<String,DictionaryInfo> DOWNLOADABLE_NAME_TO_INFO = null;
   
   static final class DictionaryConfig implements Serializable {
-    private static final long serialVersionUID = -1444177164708201260L;
+    private static final long serialVersionUID = -1444177164708201262L;
     // User-ordered list, persisted, just the ones that are/have been present.
-    final List<String> dictionaryFiles = new ArrayList<String>();
+    final List<DictionaryInfo> dictionaryFilesOrdered = new ArrayList<DictionaryInfo>();
+    final Set<String> invalidatedFilenames = new LinkedHashSet<String>();
   }
   DictionaryConfig dictionaryConfig = null;
-    
+
+  static final class DictionaryHistory implements Serializable {
+    private static final long serialVersionUID = -4842995032541390284L;
+    // User-ordered list, persisted, just the ones that are/have been present.
+    final List<DictionaryLink> dictionaryLinks = new ArrayList<DictionaryLink>();
+  }
+  DictionaryHistory dictionaryHistory = null;
+
+  
   @Override
   public void onCreate() {
     super.onCreate();
@@ -119,21 +128,37 @@ public class DictionaryApplication extends Application {
     }
   }
 
-  private File getPath(String uncompressedFilename) {
+  public File getPath(String uncompressedFilename) {
     return new File(DICT_DIR, uncompressedFilename);
   }
 
 
   public List<DictionaryInfo> getUsableDicts() {
-    final List<DictionaryInfo> result = new ArrayList<DictionaryInfo>(dictionaryConfig.dictionaryFiles.size());
-    for (final String uncompressedFilename : dictionaryConfig.dictionaryFiles) {
-      final DictionaryInfo dictionaryInfo = Dictionary.getDictionaryInfo(getPath(uncompressedFilename));
+    final List<DictionaryInfo> result = new ArrayList<DictionaryInfo>(dictionaryConfig.dictionaryFilesOrdered.size());
+    for (int i = 0; i < dictionaryConfig.dictionaryFilesOrdered.size(); ++i) {
+      DictionaryInfo dictionaryInfo = dictionaryConfig.dictionaryFilesOrdered.get(i);
+      if (dictionaryConfig.invalidatedFilenames.contains(dictionaryInfo.uncompressedFilename)) {
+        dictionaryInfo = Dictionary.getDictionaryInfo(getPath(dictionaryInfo.uncompressedFilename));
+        if (dictionaryInfo != null) {
+          dictionaryConfig.dictionaryFilesOrdered.set(i, dictionaryInfo);
+        }
+      }
       if (dictionaryInfo != null) {
         result.add(dictionaryInfo);
       }
     }
+    if (!dictionaryConfig.invalidatedFilenames.isEmpty()) {
+      dictionaryConfig.invalidatedFilenames.clear();
+      PersistentObjectCache.getInstance().write(C.DICTIONARY_CONFIGS, dictionaryConfig);
+    }
     return result;
   }
+  
+  public String getLanguageName(final String isoCode) {
+    final Integer langCode = Language.isoCodeToResourceId.get(isoCode);
+    final String lang = langCode != null ? getApplicationContext().getString(langCode) : isoCode;
+    return lang;
+  }
 
   final Map<String, String> fileToNameCache = new LinkedHashMap<String, String>();
   public synchronized String getDictionaryName(final String uncompressedFilename) {
@@ -143,16 +168,13 @@ public class DictionaryApplication extends Application {
     }
     
     final DictionaryInfo dictionaryInfo = DOWNLOADABLE_NAME_TO_INFO.get(uncompressedFilename);
-    final Context context = getApplicationContext();
     if (dictionaryInfo != null) {
       final StringBuilder nameBuilder = new StringBuilder();
       for (int i = 0; i < dictionaryInfo.indexInfos.size(); ++i) {
-        final Integer langCode = Language.isoCodeToResourceId.get(dictionaryInfo.indexInfos.get(i).shortName);
-        final String lang = langCode != null ? context.getString(langCode) : dictionaryInfo.indexInfos.get(i).shortName;
         if (i > 0) {
           nameBuilder.append("-");
         }
-        nameBuilder.append(lang);
+        nameBuilder.append(getLanguageName(dictionaryInfo.indexInfos.get(i).shortName));
       }
       name = nameBuilder.toString();
     } else {
@@ -162,17 +184,26 @@ public class DictionaryApplication extends Application {
     return name;
   }
 
-  public void moveDictionaryToTop(final String canonicalPath) {
-    dictionaryConfig.dictionaryFiles.remove(canonicalPath);
-    dictionaryConfig.dictionaryFiles.add(0, canonicalPath);
+  public void moveDictionaryToTop(final DictionaryInfo dictionaryInfo) {
+    dictionaryConfig.dictionaryFilesOrdered.remove(dictionaryInfo);
+    dictionaryConfig.dictionaryFilesOrdered.add(0, dictionaryInfo);
     PersistentObjectCache.getInstance().write(C.DICTIONARY_CONFIGS, dictionaryConfig);
   }
 
-  public void deleteDictionary(String canonicalPath) {
-    while (dictionaryConfig.dictionaryFiles.remove(canonicalPath)) {};
+  public void deleteDictionary(final DictionaryInfo dictionaryInfo) {
+    while (dictionaryConfig.dictionaryFilesOrdered.remove(dictionaryInfo)) {};
+    getPath(dictionaryInfo.uncompressedFilename).delete();
     PersistentObjectCache.getInstance().write(C.DICTIONARY_CONFIGS, dictionaryConfig);
   }
 
+  final Collator collator = Collator.getInstance();
+  final Comparator<DictionaryInfo> comparator = new Comparator<DictionaryInfo>() {
+    @Override
+    public int compare(DictionaryInfo object1, DictionaryInfo object2) {
+      return collator.compare(getDictionaryName(object1.uncompressedFilename), getDictionaryName(object2.uncompressedFilename));
+    }
+  };
+
   public List<DictionaryInfo> getAllDictionaries() {
     final List<DictionaryInfo> result = getUsableDicts();
     
@@ -181,10 +212,13 @@ public class DictionaryApplication extends Application {
     for (final DictionaryInfo usable : result) {
       known.add(usable.uncompressedFilename);
     }
+    if (!dictionaryConfig.invalidatedFilenames.isEmpty()) {
+      dictionaryConfig.invalidatedFilenames.clear();
+    }
     
     // Are there dictionaries on the device that we didn't know about already?
     // Pick them up and put them at the end of the list.
-    boolean foundNew = false;
+    final List<DictionaryInfo> toAddSorted = new ArrayList<DictionaryInfo>();
     final File[] dictDirFiles = DICT_DIR.listFiles();
     for (final File file : dictDirFiles) {
       if (!file.getName().endsWith(".quickdic")) {
@@ -200,27 +234,25 @@ public class DictionaryApplication extends Application {
         continue;
       }
       known.add(file.getName());
-      foundNew = true;
-      dictionaryConfig.dictionaryFiles.add(file.getName());
-      result.add(dictionaryInfo);
+      toAddSorted.add(dictionaryInfo);
     }
-    if (foundNew) {
+    if (!toAddSorted.isEmpty()) {
+      Collections.sort(toAddSorted, comparator);
+      result.addAll(toAddSorted);
+//      for (final DictionaryInfo dictionaryInfo : toAddSorted) {
+//        dictionaryConfig.dictionaryFilesOrdered.add(dictionaryInfo.uncompressedFilename);
+//      }
+      dictionaryConfig.dictionaryFilesOrdered.addAll(toAddSorted);
       PersistentObjectCache.getInstance().write(C.DICTIONARY_CONFIGS, dictionaryConfig);
     }
 
     // The downloadable ones.
     final Map<String,DictionaryInfo> remaining = new LinkedHashMap<String, DictionaryInfo>(DOWNLOADABLE_NAME_TO_INFO);
     remaining.keySet().removeAll(known);
-    final List<DictionaryInfo> remainingSorted = new ArrayList<DictionaryInfo>(remaining.values());
-    final Collator collator = Collator.getInstance();
-    Collections.sort(remainingSorted, new Comparator<DictionaryInfo>() {
-      @Override
-      public int compare(DictionaryInfo object1, DictionaryInfo object2) {
-        return collator.compare(getDictionaryName(object1.uncompressedFilename), getDictionaryName(object2.uncompressedFilename));
-      }
-    });
-
-    result.addAll(remainingSorted);
+    toAddSorted.clear();
+    toAddSorted.addAll(remaining.values());
+    Collections.sort(toAddSorted, comparator);
+    result.addAll(toAddSorted);
     return result;
   }
 
@@ -228,5 +260,19 @@ public class DictionaryApplication extends Application {
     return getPath(uncompressedFilename).canRead();
   }
 
+  public boolean updateAvailable(final DictionaryInfo dictionaryInfo) {
+    final DictionaryInfo downloadable = DOWNLOADABLE_NAME_TO_INFO.get(dictionaryInfo.uncompressedFilename);
+    return downloadable != null && downloadable.creationMillis > dictionaryInfo.creationMillis;
+  }
+
+  public DictionaryInfo getDownloadable(final String uncompressedFilename) {
+    final DictionaryInfo downloadable = DOWNLOADABLE_NAME_TO_INFO.get(uncompressedFilename);
+    return downloadable;
+  }
+
+  public void invalidateDictionaryInfo(final String uncompressedFilename) {
+    dictionaryConfig.invalidatedFilenames.add(uncompressedFilename);
+    PersistentObjectCache.getInstance().write(C.DICTIONARY_CONFIGS, dictionaryConfig);
+  }
   
 }
index a291dc092824f2a29898460e22b39a738127a668..990f9e1f3f2226bde466a9619967a6822d0e6200 100644 (file)
@@ -58,7 +58,11 @@ public class DictionaryInfo implements Serializable {
   public long creationMillis;
   public final List<IndexInfo> indexInfos = new ArrayList<DictionaryInfo.IndexInfo>();
   public String dictInfo;
-  
+
+  public DictionaryInfo() {
+    // Blank object.
+  }
+
   public StringBuilder append(final StringBuilder result) {
     result.append(uncompressedFilename);
     result.append("\t").append(downloadUrl);
@@ -87,10 +91,6 @@ public class DictionaryInfo implements Serializable {
     dictInfo = fields[i++].replaceAll("\\n", "\n");
   }
 
-  public DictionaryInfo() {
-    // Blank object.
-  }
-
   @Override
   public String toString() {
     return uncompressedFilename;
diff --git a/src/com/hughes/android/dictionary/DictionaryLink.java b/src/com/hughes/android/dictionary/DictionaryLink.java
new file mode 100644 (file)
index 0000000..f740047
--- /dev/null
@@ -0,0 +1,20 @@
+package com.hughes.android.dictionary;
+
+import java.io.Serializable;
+
+public class DictionaryLink implements Serializable {
+  
+  private static final long serialVersionUID = -3842984045642836981L;
+
+  final String uncompressedFilename;
+  final int index;
+  final String searchText;
+
+  private DictionaryLink(String uncompressedFilename, int index,
+      String searchText) {
+    this.uncompressedFilename = uncompressedFilename;
+    this.index = index;
+    this.searchText = searchText;
+  }
+
+}
index d5ac87eb18f16d07054bb9022f934b87520cb5c3..73b8b40b4912f7dab5b93801ae27263f537a7971 100644 (file)
@@ -14,6 +14,7 @@
 
 package com.hughes.android.dictionary;
 
+import java.io.File;
 import java.util.List;
 
 import android.app.AlertDialog;
@@ -38,23 +39,26 @@ import android.widget.AdapterView;
 import android.widget.AdapterView.AdapterContextMenuInfo;
 import android.widget.AdapterView.OnItemClickListener;
 import android.widget.BaseAdapter;
-import android.widget.TableLayout;
+import android.widget.Button;
+import android.widget.LinearLayout;
 import android.widget.TextView;
 
+import com.hughes.android.util.IntentLauncher;
+import com.hughes.util.StringUtil;
+
 public class DictionaryManagerActivity extends ListActivity {
 
   static final String LOG = "QuickDic";
-  QuickDicConfig quickDicConfig;
-  
   static boolean canAutoLaunch = true;
-  
-  final DictionaryApplication application = (DictionaryApplication) getApplication();
+
+  DictionaryApplication application;
+  Adapter adapter;
   
   public void onCreate(Bundle savedInstanceState) {
-    //((DictionaryApplication)getApplication()).applyTheme(this);
-
     super.onCreate(savedInstanceState);
     Log.d(LOG, "onCreate:" + this);
+    
+    application = (DictionaryApplication) getApplication();
 
     // UI init.
     setContentView(R.layout.list_activity);
@@ -66,6 +70,8 @@ public class DictionaryManagerActivity extends ListActivity {
         onClick(index);
       }
     });
+    
+    getListView().setClickable(true);
 
     // ContextMenu.
     registerForContextMenu(getListView());
@@ -77,7 +83,7 @@ public class DictionaryManagerActivity extends ListActivity {
       final AlertDialog.Builder builder = new AlertDialog.Builder(this);
       builder.setCancelable(false);
       final WebView webView = new WebView(getApplicationContext());
-      webView.loadData(getString(R.string.thanksForUpdating), "text/html", "utf-8");
+      webView.loadData(StringUtil.readToString(getResources().openRawResource(R.raw.whats_new)), "text/html", "utf-8");
       builder.setView(webView);
       builder.setNegativeButton(android.R.string.ok, new DialogInterface.OnClickListener() {
           public void onClick(DialogInterface dialog, int id) {
@@ -101,8 +107,17 @@ public class DictionaryManagerActivity extends ListActivity {
   
   private void onClick(int index) {
     final DictionaryInfo dictionaryInfo = adapter.getItem(index);
-    final Intent intent = DictionaryActivity.getLaunchIntent(dictionaryInfo.uncompressedFilename, 0, "");
-    startActivity(intent);
+    final DictionaryInfo downloadable = application.getDownloadable(dictionaryInfo.uncompressedFilename);
+    if (!application.isDictionaryOnDevice(dictionaryInfo.uncompressedFilename) && downloadable != null) {
+      final Intent intent = DownloadActivity
+          .getLaunchIntent(downloadable.downloadUrl,
+              application.getPath(dictionaryInfo.uncompressedFilename).getPath() + ".zip",
+              dictionaryInfo.dictInfo);
+      startActivity(intent);
+    } else {
+      final Intent intent = DictionaryActivity.getLaunchIntent(application.getPath(dictionaryInfo.uncompressedFilename), 0, "");
+      startActivity(intent);
+    }
   }
   
   @Override
@@ -119,13 +134,13 @@ public class DictionaryManagerActivity extends ListActivity {
     if (canAutoLaunch && prefs.contains(C.DICT_FILE) && prefs.contains(C.INDEX_INDEX)) {
       canAutoLaunch = false;  // Only autolaunch once per-process, on startup.
       Log.d(LOG, "Skipping Dictionary List, going straight to dictionary.");
-      startActivity(DictionaryActivity.getLaunchIntent(prefs.getString(C.DICT_FILE, ""), prefs.getInt(C.INDEX_INDEX, 0), prefs.getString(C.SEARCH_TOKEN, "")));
+      startActivity(DictionaryActivity.getLaunchIntent(new File(prefs.getString(C.DICT_FILE, "")), prefs.getInt(C.INDEX_INDEX, 0), prefs.getString(C.SEARCH_TOKEN, "")));
       // Don't finish, so that user can hit back and get here.
       //finish();
       return;
     }
 
-    setListAdapter(adapter);
+    setListAdapter(adapter = new Adapter());
   }
 
   public boolean onCreateOptionsMenu(final Menu menu) {
@@ -167,7 +182,7 @@ public class DictionaryManagerActivity extends ListActivity {
       moveToTopMenuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
         @Override
         public boolean onMenuItemClick(MenuItem item) {
-          application.moveDictionaryToTop(dictionaryInfo.uncompressedFilename);
+          application.moveDictionaryToTop(dictionaryInfo);
           setListAdapter(adapter = new Adapter());
           return true;
         }
@@ -178,7 +193,7 @@ public class DictionaryManagerActivity extends ListActivity {
     deleteMenuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
       @Override
       public boolean onMenuItemClick(MenuItem item) {
-        application.deleteDictionary(dictionaryInfo.uncompressedFilename);
+        application.deleteDictionary(dictionaryInfo);
         setListAdapter(adapter = new Adapter());
         return true;
       }
@@ -206,24 +221,54 @@ public class DictionaryManagerActivity extends ListActivity {
     }
     
     @Override
-    public View getView(int position, View convertView, ViewGroup parent) {
+    public View getView(final int position, final View convertView, final ViewGroup parent) {
       final DictionaryInfo dictionaryInfo = getItem(position);
-      final TableLayout tableLayout = new TableLayout(parent.getContext());
-      final TextView view = new TextView(parent.getContext());
+      final LinearLayout result = new LinearLayout(parent.getContext());
       
-      String name = application.getDictionaryName(dictionaryInfo.uncompressedFilename);
-      if (!application.isDictionaryOnDevice(dictionaryInfo.uncompressedFilename)) {
-        name = getString(R.string.notOnDevice, name);
+      final boolean updateAvailable = application.updateAvailable(dictionaryInfo);
+      final DictionaryInfo downloadable = application.getDownloadable(dictionaryInfo.uncompressedFilename); 
+      if ((!application.isDictionaryOnDevice(dictionaryInfo.uncompressedFilename) || updateAvailable) && downloadable != null) {
+        final Button downloadButton = new Button(parent.getContext());
+        downloadButton.setText(getString(updateAvailable ? R.string.updateButton : R.string.downloadButton));
+        downloadButton.setOnClickListener(new IntentLauncher(parent.getContext(), DownloadActivity
+            .getLaunchIntent(downloadable.downloadUrl,
+                application.getPath(dictionaryInfo.uncompressedFilename).getPath() + ".zip",
+                dictionaryInfo.dictInfo)) {
+          @Override
+          protected void onGo() {
+            application.invalidateDictionaryInfo(dictionaryInfo.uncompressedFilename);
+          }
+        });
+        WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
+        layoutParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
+        layoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
+        downloadButton.setLayoutParams(layoutParams);
+        result.addView(downloadButton);
       }
 
-      view.setText(name);
-      view.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22);
-      tableLayout.addView(view);
+      final TextView textView = new TextView(parent.getContext());
+      final String name = application.getDictionaryName(dictionaryInfo.uncompressedFilename);
+      textView.setText(name);
+      textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22);
+      result.addView(textView);
+
+      // Because we have a Button inside a ListView row:
+      // http://groups.google.com/group/android-developers/browse_thread/thread/3d96af1530a7d62a?pli=1
+      result.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
+      result.setClickable(true);
+      result.setFocusable(true);
+      result.setLongClickable(true);
+      result.setBackgroundResource(android.R.drawable.menuitem_background);
+      result.setOnClickListener(new TextView.OnClickListener() {
+        @Override
+        public void onClick(View v) {
+          DictionaryManagerActivity.this.onClick(position);
+        }
+      });
 
-      return tableLayout;
+      return result;
     }
   }
-  Adapter adapter = new Adapter();
 
   public static Intent getLaunchIntent() {
     final Intent intent = new Intent();
index 1e7a083e2b1fb3b7a2950457fe9c486f4f16af57..ce41dd1e9d981489a2d33bc902787f44b178550e 100644 (file)
@@ -52,7 +52,7 @@ public class DownloadActivity extends Activity {
 \r
   final AtomicBoolean stop = new AtomicBoolean(false);\r
   \r
-  public static Intent getLaunchIntent(final String dictFile, final String source, final String dest, final String message) {\r
+  public static Intent getLaunchIntent(final String source, final String dest, final String message) {\r
     final Intent intent = new Intent();\r
     intent.setClassName(DownloadActivity.class.getPackage().getName(), DownloadActivity.class.getName());\r
     intent.putExtra(SOURCE, source);\r
@@ -82,6 +82,9 @@ public class DownloadActivity extends Activity {
     final TextView destTextView = (TextView) findViewById(R.id.dest);\r
     destTextView.setText(dest);\r
 \r
+    final TextView messageTextView = (TextView) findViewById(R.id.downloadMessage);\r
+    messageTextView.setText(message);\r
+\r
     final ProgressBar progressBar = (ProgressBar) findViewById(R.id.downloadProgressBar);\r
     progressBar.setIndeterminate(false);\r
     progressBar.setMax(100);\r
@@ -129,6 +132,7 @@ public class DownloadActivity extends Activity {
               final OutputStream zipOut = new FileOutputStream(destUnzipped);\r
               contentLength = zipEntry.getSize();\r
               bytesRead = copyStream(zipIn, zipOut, R.string.unzipping);\r
+              destFile.delete();\r
             }\r
           }\r
           \r
diff --git a/src/com/hughes/android/dictionary/HelpActivity.java b/src/com/hughes/android/dictionary/HelpActivity.java
new file mode 100644 (file)
index 0000000..32067fb
--- /dev/null
@@ -0,0 +1,31 @@
+// Copyright 2011 Google Inc. All Rights Reserved.\r
+//\r
+// Licensed under the Apache License, Version 2.0 (the "License");\r
+// you may not use this file except in compliance with the License.\r
+// You may obtain a copy of the License at\r
+//\r
+//     http://www.apache.org/licenses/LICENSE-2.0\r
+//\r
+// Unless required by applicable law or agreed to in writing, software\r
+// distributed under the License is distributed on an "AS IS" BASIS,\r
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+// See the License for the specific language governing permissions and\r
+// limitations under the License.\r
+\r
+package com.hughes.android.dictionary;\r
+\r
+import android.app.Activity;\r
+import android.os.Bundle;\r
+\r
+public final class HelpActivity extends Activity {\r
+\r
+  /** Called when the activity is first created. */\r
+  @Override\r
+  public void onCreate(final Bundle savedInstanceState) {\r
+    super.onCreate(savedInstanceState);\r
+    setContentView(R.layout.help_activity);\r
+    \r
+    \r
+  }\r
+\r
+}\r
index 245f138a6f5a7c60645d1be2ec0b9dc4049c7bf5..61303efebcffd320bb9af492d367b0c1f14f6e00 100644 (file)
@@ -135,6 +135,8 @@ public class Dictionary implements RAFSerializable<Dictionary> {
         raf = new RandomAccessFile(file, "r");
         final Dictionary dict = new Dictionary(raf);
         final DictionaryInfo dictionaryInfo = dict.getDictionaryInfo();
+        dictionaryInfo.uncompressedFilename = file.getName();
+        dictionaryInfo.uncompressedSize = file.length();
         raf.close();
         return dictionaryInfo;
       } catch (IOException e) {
index 6e03a9ba04d79fff4ab8adc600c5d585b5aff84a..356a4339e31f3f37cf386a3b46d98cf9784c96ad 100644 (file)
@@ -17,17 +17,17 @@ package com.hughes.android.dictionary.engine;
 
 public enum EntryTypeName {
 
-  WIKTIONARY_TITLE_SINGLE(true, null),
-  WIKTIONARY_INFLECTD_FORM_SINGLE(true, null),
+  WIKTIONARY_TITLE_SINGLE(true, true, null),
+  WIKTIONARY_INFLECTD_FORM_SINGLE(false, true, null),
 
 
-  ONE_WORD(true, null),
-  MULTIROW_HEAD_ONE_WORD(true, null),
-  MULTIROW_TAIL_ONE_WORD(true, null),
+  ONE_WORD(true, true, null),
+  MULTIROW_HEAD_ONE_WORD(true, true, null),
+  MULTIROW_TAIL_ONE_WORD(false, true, null),
 
-  WIKTIONARY_TITLE_MULTI(true, WIKTIONARY_TITLE_SINGLE),
+  WIKTIONARY_TITLE_MULTI(false, true, WIKTIONARY_TITLE_SINGLE),
   WIKTIONARY_TRANSLITERATION(),
-  WIKTIONARY_INFLECTED_FORM_MULTI(true, WIKTIONARY_INFLECTD_FORM_SINGLE),
+  WIKTIONARY_INFLECTED_FORM_MULTI(false, true, WIKTIONARY_INFLECTD_FORM_SINGLE),
   WIKTIONARY_ENGLISH_DEF_WIKI_LINK(),
   WIKTIONARY_ENGLISH_DEF_OTHER_LANG(),
   WIKTIONARY_ENGLISH_DEF(),
@@ -39,13 +39,13 @@ public enum EntryTypeName {
   WIKTIONARY_TRANSLATION_WIKI_TEXT(),
   WIKTIONARY_TRANSLATION_OTHER_TEXT(),
 
-  WIKTIONARY_IS_FORM_OF_SOMETHING_ELSE(true, null),
+  WIKTIONARY_IS_FORM_OF_SOMETHING_ELSE(false, true, null),
 
   MULTIROW_HEAD_MANY_WORDS(),
   MULTIROW_TAIL_MANY_WORDS(),
   WIKTIONARY_EXAMPLE(),
   WIKTIONARY_BASE_FORM_SINGLE(),  // These two should be eligible for removal if the links are otherwise present.
-  WIKTIONARY_BASE_FORM_MULTI(false, WIKTIONARY_BASE_FORM_SINGLE),
+  WIKTIONARY_BASE_FORM_MULTI(false, false, WIKTIONARY_BASE_FORM_SINGLE),
   PART_OF_HYPHENATED(),
   BRACKETED(),
   PARENTHESIZED(),
@@ -53,14 +53,16 @@ public enum EntryTypeName {
   SEE_ALSO(), 
   ;
 
+  final boolean mainWord;
   final boolean overridesStopList;
   final EntryTypeName singleWordInstance;
   
   private EntryTypeName() {
-    this(false, null);
+    this(false, false, null);
   }
 
-  private EntryTypeName(final boolean overridesStopList, final EntryTypeName singleWordInstance) {
+  private EntryTypeName(final boolean mainWord, final boolean overridesStopList, final EntryTypeName singleWordInstance) {
+    this.mainWord = mainWord;
     this.overridesStopList = overridesStopList;
     this.singleWordInstance = singleWordInstance == null ? this : singleWordInstance;
   }
index 90bc3b947ab57197fa4aadb23f59aeeb49f97cbe..74130c1d5964e1f35b4ce361f48227e9541ae854 100644 (file)
@@ -80,6 +80,7 @@ public class Language {
     isoCodeToResourceId.put("ES", R.string.ES);\r
     isoCodeToResourceId.put("SW", R.string.SW);\r
     isoCodeToResourceId.put("SV", R.string.SV);\r
+    isoCodeToResourceId.put("TL", R.string.TL);\r
     isoCodeToResourceId.put("TG", R.string.TG);\r
     isoCodeToResourceId.put("TH", R.string.TH);\r
     isoCodeToResourceId.put("BO", R.string.BO);\r
@@ -91,10 +92,12 @@ public class Language {
     isoCodeToResourceId.put("YI", R.string.YI);\r
     isoCodeToResourceId.put("ZU", R.string.ZU);\r
     \r
+    \r
     // Hack to allow lower-case ISO codes to work:\r
     for (final String isoCode : new ArrayList<String>(isoCodeToResourceId.keySet())) {\r
       isoCodeToResourceId.put(isoCode.toLowerCase(), isoCodeToResourceId.get(isoCode));\r
     }\r
+\r
   }\r
 \r
 \r
index 46e66a44cac4004d779b4c3fbcb053173fc01f11..03cc102ef7b858a377217a2be2432eb7ee61071d 100644 (file)
@@ -1,23 +1,32 @@
 package com.hughes.android.util;
 
-import android.app.Activity;
+import android.content.Context;
 import android.content.Intent;
+import android.view.View;
+import android.view.View.OnClickListener;
 
-public class IntentLauncher {
+public class IntentLauncher implements OnClickListener {
   
+  final Context context;
   final Intent intent;
-  final Activity activity;
   
-  private IntentLauncher(final Intent intent, final Activity activity) {
+  public IntentLauncher(final Context context, final Intent intent) {
+    this.context = context;
     this.intent = intent;
-    this.activity = activity;
   }
-  
+
+  protected void onGo() {
+  }
+
+
   private void go() {
-    if (activity != null) {
-      activity.finish();
-    }
-    activity.startActivity(intent);
+    onGo();
+    context.startActivity(intent);
+  }
+
+  @Override
+  public void onClick(View v) {
+    go();
   }
   
   
diff --git a/todo.txt b/todo.txt
deleted file mode 100644 (file)
index 02d4b7b..0000000
--- a/todo.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-* multi word search
-* link to leo, dict.cc
-* source in context menu
-* quiz
-* colorize things
-
-
-done:
-* sorting of entries
-* better Row/Entry classes?
-* wiktionary
-* better tokenization?
-* publish 2.0 dictionary
-* test email
-* dict manager