From: Thad Hughes Date: Thu, 19 Jan 2012 01:14:08 +0000 (-0800) Subject: UI fixes, launch with intent not prefs, X-Git-Url: http://gitweb.fperrin.net/?p=Dictionary.git;a=commitdiff_plain;h=c56b5d8ce1721eabc8283558acce1d00b6b358e2 UI fixes, launch with intent not prefs, --- diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml index ecd445e..30a6066 100644 --- a/res/xml/preferences.xml +++ b/res/xml/preferences.xml @@ -12,7 +12,7 @@ android:key="@string/fontSizeKey" android:title="@string/fontSizeTitle" android:summary="@string/fontSizeSummary" - android:defaultValue="12" + android:defaultValue="14" android:persistent="true" /> diff --git a/src/com/hughes/android/dictionary/C.java b/src/com/hughes/android/dictionary/C.java index acb10ee..fc28a15 100644 --- a/src/com/hughes/android/dictionary/C.java +++ b/src/com/hughes/android/dictionary/C.java @@ -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"; diff --git a/src/com/hughes/android/dictionary/DictionaryActivity.java b/src/com/hughes/android/dictionary/DictionaryActivity.java index cb814f7..d6ec791 100644 --- a/src/com/hughes/android/dictionary/DictionaryActivity.java +++ b/src/com/hughes/android/dictionary/DictionaryActivity.java @@ -123,55 +123,39 @@ public class DictionaryActivity extends ListActivity { public DictionaryActivity() { } - public static Intent getIntent(final Context context, final int dictIndex, final int indexIndex, final String searchToken) { - setDictionaryPrefs(context, dictIndex, indexIndex, searchToken); + public static Intent getLaunchIntent(final String dictFile, final int indexIndex, final String searchToken) { final Intent intent = new Intent(); intent.setClassName(DictionaryActivity.class.getPackage().getName(), DictionaryActivity.class.getName()); + intent.putExtra(C.DICT_FILE, dictFile); + intent.putExtra(C.INDEX_INDEX, indexIndex); + intent.putExtra(C.SEARCH_TOKEN, searchToken); return intent; } - // TODO: Can we trigger an App restart when the preferences activity gets opened? // TODO: fix these... @Override protected void onSaveInstanceState(final Bundle outState) { super.onSaveInstanceState(outState); - setDictionaryPrefs(this, dictIndex, indexIndex, searchText.getText().toString()); - } - - public static void setDictionaryPrefs(final Context context, - final int dictIndex, final int indexIndex, final String searchToken) { - final SharedPreferences.Editor prefs = PreferenceManager.getDefaultSharedPreferences(context).edit(); - prefs.putInt(C.DICT_INDEX, dictIndex); - prefs.putInt(C.INDEX_INDEX, indexIndex); - prefs.putString(C.SEARCH_TOKEN, searchToken); - prefs.commit(); + outState.putString(C.SEARCH_TOKEN, searchText.getText().toString()); } - public static void clearDictionaryPrefs(final Context context) { - final SharedPreferences.Editor prefs = PreferenceManager - .getDefaultSharedPreferences(context).edit(); - prefs.remove(C.DICT_INDEX); - prefs.remove(C.INDEX_INDEX); - prefs.remove(C.SEARCH_TOKEN); - prefs.commit(); - Log.d(LOG, "Removed default dictionary prefs."); - } - @Override public void onCreate(Bundle savedInstanceState) { + clearDictionaryPrefs(this); + Log.d(LOG, "onCreate:" + this); theme = ((DictionaryApplication)getApplication()).getSelectedTheme(); super.onCreate(savedInstanceState); - final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); - + final Intent intent = getIntent(); + dictFile = intent.getStringExtra(C.DICT_FILE); + try { PersistentObjectCache.init(this); QuickDicConfig quickDicConfig = PersistentObjectCache.init( this).read(C.DICTIONARY_CONFIGS, QuickDicConfig.class); - dictIndex = prefs.getInt(C.DICT_INDEX, 0) ; - final DictionaryInfo dictionaryConfig = quickDicConfig.dictionaryInfos.get(dictIndex); + final DictionaryInfo dictionaryConfig = quickDicConfig.getDictionaryInfoByFile(dictFile); this.setTitle("QuickDic: " + dictionaryConfig.name); dictRaf = new RandomAccessFile(dictionaryConfig.localFile, "r"); dictionary = new Dictionary(dictRaf); @@ -186,16 +170,16 @@ public class DictionaryActivity extends ListActivity { dictRaf = null; } Toast.makeText(this, getString(R.string.invalidDictionary, "", e.getMessage()), Toast.LENGTH_LONG); - startActivity(DictionaryManagerActivity.getIntent(this)); + startActivity(DictionaryEditActivity.getLaunchIntent(dictFile)); finish(); return; } - indexIndex = prefs.getInt(C.INDEX_INDEX, 0) % dictionary.indices.size(); Log.d(LOG, "Loading index."); + indexIndex = intent.getIntExtra(C.INDEX_INDEX, 0) % dictionary.indices.size(); index = dictionary.indices.get(indexIndex); setListAdapter(new IndexAdapter(index)); - + // Pre-load the collators. searchExecutor.execute(new Runnable() { public void run() { @@ -227,9 +211,11 @@ public class DictionaryActivity extends ListActivity { } }); - final String fontSize = prefs.getString(getString(R.string.fontSizeKey), "12"); + final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); + + final String fontSize = prefs.getString(getString(R.string.fontSizeKey), "14"); try { - fontSizeSp = Integer.parseInt(fontSize); + fontSizeSp = Integer.parseInt(fontSize.trim()); } catch (NumberFormatException e) { fontSizeSp = 12; } @@ -315,6 +301,8 @@ public class DictionaryActivity extends ListActivity { // vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); //} Log.d(LOG, "wordList=" + wordList + ", saveOnlyFirstSubentry=" + saveOnlyFirstSubentry); + + setDictionaryPrefs(this, dictFile, indexIndex, searchText.getText().toString()); } @Override @@ -331,6 +319,24 @@ public class DictionaryActivity extends ListActivity { protected void onPause() { super.onPause(); } + + private static void setDictionaryPrefs(final Context context, + final String dictFile, final int indexIndex, final String searchToken) { + final SharedPreferences.Editor prefs = PreferenceManager.getDefaultSharedPreferences(context).edit(); + prefs.putString(C.DICT_FILE, dictFile); + prefs.putInt(C.INDEX_INDEX, indexIndex); + prefs.putString(C.SEARCH_TOKEN, searchToken); + prefs.commit(); + } + + private static void clearDictionaryPrefs(final Context context) { + final SharedPreferences.Editor prefs = PreferenceManager.getDefaultSharedPreferences(context).edit(); + prefs.remove(C.DICT_FILE); + prefs.remove(C.INDEX_INDEX); + prefs.remove(C.SEARCH_TOKEN); + prefs.commit(); + } + @Override protected void onDestroy() { @@ -338,7 +344,6 @@ public class DictionaryActivity extends ListActivity { if (dictRaf == null) { return; } - setDictionaryPrefs(this, dictIndex, indexIndex, searchText.getText().toString()); // Before we close the RAF, we have to wind the current search down. if (currentSearchOperation != null) { @@ -388,21 +393,19 @@ public class DictionaryActivity extends ListActivity { currentSearchOperation.interrupted.set(true); currentSearchOperation = null; } - changeIndex((indexIndex + 1)% dictionary.indices.size()); - onSearchTextChange(searchText.getText().toString()); } static class OpenIndexButton extends Button implements OnClickListener { final Activity activity; - final int dictionaryIndex; + final String dictFile; final int indexIndex; - public OpenIndexButton(final Context context, final Activity activity, final String text, final int dictionaryIndex, final int indexIndex) { + public OpenIndexButton(final Context context, final Activity activity, final String text, final String dictFile, final int indexIndex) { super(context); this.activity = activity; - this.dictionaryIndex = dictionaryIndex; + this.dictFile = dictFile; this.indexIndex = indexIndex; setOnClickListener(this); setText(text, BufferType.NORMAL); @@ -411,7 +414,7 @@ public class DictionaryActivity extends ListActivity { @Override public void onClick(View v) { activity.finish(); - getContext().startActivity(DictionaryActivity.getIntent(getContext(), dictionaryIndex, indexIndex, "")); + getContext().startActivity(DictionaryActivity.getLaunchIntent(dictFile, indexIndex, "")); } } @@ -438,7 +441,8 @@ public class DictionaryActivity extends ListActivity { @Override public View getView(int position, View convertView, ViewGroup parent) { final LinearLayout result = new LinearLayout(parent.getContext()); - result.addView(new Butt) + //result.addView(new Butt) + return result; } @Override @@ -466,6 +470,8 @@ public class DictionaryActivity extends ListActivity { Log.d(LOG, "changingIndex, newLang=" + index.longName); setListAdapter(indexAdapter); updateLangButton(); + searchText.requestFocus(); // Otherwise, nothing may happen. + onSearchTextChange(searchText.getText().toString()); } void onUpDownButton(final boolean up) { @@ -514,7 +520,7 @@ public class DictionaryActivity extends ListActivity { final MenuItem dictionaryList = menu.add(getString(R.string.dictionaryManager)); dictionaryList.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(final MenuItem menuItem) { - startActivity(DictionaryManagerActivity.getIntent(DictionaryActivity.this)); + startActivity(DictionaryManagerActivity.getLaunchIntent()); finish(); return false; } @@ -571,7 +577,7 @@ public class DictionaryActivity extends ListActivity { if (indexIndex != selectedSpannableIndex) { changeIndex(selectedSpannableIndex); } - searchText.setText(selectedText); + setSearchText(selectedText); return false; } }); @@ -642,10 +648,7 @@ public class DictionaryActivity extends ListActivity { public boolean onKeyDown(final int keyCode, final KeyEvent event) { if (event.getUnicodeChar() != 0) { if (!searchText.hasFocus()) { - searchText.setText("" + (char) event.getUnicodeChar()); - onSearchTextChange(searchText.getText().toString()); - searchText.requestFocus(); - Selection.moveToRightEdge(searchText.getText(), searchText.getLayout()); + setSearchText("" + (char) event.getUnicodeChar()); } return true; } @@ -662,6 +665,13 @@ public class DictionaryActivity extends ListActivity { return super.onKeyDown(keyCode, event); } + private void setSearchText(final String text) { + searchText.setText(text); + searchText.requestFocus(); + onSearchTextChange(searchText.getText().toString()); + Selection.moveToRightEdge(searchText.getText(), searchText.getLayout()); + } + // -------------------------------------------------------------------------- // SearchOperation @@ -939,7 +949,7 @@ public class DictionaryActivity extends ListActivity { textView.setMovementMethod(LinkMovementMethod.getInstance()); final Matcher matcher = CHAR_DASH.matcher(text); while (matcher.find()) { - spannable.setSpan(new MyClickableSpan(), matcher.start(), matcher.end(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE); + spannable.setSpan(new NonLinkClickableSpan(), matcher.start(), matcher.end(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE); } } diff --git a/src/com/hughes/android/dictionary/DictionaryEditActivity.java b/src/com/hughes/android/dictionary/DictionaryEditActivity.java index 8ad0e25..499feb2 100644 --- a/src/com/hughes/android/dictionary/DictionaryEditActivity.java +++ b/src/com/hughes/android/dictionary/DictionaryEditActivity.java @@ -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; } }); diff --git a/src/com/hughes/android/dictionary/DictionaryInfo.java b/src/com/hughes/android/dictionary/DictionaryInfo.java index 26c818a..6759e32 100644 --- a/src/com/hughes/android/dictionary/DictionaryInfo.java +++ b/src/com/hughes/android/dictionary/DictionaryInfo.java @@ -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; diff --git a/src/com/hughes/android/dictionary/DictionaryManagerActivity.java b/src/com/hughes/android/dictionary/DictionaryManagerActivity.java index 9057803..bd41943 100644 --- a/src/com/hughes/android/dictionary/DictionaryManagerActivity.java +++ b/src/com/hughes/android/dictionary/DictionaryManagerActivity.java @@ -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 index e3b6e64..0000000 --- a/src/com/hughes/android/dictionary/MyClickableSpan.java +++ /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 index 0000000..75e38fc --- /dev/null +++ b/src/com/hughes/android/dictionary/NonLinkClickableSpan.java @@ -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); + } + +} diff --git a/src/com/hughes/android/dictionary/QuickDicConfig.java b/src/com/hughes/android/dictionary/QuickDicConfig.java index 4574107..4cdcbd3 100644 --- a/src/com/hughes/android/dictionary/QuickDicConfig.java +++ b/src/com/hughes/android/dictionary/QuickDicConfig.java @@ -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); + } }