]> gitweb.fperrin.net Git - Dictionary.git/blobdiff - src/com/hughes/android/dictionary/DictionaryActivity.java
Font size pref, reorder a few EntryTypes.
[Dictionary.git] / src / com / hughes / android / dictionary / DictionaryActivity.java
index 966425eb34da6d6fcc1eebfde90b40110a1a7fae..00d4576012d7b5356bae9aec3ddcacf15335eee8 100644 (file)
@@ -40,6 +40,7 @@ import android.text.Spannable;
 import android.text.TextWatcher;\r
 import android.text.style.StyleSpan;\r
 import android.util.Log;\r
+import android.util.TypedValue;\r
 import android.view.ContextMenu;\r
 import android.view.ContextMenu.ContextMenuInfo;\r
 import android.view.KeyEvent;\r
@@ -93,6 +94,7 @@ public class DictionaryActivity extends ListActivity {
   });\r
   private SearchOperation currentSearchOperation = null;\r
 \r
+  int fontSizeSp;\r
   EditText searchText;\r
   Button langButton;\r
 \r
@@ -207,11 +209,19 @@ public class DictionaryActivity extends ListActivity {
       }\r
     });\r
     \r
+    final String fontSize = prefs.getString(getString(R.string.fontSizeKey), "12");\r
+    try {\r
+      fontSizeSp = Integer.parseInt(fontSize);\r
+    } catch (NumberFormatException e) {\r
+      fontSizeSp = 12;\r
+    }\r
 \r
     setContentView(R.layout.dictionary_activity);\r
     searchText = (EditText) findViewById(R.id.SearchText);\r
+    searchText.setTextSize(TypedValue.COMPLEX_UNIT_SP, fontSizeSp);\r
     \r
     langButton = (Button) findViewById(R.id.LangButton);\r
+    langButton.setTextSize(TypedValue.COMPLEX_UNIT_SP, fontSizeSp);\r
     \r
     searchText.requestFocus();\r
     searchText.addTextChangedListener(searchTextWatcher);\r
@@ -632,7 +642,7 @@ public class DictionaryActivity extends ListActivity {
   // IndexAdapter\r
   // --------------------------------------------------------------------------\r
 \r
-  static final class IndexAdapter extends BaseAdapter {\r
+  final class IndexAdapter extends BaseAdapter {\r
     \r
     final Index index;\r
 \r
@@ -711,6 +721,9 @@ public class DictionaryActivity extends ListActivity {
 \r
         final String col2Text = index.swapPairEntries ? pair.lang1 : pair.lang2;\r
         column2.setText(col2Text, TextView.BufferType.NORMAL);\r
+        \r
+        column1.setTextSize(TypedValue.COMPLEX_UNIT_SP, fontSizeSp);\r
+        column2.setTextSize(TypedValue.COMPLEX_UNIT_SP, fontSizeSp);\r
 \r
         result.addView(tableRow);\r
       }\r
@@ -721,7 +734,7 @@ public class DictionaryActivity extends ListActivity {
     private View getView(TokenRow row, ViewGroup parent) {\r
       final TextView textView = new TextView(parent.getContext());\r
       textView.setText(row.getToken());\r
-      textView.setTextSize(20);\r
+      textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 6 * fontSizeSp / 5);\r
       return textView;\r
     }\r
     \r