1 // Copyright 2011 Google Inc. All Rights Reserved.
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 package com.hughes.android.dictionary;
17 import java.util.List;
19 import android.content.SharedPreferences;
20 import android.os.Bundle;
21 import android.preference.ListPreference;
22 import android.preference.PreferenceManager;
24 public class PreferenceActivity extends android.preference.PreferenceActivity {
26 static boolean prefsMightHaveChanged = false;
28 @SuppressWarnings("deprecation")
30 public void onCreate(Bundle savedInstanceState) {
31 final DictionaryApplication application = (DictionaryApplication) getApplication();
32 setTheme(application.getSelectedTheme().themeId);
34 final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
35 if (prefs.getString(getString(R.string.quickdicDirectoryKey), "").equals("")) {
36 prefs.edit().putString(getString(R.string.quickdicDirectoryKey), application.getDictDir().getAbsolutePath()).commit();
38 if (prefs.getString(getString(R.string.wordListFileKey), "").equals("")) {
39 prefs.edit().putString(getString(R.string.wordListFileKey), application.getWordListFile().getAbsolutePath()).commit();
43 * @author Dominik Köppl Preference: select default dictionary As this
44 * list is dynamically generated, we have to do it in this
47 super.onCreate(savedInstanceState);
48 addPreferencesFromResource(R.xml.preferences);
49 ListPreference defaultDic = (ListPreference) findPreference(getResources().getString(
50 R.string.defaultDicKey));
51 List<DictionaryInfo> dicts = application.getDictionariesOnDevice(null);
53 final CharSequence[] entries = new CharSequence[dicts.size()];
54 final CharSequence[] entryvalues = new CharSequence[dicts.size()];
56 for (int i = 0; i < entries.length; ++i)
58 entries[i] = dicts.get(i).dictInfo;
59 entryvalues[i] = dicts.get(i).uncompressedFilename;
62 defaultDic.setEntries(entries);
63 defaultDic.setEntryValues(entryvalues);
67 public void onContentChanged() {
68 super.onContentChanged();