]> gitweb.fperrin.net Git - Dictionary.git/blobdiff - src/com/hughes/android/dictionary/DictionaryManagerActivity.java
Added multiword search to dictionary.
[Dictionary.git] / src / com / hughes / android / dictionary / DictionaryManagerActivity.java
index b3df7f30e392432fba2170d8acdb3d9476058491..1ba06fc59fd7c845beb8a2fb645d5a4e5f3b2cd8 100644 (file)
@@ -40,6 +40,7 @@ import android.widget.AdapterView.AdapterContextMenuInfo;
 import android.widget.AdapterView.OnItemClickListener;
 import android.widget.BaseAdapter;
 import android.widget.Button;
+import android.widget.ImageView;
 import android.widget.LinearLayout;
 import android.widget.TextView;
 
@@ -214,7 +215,12 @@ public class DictionaryManagerActivity extends ListActivity {
     public View getView(final int position, final View convertView, final ViewGroup parent) {
       final DictionaryInfo dictionaryInfo = getItem(position);
       final LinearLayout result = new LinearLayout(parent.getContext());
-      
+      result.setOrientation(LinearLayout.VERTICAL);
+
+      final LinearLayout row = new LinearLayout(parent.getContext());
+      row.setOrientation(LinearLayout.HORIZONTAL);
+      result.addView(row);
+
       final boolean updateAvailable = application.updateAvailable(dictionaryInfo);
       final DictionaryInfo downloadable = application.getDownloadable(dictionaryInfo.uncompressedFilename); 
       if ((!application.isDictionaryOnDevice(dictionaryInfo.uncompressedFilename) || updateAvailable) && downloadable != null) {
@@ -233,22 +239,37 @@ public class DictionaryManagerActivity extends ListActivity {
         layoutParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
         layoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
         downloadButton.setLayoutParams(layoutParams);
-        result.addView(downloadButton);
+        row.addView(downloadButton);
+      } else {
+        final ImageView checkMark = new ImageView(parent.getContext());
+        checkMark.setImageResource(android.R.drawable.checkbox_on_background);
+        row.addView(checkMark);
       }
 
       final TextView textView = new TextView(parent.getContext());
       final String name = application.getDictionaryName(dictionaryInfo.uncompressedFilename);
       textView.setText(name);
       textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22);
-      result.addView(textView);
+      row.addView(textView);
       
       // Add the information about each index.
+      final LinearLayout row2 = new LinearLayout(parent.getContext());
+      row2.setOrientation(LinearLayout.HORIZONTAL);
+      final LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
+      row2.setLayoutParams(layoutParams);
+      result.addView(row2);
+      final StringBuilder builder = new StringBuilder();
       for (final IndexInfo indexInfo : dictionaryInfo.indexInfos) {
-        final TextView indexView = new TextView(parent.getContext());
-        indexView.setText(getString(R.string.indexInfo, indexInfo.shortName, indexInfo.mainTokenCount));
-        result.addView(indexView);
+        if (builder.length() > 0) {
+          builder.append(" | ");
+        }
+        builder.append(getString(R.string.indexInfo, indexInfo.shortName, indexInfo.mainTokenCount));
       }
-
+      final TextView indexView = new TextView(parent.getContext());
+      indexView.setText(builder.toString());
+      row2.addView(indexView);
+      
+      
       // Because we have a Button inside a ListView row:
       // http://groups.google.com/group/android-developers/browse_thread/thread/3d96af1530a7d62a?pli=1
       result.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);