]> gitweb.fperrin.net Git - Dictionary.git/commitdiff
UI fixes, launch with intent not prefs,
authorThad Hughes <thad.hughes@gmail.com>
Thu, 19 Jan 2012 01:14:08 +0000 (17:14 -0800)
committerThad Hughes <thad.hughes@gmail.com>
Thu, 19 Jan 2012 01:14:08 +0000 (17:14 -0800)
res/xml/preferences.xml
src/com/hughes/android/dictionary/C.java
src/com/hughes/android/dictionary/DictionaryActivity.java
src/com/hughes/android/dictionary/DictionaryEditActivity.java
src/com/hughes/android/dictionary/DictionaryInfo.java
src/com/hughes/android/dictionary/DictionaryManagerActivity.java
src/com/hughes/android/dictionary/MyClickableSpan.java [deleted file]
src/com/hughes/android/dictionary/NonLinkClickableSpan.java [new file with mode: 0644]
src/com/hughes/android/dictionary/QuickDicConfig.java

index ecd445e83613df50218834b5768046e9d060618d..30a60660584b11041af55eb0c4b294c35e547080 100644 (file)
@@ -12,7 +12,7 @@
     android:key="@string/fontSizeKey"\r
     android:title="@string/fontSizeTitle" \r
     android:summary="@string/fontSizeSummary"\r
-    android:defaultValue="12"\r
+    android:defaultValue="14"\r
     android:persistent="true"\r
   />\r
 \r
