]> gitweb.fperrin.net Git - Dictionary.git/blobdiff - src/com/hughes/android/dictionary/DictionaryActivity.java
Flag of Scotland, error message when directory is not available.
[Dictionary.git] / src / com / hughes / android / dictionary / DictionaryActivity.java
index d99de3c65ff67617879a5175e3eeb3e6f497a7e6..4425a0b0f3d7cc2276ba5679d7df7e956b68ef20 100644 (file)
@@ -196,11 +196,11 @@ public class DictionaryActivity extends SherlockListActivity {
     public void onCreate(Bundle savedInstanceState) {
         Log.d(LOG, "onCreate:" + this);
         super.onCreate(savedInstanceState);
-
+        
         final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
         
         // Don't auto-launch if this fails.
-        prefs.edit().remove(C.INDEX_SHORT_NAME).commit(); 
+        prefs.edit().remove(C.DICT_FILE).commit(); 
 
         setTheme(((DictionaryApplication) getApplication()).getSelectedTheme().themeId);
 
@@ -233,7 +233,7 @@ public class DictionaryActivity extends SherlockListActivity {
                if(intent.getStringExtra(C.DICT_FILE) == null && (from != null || to != null))
                {
                        Log.d(LOG, "DictSearch: from: " + from + " to " + to);
-                       List<DictionaryInfo> dicts = application.getDictionariesOnDevice();
+                       List<DictionaryInfo> dicts = application.getDictionariesOnDevice(null);
                        for(DictionaryInfo info : dicts)
                        {
                                boolean hasFrom = from == null;
@@ -336,7 +336,6 @@ public class DictionaryActivity extends SherlockListActivity {
                 break;
             }
         }
-        indexIndex %= dictionary.indices.size();
         Log.d(LOG, "Loading index " + indexIndex);
         index = dictionary.indices.get(indexIndex);
         setListAdapter(new IndexAdapter(index));
@@ -404,7 +403,7 @@ public class DictionaryActivity extends SherlockListActivity {
 
         // Cache some prefs.
         wordList = new File(prefs.getString(getString(R.string.wordListFileKey),
-                getString(R.string.wordListFileDefault)));
+                new File(application.getDictDir(), "wordList.txt").getAbsolutePath()));
         saveOnlyFirstSubentry = prefs.getBoolean(getString(R.string.saveOnlyFirstSubentryKey),
                 false);
         clickOpensContextMenu = prefs.getBoolean(getString(R.string.clickOpensContextMenuKey),
@@ -435,7 +434,7 @@ public class DictionaryActivity extends SherlockListActivity {
         
         searchView = new SearchView(getSupportActionBar().getThemedContext());
         searchView.setIconifiedByDefault(false);
-        // searchView.setIconified(false); // puts the magifying glass in the
+        // searchView.setIconified(false); // puts the magnifying glass in the
         // wrong place.
         searchView.setQueryHint(getString(R.string.searchText));
         searchView.setSubmitButtonEnabled(false);
@@ -613,7 +612,7 @@ public class DictionaryActivity extends SherlockListActivity {
         dialog.setContentView(R.layout.select_dictionary_dialog);
         dialog.setTitle(R.string.selectDictionary);
 
-        final List<DictionaryInfo> installedDicts = application.getDictionariesOnDevice();
+        final List<DictionaryInfo> installedDicts = application.getDictionariesOnDevice(null);
 
         ListView listView = (ListView) dialog.findViewById(android.R.id.list);
         final Button button = new Button(listView.getContext());
@@ -638,15 +637,8 @@ public class DictionaryActivity extends SherlockListActivity {
                 final LinearLayout result = new LinearLayout(parent.getContext());
 
                 for (int i = 0; i < dictionaryInfo.indexInfos.size(); ++i) {
-                    if (i > 0) {
-                        final TextView dash = new TextView(parent.getContext());
-                        dash.setText("-");
-                        result.addView(dash);
-                    }
-
                     final IndexInfo indexInfo = dictionaryInfo.indexInfos.get(i);
-                    final Button button = new Button(parent.getContext());
-                    button.setText(indexInfo.shortName);
+                    final View button = application.createButton(parent.getContext(), dictionaryInfo, indexInfo);
                     final IntentLauncher intentLauncher = new IntentLauncher(parent.getContext(),
                             getLaunchIntent(
                                     application.getPath(dictionaryInfo.uncompressedFilename),
@@ -659,7 +651,6 @@ public class DictionaryActivity extends SherlockListActivity {
                     };
                     button.setOnClickListener(intentLauncher);
                     result.addView(button);
-
                 }
 
                 final TextView nameView = new TextView(parent.getContext());
@@ -672,7 +663,6 @@ public class DictionaryActivity extends SherlockListActivity {
                 layoutParams.weight = 1.0f;
                 nameView.setLayoutParams(layoutParams);
                 result.addView(nameView);
-
                 return result;
             }