]> gitweb.fperrin.net Git - Dictionary.git/blobdiff - src/com/hughes/android/dictionary/DictionaryActivity.java
String changes, focus changes.
[Dictionary.git] / src / com / hughes / android / dictionary / DictionaryActivity.java
index 922b9728cda321c11c62614ba554414496ce8025..e6eb3d1297054fa7b1f0945e4b66d71b4e46ebb4 100644 (file)
@@ -1,3 +1,17 @@
+// 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 java.io.File;\r
@@ -137,6 +151,7 @@ public class DictionaryActivity extends ListActivity {
           this).read(C.DICTIONARY_CONFIGS, QuickDicConfig.class);\r
       dictIndex = prefs.getInt(C.DICT_INDEX, 0) ;\r
       final DictionaryConfig dictionaryConfig = quickDicConfig.dictionaryConfigs.get(dictIndex);\r
+      this.setTitle("QuickDic: " + dictionaryConfig.name);\r
       dictRaf = new RandomAccessFile(dictionaryConfig.localFile, "r");\r
       dictionary = new Dictionary(dictRaf); \r
     } catch (Exception e) {\r
@@ -194,6 +209,7 @@ public class DictionaryActivity extends ListActivity {
 \r
     setContentView(R.layout.dictionary_activity);\r
     searchText = (EditText) findViewById(R.id.SearchText);\r
+    \r
     langButton = (Button) findViewById(R.id.LangButton);\r
     \r
     searchText.requestFocus();\r
@@ -319,7 +335,7 @@ public class DictionaryActivity extends ListActivity {
     searchText.requestFocus();\r
     Log.d(LOG, "Trying to show soft keyboard.");\r
     final InputMethodManager manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);\r
-    manager.showSoftInput(searchText, InputMethodManager.SHOW_IMPLICIT);\r
+    manager.showSoftInput(searchText, InputMethodManager.SHOW_FORCED);\r
   }\r
   \r
   void updateLangButton() {\r
@@ -404,6 +420,18 @@ public class DictionaryActivity extends ListActivity {
       });\r
     }\r
 \r
+    {\r
+      final MenuItem about = menu.add(getString(R.string.about));\r
+      about.setOnMenuItemClickListener(new OnMenuItemClickListener() {\r
+        public boolean onMenuItemClick(final MenuItem menuItem) {\r
+          final Intent intent = new Intent().setClassName(AboutActivity.class\r
+              .getPackage().getName(), AboutActivity.class.getCanonicalName());\r
+          startActivity(intent);\r
+          return false;\r
+        }\r
+      });\r
+    }\r
+\r
     return true;\r
   }\r
 \r
@@ -450,6 +478,10 @@ public class DictionaryActivity extends ListActivity {
     rawText.append(row.getTokenRow(true).getToken()).append("\t");\r
     rawText.append(row.getRawText(saveOnlyFirstSubentry));\r
     Log.d(LOG, "Writing : " + rawText);\r
+\r
+    // Request focus so that if we start typing again, it clears the text input.\r
+    getListView().requestFocus();\r
+\r
     try {\r
       wordList.getParentFile().mkdirs();\r
       final PrintWriter out = new PrintWriter(\r
@@ -464,6 +496,9 @@ public class DictionaryActivity extends ListActivity {
   }\r
 \r
   void onCopy(final RowBase row) {\r
+    // Request focus so that if we start typing again, it clears the text input.\r
+    getListView().requestFocus();\r
+\r
     Log.d(LOG, "Copy, row=" + row);\r
     final StringBuilder result = new StringBuilder();\r
     result.append(row.getRawText(false));\r
@@ -486,6 +521,12 @@ public class DictionaryActivity extends ListActivity {
       Log.d(LOG, "Clearing dictionary prefs.");\r
       DictionaryActivity.clearDictionaryPrefs(this);\r
     }\r
+    if (keyCode == KeyEvent.KEYCODE_ENTER) {\r
+//      Log.d(LOG, "Trying to hide soft keyboard.");\r
+//      final InputMethodManager manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);\r
+//      manager.hideSoftInputFromWindow(searchText, InputMethodManager.SHOW_FORCED);\r
+\r
+    }\r
     return super.onKeyDown(keyCode, event);\r
   }\r
 \r