index acb10ee4f346dd7a0d73bb83bb5f39158e540ef2..fc28a15dab4f8e44defd9fbbcf89d2e45c2db2fe 100644 (file)
@@ -18,9 +18,10 @@ public class C {
 
   static final String DICTIONARY_CONFIGS = "dictionaryConfigs";
 
-  static final String DICT_INDEX = "dictIndex";
+  static final String DICT_FILE = "dictFile";
   static final String INDEX_INDEX = "indexIndex";
   static final String SEARCH_TOKEN = "searchToken";
+  static final String CAN_AUTO_LAUNCH_DICT = "canAutoLaunch";
 
   public static final String THANKS_FOR_UPDATING_VERSION = "thanksForUpdatingVersion";
 
index cb814f772272ad88c9e2bed400c837e7ce1b6380..d6ec791fc9a214e9c85caa608d26147dce285e2a 100644 (file)
@@ -123,55 +123,39 @@ public class DictionaryActivity extends ListActivity {
   public DictionaryActivity() {\r
   }\r
   \r
-  public static Intent getIntent(final Context context, final int dictIndex, final int indexIndex, final String searchToken) {\r
-    setDictionaryPrefs(context, dictIndex, indexIndex, searchToken);\r
+  public static Intent getLaunchIntent(final String 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.INDEX_INDEX, indexIndex);\r
+    intent.putExtra(C.SEARCH_TOKEN, searchToken);\r
     return intent;\r
   }\r
   \r
-  // TODO: Can we trigger an App restart when the preferences activity gets opened?\r
   // TODO: fix these...\r
 \r
   @Override\r
   protected void onSaveInstanceState(final Bundle outState) {\r
     super.onSaveInstanceState(outState);\r
-    setDictionaryPrefs(this, dictIndex, indexIndex, searchText.getText().toString());\r
-  }\r
-\r
-  public static void setDictionaryPrefs(final Context context,\r
-      final int dictIndex, final int indexIndex, final String searchToken) {\r
-    final SharedPreferences.Editor prefs = PreferenceManager.getDefaultSharedPreferences(context).edit();\r
-    prefs.putInt(C.DICT_INDEX, dictIndex);\r
-    prefs.putInt(C.INDEX_INDEX, indexIndex);\r
-    prefs.putString(C.SEARCH_TOKEN, searchToken);\r
-    prefs.commit();\r
+    outState.putString(C.SEARCH_TOKEN, searchText.getText().toString());\r
   }\r
   \r
-  public static void clearDictionaryPrefs(final Context context) {\r
-    final SharedPreferences.Editor prefs = PreferenceManager\r
-        .getDefaultSharedPreferences(context).edit();\r
-    prefs.remove(C.DICT_INDEX);\r
-    prefs.remove(C.INDEX_INDEX);\r
-    prefs.remove(C.SEARCH_TOKEN);\r
-    prefs.commit();\r
-    Log.d(LOG, "Removed default dictionary prefs.");\r
-  }\r
-\r
   @Override\r
   public void onCreate(Bundle savedInstanceState) {\r
+    clearDictionaryPrefs(this);\r
+    \r
     Log.d(LOG, "onCreate:" + this);\r
     theme = ((DictionaryApplication)getApplication()).getSelectedTheme();\r
     super.onCreate(savedInstanceState);\r
     \r
-    final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);\r
-    \r
+    final Intent intent = getIntent();\r
+    dictFile = intent.getStringExtra(C.DICT_FILE);\r
+\r
     try {\r
       PersistentObjectCache.init(this);\r
       QuickDicConfig quickDicConfig = PersistentObjectCache.init(\r
           this).read(C.DICTIONARY_CONFIGS, QuickDicConfig.class);\r
-      dictIndex = prefs.getInt(C.DICT_INDEX, 0) ;\r
-      final DictionaryInfo dictionaryConfig = quickDicConfig.dictionaryInfos.get(dictIndex);\r
+      final DictionaryInfo dictionaryConfig = quickDicConfig.getDictionaryInfoByFile(dictFile);\r
       this.setTitle("QuickDic: " + dictionaryConfig.name);\r
       dictRaf = new RandomAccessFile(dictionaryConfig.localFile, "r");\r
       dictionary = new Dictionary(dictRaf); \r
@@ -186,16 +170,16 @@ public class DictionaryActivity extends ListActivity {
         dictRaf = null;\r
       }\r
       Toast.makeText(this, getString(R.string.invalidDictionary, "", e.getMessage()), Toast.LENGTH_LONG);\r
-      startActivity(DictionaryManagerActivity.getIntent(this));\r
+      startActivity(DictionaryEditActivity.getLaunchIntent(dictFile));\r
       finish();\r
       return;\r
     }\r
 \r
-    indexIndex = prefs.getInt(C.INDEX_INDEX, 0) % dictionary.indices.size();\r
     Log.d(LOG, "Loading index.");\r
+    indexIndex = intent.getIntExtra(C.INDEX_INDEX, 0) % dictionary.indices.size();\r
     index = dictionary.indices.get(indexIndex);\r
     setListAdapter(new IndexAdapter(index));\r
-\r
+    \r
     // Pre-load the collators.\r
     searchExecutor.execute(new Runnable() {\r
       public void run() {\r
@@ -227,9 +211,11 @@ public class DictionaryActivity extends ListActivity {
       }\r
     });\r
     \r
-    final String fontSize = prefs.getString(getString(R.string.fontSizeKey), "12");\r
+    final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);\r
+    \r
+    final String fontSize = prefs.getString(getString(R.string.fontSizeKey), "14");\r
     try {\r
-      fontSizeSp = Integer.parseInt(fontSize);\r
+      fontSizeSp = Integer.parseInt(fontSize.trim());\r
     } catch (NumberFormatException e) {\r
       fontSizeSp = 12;\r
     }\r
@@ -315,6 +301,8 @@ public class DictionaryActivity extends ListActivity {
       // vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);\r
     //}\r
     Log.d(LOG, "wordList=" + wordList + ", saveOnlyFirstSubentry=" + saveOnlyFirstSubentry);\r
+    \r
+    setDictionaryPrefs(this, dictFile, indexIndex, searchText.getText().toString());\r
   }\r
   \r
   @Override\r
@@ -331,6 +319,24 @@ public class DictionaryActivity extends ListActivity {
   protected void onPause() {\r
     super.onPause();\r
   }\r
+  \r
+  private static void setDictionaryPrefs(final Context context,\r
+      final String 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.putInt(C.INDEX_INDEX, indexIndex);\r
+    prefs.putString(C.SEARCH_TOKEN, searchToken);\r
+    prefs.commit();\r
+  }\r
+\r
+  private static void clearDictionaryPrefs(final Context context) {\r
+    final SharedPreferences.Editor prefs = PreferenceManager.getDefaultSharedPreferences(context).edit();\r
+    prefs.remove(C.DICT_FILE);\r
+    prefs.remove(C.INDEX_INDEX);\r
+    prefs.remove(C.SEARCH_TOKEN);\r
+    prefs.commit();\r
+  }\r
+\r
 \r
   @Override\r
   protected void onDestroy() {\r
@@ -338,7 +344,6 @@ public class DictionaryActivity extends ListActivity {
     if (dictRaf == null) {\r
       return;\r
     }\r
-    setDictionaryPrefs(this, dictIndex, indexIndex, searchText.getText().toString());\r
     \r
     // Before we close the RAF, we have to wind the current search down.\r
     if (currentSearchOperation != null) {\r
@@ -388,21 +393,19 @@ public class DictionaryActivity extends ListActivity {
       currentSearchOperation.interrupted.set(true);\r
       currentSearchOperation = null;\r
     }\r
-    \r
     changeIndex((indexIndex + 1)% dictionary.indices.size());\r
-    onSearchTextChange(searchText.getText().toString());\r
   }\r
   \r
   static class OpenIndexButton extends Button implements OnClickListener {\r
 \r
     final Activity activity;\r
-    final int dictionaryIndex;\r
+    final String dictFile;\r
     final int indexIndex;\r
 \r
-    public OpenIndexButton(final Context context, final Activity activity, final String text, final int dictionaryIndex, final int indexIndex) {\r
+    public OpenIndexButton(final Context context, final Activity activity, final String text, final String dictFile, final int indexIndex) {\r
       super(context);\r
       this.activity = activity;\r
-      this.dictionaryIndex = dictionaryIndex;\r
+      this.dictFile = dictFile;\r
       this.indexIndex = indexIndex;\r
       setOnClickListener(this);\r
       setText(text, BufferType.NORMAL);\r
@@ -411,7 +414,7 @@ public class DictionaryActivity extends ListActivity {
     @Override\r
     public void onClick(View v) {\r
       activity.finish();\r
-      getContext().startActivity(DictionaryActivity.getIntent(getContext(), dictionaryIndex, indexIndex, ""));\r
+      getContext().startActivity(DictionaryActivity.getLaunchIntent(dictFile, indexIndex, ""));\r
     }\r
     \r
   }\r
@@ -438,7 +441,8 @@ public class DictionaryActivity extends ListActivity {
       @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
+        //result.addView(new Butt)\r
+        return result;\r
       }\r
       \r
       @Override\r
@@ -466,6 +470,8 @@ public class DictionaryActivity extends ListActivity {
     Log.d(LOG, "changingIndex, newLang=" + index.longName);\r
     setListAdapter(indexAdapter);\r
     updateLangButton();\r
+    searchText.requestFocus();  // Otherwise, nothing may happen.\r
+    onSearchTextChange(searchText.getText().toString());\r
   }\r
   \r
   void onUpDownButton(final boolean up) {\r
@@ -514,7 +520,7 @@ public class DictionaryActivity extends ListActivity {
       final MenuItem dictionaryList = menu.add(getString(R.string.dictionaryManager));\r
       dictionaryList.setOnMenuItemClickListener(new OnMenuItemClickListener() {\r
         public boolean onMenuItemClick(final MenuItem menuItem) {\r
-          startActivity(DictionaryManagerActivity.getIntent(DictionaryActivity.this));\r
+          startActivity(DictionaryManagerActivity.getLaunchIntent());\r
           finish();\r
           return false;\r
         }\r
@@ -571,7 +577,7 @@ public class DictionaryActivity extends ListActivity {
           if (indexIndex != selectedSpannableIndex) {\r
             changeIndex(selectedSpannableIndex);\r
           }\r
-          searchText.setText(selectedText);\r
+          setSearchText(selectedText);\r
           return false;\r
         }\r
       });\r
@@ -642,10 +648,7 @@ public class DictionaryActivity extends ListActivity {
   public boolean onKeyDown(final int keyCode, final KeyEvent event) {\r
     if (event.getUnicodeChar() != 0) {\r
       if (!searchText.hasFocus()) {\r
-        searchText.setText("" + (char) event.getUnicodeChar());\r
-        onSearchTextChange(searchText.getText().toString());\r
-        searchText.requestFocus();\r
-        Selection.moveToRightEdge(searchText.getText(), searchText.getLayout());\r
+        setSearchText("" + (char) event.getUnicodeChar());\r
       }\r
       return true;\r
     }\r
@@ -662,6 +665,13 @@ public class DictionaryActivity extends ListActivity {
     return super.onKeyDown(keyCode, event);\r
   }\r
 \r
+  private void setSearchText(final String text) {\r
+    searchText.setText(text);\r
+    searchText.requestFocus();\r
+    onSearchTextChange(searchText.getText().toString());\r
+    Selection.moveToRightEdge(searchText.getText(), searchText.getLayout());\r
+  }\r
+\r
 \r
   // --------------------------------------------------------------------------\r
   // SearchOperation\r
@@ -939,7 +949,7 @@ public class DictionaryActivity extends ListActivity {
     textView.setMovementMethod(LinkMovementMethod.getInstance());\r
     final Matcher matcher = CHAR_DASH.matcher(text);\r
     while (matcher.find()) {\r
-      spannable.setSpan(new MyClickableSpan(), matcher.start(), matcher.end(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE);\r
+      spannable.setSpan(new NonLinkClickableSpan(), matcher.start(), matcher.end(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE);\r
     }\r
   }\r
   \r
index 8ad0e258a713026b97126d5ab2eef6b81f64dd47..499feb2465af5a70d15eab0cd9beac5d4360053e 100644 (file)
@@ -45,15 +45,15 @@ public class DictionaryEditActivity extends Activity {
   static final String LOG = "QuickDic";
 
   QuickDicConfig quickDicConfig;
-  private DictionaryInfo dictionaryConfig;
+  private DictionaryInfo dictionaryInfo;
   
   final Handler uiHandler = new Handler();
 
-  public static Intent getIntent(final int dictIndex) {
+  public static Intent getLaunchIntent(final String dictFile) {
     final Intent intent = new Intent();
     intent.setClassName(DictionaryEditActivity.class.getPackage().getName(),
         DictionaryEditActivity.class.getName());
-    intent.putExtra(C.DICT_INDEX, dictIndex);
+    intent.putExtra(C.DICT_FILE, dictFile);
     return intent;
   }
 
@@ -66,26 +66,26 @@ public class DictionaryEditActivity extends Activity {
     setContentView(R.layout.edit_activity);
 
     final Intent intent = getIntent();
-
-    final int dictIndex = intent.getIntExtra(C.DICT_INDEX, 0);
+    final String dictFile = intent.getStringExtra(C.DICT_FILE);
       
     PersistentObjectCache.init(this);
     try {
       quickDicConfig = PersistentObjectCache.init(this).read(
           C.DICTIONARY_CONFIGS, QuickDicConfig.class);
-      dictionaryConfig = quickDicConfig.dictionaryInfos.get(dictIndex);
+      dictionaryInfo = quickDicConfig.getDictionaryInfoByFile(dictFile);
     } catch (Exception e) {
       Log.e(LOG, "Failed to read QuickDicConfig.", e);
-      quickDicConfig = new QuickDicConfig(this);
-      dictionaryConfig = quickDicConfig.dictionaryInfos.get(0);
+      finish();
+      startActivity(DictionaryManagerActivity.getLaunchIntent());
+      return;
     }
     
     // Write stuff from object into fields.
 
     ((EditText) findViewById(R.id.dictionaryName))
-        .setText(dictionaryConfig.name);
+        .setText(dictionaryInfo.name);
     ((EditText) findViewById(R.id.localFile))
-        .setText(dictionaryConfig.localFile);
+        .setText(dictionaryInfo.localFile);
 
     final TextWatcher textWatcher = new TextWatcher() {
       @Override
@@ -107,7 +107,7 @@ public class DictionaryEditActivity extends Activity {
     ((EditText) findViewById(R.id.localFile)).addTextChangedListener(textWatcher);
 
     final EditText downloadUrl = (EditText) findViewById(R.id.downloadUrl);
-    downloadUrl.setText(dictionaryConfig.downloadUrl);
+    downloadUrl.setText(dictionaryInfo.downloadUrl);
     downloadUrl.addTextChangedListener(textWatcher);
     
     final Button downloadButton = (Button) findViewById(R.id.downloadButton);
@@ -115,7 +115,7 @@ public class DictionaryEditActivity extends Activity {
       @Override
       public void onClick(View v) {
         startDownloadDictActivity(DictionaryEditActivity.this,
-            dictionaryConfig);
+            dictionaryInfo);
       }
     });
 
@@ -123,7 +123,7 @@ public class DictionaryEditActivity extends Activity {
     openButton.setOnClickListener(new OnClickListener() {
       @Override
       public void onClick(View v) {
-        final Intent intent = DictionaryActivity.getIntent(DictionaryEditActivity.this, dictIndex, 0, "");
+        final Intent intent = DictionaryActivity.getLaunchIntent(dictFile, 0, "");
         startActivity(intent);
       }
     });
@@ -148,11 +148,11 @@ public class DictionaryEditActivity extends Activity {
     super.onPause();
 
     // Read stuff from fields into object.
-    dictionaryConfig.name = ((EditText) findViewById(R.id.dictionaryName))
+    dictionaryInfo.name = ((EditText) findViewById(R.id.dictionaryName))
         .getText().toString();
-    dictionaryConfig.localFile = ((EditText) findViewById(R.id.localFile))
+    dictionaryInfo.localFile = ((EditText) findViewById(R.id.localFile))
         .getText().toString();
-    dictionaryConfig.downloadUrl = ((EditText) findViewById(R.id.downloadUrl))
+    dictionaryInfo.downloadUrl = ((EditText) findViewById(R.id.downloadUrl))
         .getText().toString();
 
     PersistentObjectCache.getInstance().write(C.DICTIONARY_CONFIGS,
@@ -165,7 +165,7 @@ public class DictionaryEditActivity extends Activity {
     newDictionaryMenuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
           public boolean onMenuItemClick(final MenuItem menuItem) {
             startDownloadDictActivity(DictionaryEditActivity.this,
-                dictionaryConfig);
+                dictionaryInfo);
             return false;
           }
         });
@@ -173,7 +173,7 @@ public class DictionaryEditActivity extends Activity {
     final MenuItem dictionaryList = menu.add(getString(R.string.dictionaryManager));
     dictionaryList.setOnMenuItemClickListener(new OnMenuItemClickListener() {
       public boolean onMenuItemClick(final MenuItem menuItem) {
-        startActivity(DictionaryManagerActivity.getIntent(DictionaryEditActivity.this));
+        startActivity(DictionaryManagerActivity.getLaunchIntent());
         return false;
       }
     });
index 26c818a70cd4c4c2412b7a906ed041cf49bec016..6759e32e4809b043498da3bf28b14db4d041642d 100644 (file)
@@ -22,7 +22,9 @@ public class DictionaryInfo implements Serializable {
   
   private static final long serialVersionUID = -6850863377577700388L;
   
-  public static final class IndexInfo {
+  public static final class IndexInfo implements Serializable {
+    private static final long serialVersionUID = 6524751236198309438L;
+
     public IndexInfo(String langIso, int allTokenCount, int mainTokenCount) {
       this.langIso = langIso;
       this.allTokenCount = allTokenCount;
index 90578038775171ce21aebb7be70a93efd2d51dc3..bd41943ef12d086018b37e3ecba0095226290633 100644 (file)
@@ -18,7 +18,6 @@ import java.io.File;
 
 import android.app.AlertDialog;
 import android.app.ListActivity;
-import android.content.Context;
 import android.content.DialogInterface;
 import android.content.Intent;
 import android.content.SharedPreferences;
@@ -27,29 +26,30 @@ import android.preference.PreferenceManager;
 import android.util.Log;
 import android.util.TypedValue;
 import android.view.ContextMenu;
+import android.view.ContextMenu.ContextMenuInfo;
 import android.view.Menu;
 import android.view.MenuItem;
+import android.view.MenuItem.OnMenuItemClickListener;
 import android.view.View;
 import android.view.ViewGroup;
-import android.view.ContextMenu.ContextMenuInfo;
-import android.view.MenuItem.OnMenuItemClickListener;
 import android.view.WindowManager;
 import android.webkit.WebView;
 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.TextView;
-import android.widget.AdapterView.AdapterContextMenuInfo;
-import android.widget.AdapterView.OnItemClickListener;
 
 import com.hughes.android.util.PersistentObjectCache;
 
 public class DictionaryManagerActivity extends ListActivity {
 
   static final String LOG = "QuickDic";
-  
   QuickDicConfig quickDicConfig;
   
+  static boolean canAutoLaunch = true;
+  
   
   public void onCreate(Bundle savedInstanceState) {
     //((DictionaryApplication)getApplication()).applyTheme(this);
@@ -74,6 +74,7 @@ public class DictionaryManagerActivity extends ListActivity {
     final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
     final String thanksForUpdatingLatestVersion = getString(R.string.thanksForUpdatingVersion);
     if (!prefs.getString(C.THANKS_FOR_UPDATING_VERSION, "").equals(thanksForUpdatingLatestVersion)) {
+      canAutoLaunch = false;
       final AlertDialog.Builder builder = new AlertDialog.Builder(this);
       builder.setCancelable(false);
       final WebView webView = new WebView(getApplicationContext());
@@ -93,10 +94,15 @@ public class DictionaryManagerActivity extends ListActivity {
       alert.getWindow().setAttributes(layoutParams);
       prefs.edit().putString(C.THANKS_FOR_UPDATING_VERSION, thanksForUpdatingLatestVersion).commit();
     }
+    
+    if (!getIntent().getBooleanExtra(C.CAN_AUTO_LAUNCH_DICT, true)) {
+      canAutoLaunch = false;
+    }
   }
   
   private void onClick(int dictIndex) {
-    final Intent intent = DictionaryActivity.getIntent(this, dictIndex, 0, "");
+    final DictionaryInfo dictionaryInfo = quickDicConfig.dictionaryInfos.get(dictIndex);
+    final Intent intent = DictionaryActivity.getLaunchIntent(dictionaryInfo.localFile, 0, "");
     startActivity(intent);
   }
   
@@ -111,9 +117,11 @@ public class DictionaryManagerActivity extends ListActivity {
     }
     
     final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
-    if (prefs.contains(C.DICT_INDEX) && prefs.contains(C.INDEX_INDEX)) {
+    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.getIntent(this, prefs.getInt(C.DICT_INDEX, 0), prefs.getInt(C.INDEX_INDEX, 0), prefs.getString(C.SEARCH_TOKEN, "")));
+      startActivity(DictionaryActivity.getLaunchIntent(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;
     }
@@ -229,11 +237,11 @@ public class DictionaryManagerActivity extends ListActivity {
     
   }
 
-  public static Intent getIntent(final Context context) {
-    DictionaryActivity.clearDictionaryPrefs(context);
+  public static Intent getLaunchIntent() {
     final Intent intent = new Intent();
     intent.setClassName(DictionaryManagerActivity.class.getPackage().getName(),
         DictionaryManagerActivity.class.getName());
+    intent.putExtra(C.CAN_AUTO_LAUNCH_DICT, false);
     return intent;
   }
 
diff --git a/src/com/hughes/android/dictionary/MyClickableSpan.java b/src/com/hughes/android/dictionary/MyClickableSpan.java
deleted file mode 100644 (file)
index e3b6e64..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.hughes.android.dictionary;
-
-import android.text.TextPaint;
-import android.text.style.ClickableSpan;
-import android.view.View;
-
-public class MyClickableSpan extends ClickableSpan {
-  
-  static MyClickableSpan instance = new MyClickableSpan();
-
-  // Won't see these on a long-click.
-  @Override
-  public void onClick(View widget) {
-  }
-
-  @Override
-  public void updateDrawState(TextPaint ds) {
-    super.updateDrawState(ds);
-    ds.setUnderlineText(false);
-    //ds.setColor(color);
-  }
-
-}
diff --git a/src/com/hughes/android/dictionary/NonLinkClickableSpan.java b/src/com/hughes/android/dictionary/NonLinkClickableSpan.java
new file mode 100644 (file)
index 0000000..75e38fc
--- /dev/null
@@ -0,0 +1,37 @@
+// Copyright 2012 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.hughes.android.dictionary;
+
+import android.text.TextPaint;
+import android.text.style.ClickableSpan;
+import android.view.View;
+
+public class NonLinkClickableSpan extends ClickableSpan {
+  
+  static NonLinkClickableSpan instance = new NonLinkClickableSpan();
+
+  // Won't see these on a long-click.
+  @Override
+  public void onClick(View widget) {
+  }
+
+  @Override
+  public void updateDrawState(TextPaint ds) {
+    super.updateDrawState(ds);
+    ds.setUnderlineText(false);
+    //ds.setColor(color);
+  }
+
+}
index 4574107f57a8ca3f3778365257e3c1c745f5c58b..4cdcbd38ae2f9ddbc7c43cbea4f9df08a5e0a5a2 100644 (file)
@@ -90,5 +90,14 @@ public final class QuickDicConfig implements Serializable {
     }
     dictionaryInfos.add(dictionaryConfig);
   }
+  
+  DictionaryInfo getDictionaryInfoByFile(final String dictFile) throws Exception {
+    for (int i = 0; i < dictionaryInfos.size(); ++i) {
+      if (dictionaryInfos.get(i).localFile.equals(dictFile)) {
+        return dictionaryInfos.get(i);
+      }
+    }
+    throw new Exception("Not found: " + dictFile);
+  }
 
 }