]> gitweb.fperrin.net Git - Dictionary.git/blobdiff - src/com/hughes/android/dictionary/DictionaryActivity.java
Theme, different color rows, dictionary_info, long click begin.
[Dictionary.git] / src / com / hughes / android / dictionary / DictionaryActivity.java
index a3cc390e3991936423de0427d6dd5177d219606f..0a846e6d9bf6a52bfdfb3d648ddd08ef98dbde76 100644 (file)
@@ -78,8 +78,6 @@ public class DictionaryActivity extends ListActivity {
 \r
   static final String LOG = "QuickDic";\r
   \r
-  static final int VIBRATE_MILLIS = 100;\r
-\r
   int dictIndex = 0;\r
   RandomAccessFile dictRaf = null;\r
   Dictionary dictionary = null;\r
@@ -96,6 +94,7 @@ public class DictionaryActivity extends ListActivity {
   });\r
   private SearchOperation currentSearchOperation = null;\r
 \r
+  C.Theme theme = C.Theme.LIGHT;\r
   int fontSizeSp;\r
   EditText searchText;\r
   Button langButton;\r
@@ -153,7 +152,7 @@ public class DictionaryActivity extends ListActivity {
   @Override\r
   public void onCreate(Bundle savedInstanceState) {\r
     Log.d(LOG, "onCreate:" + this);\r
-    ((DictionaryApplication)getApplication()).applyTheme(this);\r
+    theme = ((DictionaryApplication)getApplication()).getSelectedTheme();\r
     super.onCreate(savedInstanceState);\r
     \r
     final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);\r
@@ -163,7 +162,7 @@ public class DictionaryActivity extends ListActivity {
       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.dictionaryConfigs.get(dictIndex);\r
+      final DictionaryInfo dictionaryConfig = quickDicConfig.dictionaryInfos.get(dictIndex);\r
       this.setTitle("QuickDic: " + dictionaryConfig.name);\r
       dictRaf = new RandomAccessFile(dictionaryConfig.localFile, "r");\r
       dictionary = new Dictionary(dictRaf); \r
@@ -711,8 +710,8 @@ public class DictionaryActivity extends ListActivity {
       for (int r = 0; r < rowCount; ++r) {\r
         final TableRow tableRow = new TableRow(result.getContext());\r
 \r
-        TextView column1 = new TextView(tableRow.getContext());\r
-        TextView column2 = new TextView(tableRow.getContext());\r
+        final EditText column1 = new EditText(tableRow.getContext());\r
+        final EditText column2 = new EditText(tableRow.getContext());\r
         final TableRow.LayoutParams layoutParams = new TableRow.LayoutParams();\r
         layoutParams.weight = 0.5f;\r
 \r
@@ -752,6 +751,17 @@ public class DictionaryActivity extends ListActivity {
         \r
         column1.setTextSize(TypedValue.COMPLEX_UNIT_SP, fontSizeSp);\r
         column2.setTextSize(TypedValue.COMPLEX_UNIT_SP, fontSizeSp);\r
+        column2.setBackgroundResource(theme.otherLangBg);\r
+        \r
+        column2.setOnLongClickListener(new EditText.OnLongClickListener() {\r
+          @Override\r
+          public boolean onLongClick(View v) {\r
+            final int start = column2.getSelectionStart();\r
+            final int end = column2.getSelectionStart();\r
+            Log.i(LOG, "Long click on: " + column2.getText().toString().substring(start, end));\r
+            return false;\r
+          }\r
+        });\r
 \r
         result.addView(tableRow);\r
       }\r
@@ -763,10 +773,10 @@ public class DictionaryActivity extends ListActivity {
       final Context context = parent.getContext();\r
       final TextView textView = new TextView(context);\r
       textView.setText(row.getToken());\r
-      textView.setBackgroundResource(R.drawable.token_row_drawable);\r
+      textView.setBackgroundResource(row.hasMainEntry ? theme.tokenRowMainBg : theme.tokenRowOtherBg);\r
       // Doesn't work:\r
       //textView.setTextColor(android.R.color.secondary_text_light);\r
-      textView.setTextAppearance(context, R.style.Theme_Light_Token);\r
+      textView.setTextAppearance(context, theme.tokenRowFg);\r
       textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 5 * fontSizeSp / 4);\r
       return textView;\r
     }\r