]> gitweb.fperrin.net Git - Dictionary.git/blobdiff - src/com/hughes/android/dictionary/DictionaryListActivity.java
Font size pref, reorder a few EntryTypes.
[Dictionary.git] / src / com / hughes / android / dictionary / DictionaryListActivity.java
index 286f2497e98e035d7255f6e3e90b675ef087ad70..004ce2be4edcb459d0faac295d1d187a14c15858 100644 (file)
@@ -1,5 +1,21 @@
+// Copyright 2011 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
 package com.hughes.android.dictionary;
 
+import java.io.File;
+
 import android.app.AlertDialog;
 import android.app.ListActivity;
 import android.content.Context;
@@ -9,6 +25,7 @@ import android.content.SharedPreferences;
 import android.os.Bundle;
 import android.preference.PreferenceManager;
 import android.util.Log;
+import android.util.TypedValue;
 import android.view.ContextMenu;
 import android.view.Menu;
 import android.view.MenuItem;
@@ -125,6 +142,15 @@ public class DictionaryListActivity extends ListActivity {
           }
         });
 
+    final MenuItem removeAllDictionariesMenuItem = menu.add(R.string.removeAllDictionaries);
+    removeAllDictionariesMenuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
+          public boolean onMenuItemClick(final MenuItem menuItem) {
+            quickDicConfig.dictionaryConfigs.clear();
+            dictionaryConfigsChanged();
+            return false;
+          }
+        });
+
     final MenuItem about = menu.add(getString(R.string.about));
     about.setOnMenuItemClickListener(new OnMenuItemClickListener() {
       public boolean onMenuItemClick(final MenuItem menuItem) {
@@ -165,12 +191,12 @@ public class DictionaryListActivity extends ListActivity {
     });
 
     if (adapterContextMenuInfo.position > 0) {
-      final MenuItem moveUpMenuItem = menu.add(R.string.moveUp);
-      moveUpMenuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
+      final MenuItem moveToTopMenuItem = menu.add(R.string.moveToTop);
+      moveToTopMenuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
         @Override
         public boolean onMenuItemClick(MenuItem item) {
           final DictionaryConfig dictionaryConfig = quickDicConfig.dictionaryConfigs.remove(adapterContextMenuInfo.position);
-          quickDicConfig.dictionaryConfigs.add(adapterContextMenuInfo.position - 1, dictionaryConfig);
+          quickDicConfig.dictionaryConfigs.add(0, dictionaryConfig);
           dictionaryConfigsChanged();
           return true;
         }
@@ -216,9 +242,14 @@ public class DictionaryListActivity extends ListActivity {
       final DictionaryConfig dictionaryConfig = getItem(position);
       final TableLayout tableLayout = new TableLayout(parent.getContext());
       final TextView view = new TextView(parent.getContext());
+      
+      String name = dictionaryConfig.name;
+      if (!new File(dictionaryConfig.localFile).canRead()) {
+        name = getString(R.string.notOnDevice, dictionaryConfig.name);
+      }
 
-      view.setText(dictionaryConfig.name);
-      view.setTextSize(20);
+      view.setText(name);
+      view.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22);
       tableLayout.addView(view);
 
       return tableLayout;