import java.io.PrintWriter;\r
import java.io.RandomAccessFile;\r
import java.text.SimpleDateFormat;\r
+import java.util.ArrayList;\r
import java.util.Date;\r
+import java.util.List;\r
import java.util.concurrent.Executor;\r
import java.util.concurrent.Executors;\r
import java.util.concurrent.ThreadFactory;\r
import java.util.regex.Matcher;\r
import java.util.regex.Pattern;\r
\r
+import android.app.Activity;\r
+import android.app.Dialog;\r
import android.app.ListActivity;\r
import android.content.Context;\r
import android.content.Intent;\r
import android.widget.BaseAdapter;\r
import android.widget.Button;\r
import android.widget.EditText;\r
+import android.widget.LinearLayout;\r
import android.widget.ListAdapter;\r
import android.widget.ListView;\r
import android.widget.TableLayout;\r
\r
static final String LOG = "QuickDic";\r
\r
- int dictIndex = 0;\r
+ String dictFile = null;\r
RandomAccessFile dictRaf = null;\r
Dictionary dictionary = null;\r
int indexIndex = 0;\r
onLanguageButton();\r
}\r
});\r
+ langButton.setOnLongClickListener(new OnLongClickListener() {\r
+ @Override\r
+ public boolean onLongClick(View v) {\r
+ onLanguageButtonLongClick();\r
+ return true;\r
+ }\r
+ });\r
updateLangButton();\r
\r
final Button upButton = (Button) findViewById(R.id.UpButton);\r
}\r
\r
void updateLangButton() {\r
- langButton.setText(index.shortName.toUpperCase());\r
+ langButton.setText(index.shortName);\r
}\r
\r
void onLanguageButton() {\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 int indexIndex;\r
+\r
+ public OpenIndexButton(final Context context, final Activity activity, final String text, final int dictionaryIndex, final int indexIndex) {\r
+ super(context);\r
+ this.activity = activity;\r
+ this.dictionaryIndex = dictionaryIndex;\r
+ this.indexIndex = indexIndex;\r
+ setOnClickListener(this);\r
+ setText(text, BufferType.NORMAL);\r
+ }\r
+\r
+ @Override\r
+ public void onClick(View v) {\r
+ activity.finish();\r
+ getContext().startActivity(DictionaryActivity.getIntent(getContext(), dictionaryIndex, indexIndex, ""));\r
+ }\r
+ \r
+ }\r
+\r
+ void onLanguageButtonLongClick() {\r
+ Context mContext = getApplicationContext();\r
+ Dialog dialog = new Dialog(mContext);\r
+ \r
+ dialog.setContentView(R.layout.select_dictionary_dialog);\r
+ dialog.setTitle(R.string.selectADictionary);\r
+\r
+ ListView listView = (ListView) dialog.findViewById(android.R.id.list);\r
+\r
+ QuickDicConfig quickDicConfig = PersistentObjectCache.init(\r
+ this).read(C.DICTIONARY_CONFIGS, QuickDicConfig.class);\r
+ final List<DictionaryInfo> dictionaryInfos = new ArrayList<DictionaryInfo>();\r
+ for (final DictionaryInfo dictionaryInfo : quickDicConfig.dictionaryInfos) {\r
+ if (new File(dictionaryInfo.localFile).canRead()) {\r
+ dictionaryInfos.add(dictionaryInfo);\r
+ }\r
+ }\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
+ }\r
+ \r
+ @Override\r
+ public long getItemId(int position) {\r
+ return position;\r
+ }\r
+ \r
+ @Override\r
+ public Object getItem(int position) {\r
+ return dictionaryInfos.get(position);\r
+ }\r
+ \r
+ @Override\r
+ public int getCount() {\r
+ return dictionaryInfos.size();\r
+ }\r
+ });\r
+ }\r
+\r
\r
private void changeIndex(final int newIndex) {\r
indexIndex = newIndex;\r