X-Git-Url: http://gitweb.fperrin.net/?a=blobdiff_plain;f=src%2Fcom%2Fhughes%2Fandroid%2Fdictionary%2FPreferenceActivity.java;h=40784af0161a25bf6e9ab9cf854dccce8afb6697;hb=83d9dc7cd871082a82c2dd0dbb7a0ceabd7c83a0;hp=4481f46a737db3a568132bb828be286ed7e9591b;hpb=fff1803c98e359bd7b3caf5d0215291b107cdc78;p=Dictionary.git diff --git a/src/com/hughes/android/dictionary/PreferenceActivity.java b/src/com/hughes/android/dictionary/PreferenceActivity.java index 4481f46..40784af 100644 --- a/src/com/hughes/android/dictionary/PreferenceActivity.java +++ b/src/com/hughes/android/dictionary/PreferenceActivity.java @@ -33,9 +33,10 @@ public class PreferenceActivity extends android.preference.PreferenceActivity @SuppressWarnings("deprecation") @Override public void onCreate(Bundle savedInstanceState) { - final DictionaryApplication application = (DictionaryApplication) getApplication(); + DictionaryApplication.INSTANCE.init(getApplicationContext()); + final DictionaryApplication application = DictionaryApplication.INSTANCE; setTheme(application.getSelectedTheme().themeId); - + final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); if (prefs.getString(getString(R.string.quickdicDirectoryKey), "").equals("")) { prefs.edit().putString(getString(R.string.quickdicDirectoryKey), application.getDictDir().getAbsolutePath()).commit(); @@ -44,22 +45,21 @@ public class PreferenceActivity extends android.preference.PreferenceActivity prefs.edit().putString(getString(R.string.wordListFileKey), application.getWordListFile().getAbsolutePath()).commit(); } - /** - * @author Dominik Köppl Preference: select default dictionary As this + /* + @author Dominik Köppl Preference: select default dictionary As this * list is dynamically generated, we have to do it in this * fashion */ super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.preferences); ListPreference defaultDic = (ListPreference) findPreference(getResources().getString( - R.string.defaultDicKey)); + R.string.defaultDicKey)); List dicts = application.getDictionariesOnDevice(null); final CharSequence[] entries = new CharSequence[dicts.size()]; final CharSequence[] entryvalues = new CharSequence[dicts.size()]; - for (int i = 0; i < entries.length; ++i) - { + for (int i = 0; i < entries.length; ++i) { entries[i] = dicts.get(i).dictInfo; entryvalues[i] = dicts.get(i).uncompressedFilename; } @@ -82,17 +82,13 @@ public class PreferenceActivity extends android.preference.PreferenceActivity prefs.registerOnSharedPreferenceChangeListener(this); } - @Override - public void onContentChanged() { - super.onContentChanged(); - } - @Override public void onSharedPreferenceChanged(SharedPreferences p, String v) { - final DictionaryApplication application = (DictionaryApplication)getApplication(); + DictionaryApplication.INSTANCE.init(getApplicationContext()); + final DictionaryApplication application = DictionaryApplication.INSTANCE; File dictDir = application.getDictDir(); if (!dictDir.isDirectory() || !dictDir.canWrite() || - !application.checkFileCreate(dictDir)) { + !DictionaryApplication.checkFileCreate(dictDir)) { String dirs = ""; String externalDir = Environment.getExternalStorageDirectory().getAbsolutePath(); if (new File(externalDir).canWrite()) @@ -115,9 +111,12 @@ public class PreferenceActivity extends android.preference.PreferenceActivity dirs += "\n" + externalFilesDir; } } + File fd = getApplicationContext().getFilesDir(); + if (fd.canWrite()) + dirs += "\n" + fd.getAbsolutePath(); new AlertDialog.Builder(this).setTitle(getString(R.string.error)) - .setMessage(getString(R.string.chosenNotWritable) + dirs) - .setNeutralButton("Close", null).show(); + .setMessage(getString(R.string.chosenNotWritable) + dirs) + .setNeutralButton("Close", null).show(); } } }