]> gitweb.fperrin.net Git - Dictionary.git/blob - src/com/hughes/android/dictionary/PreferenceActivity.java
Using ListView again for DictionaryManager, downloads working with
[Dictionary.git] / src / com / hughes / android / dictionary / PreferenceActivity.java
1 // Copyright 2011 Google Inc. All Rights Reserved.
2 //
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
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
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.
14
15 package com.hughes.android.dictionary;
16
17 import java.util.List;
18
19 import android.os.Bundle;
20 import android.preference.ListPreference;
21
22 public class PreferenceActivity extends android.preference.PreferenceActivity {
23   
24   static boolean prefsMightHaveChanged = false;
25   
26   @SuppressWarnings("deprecation")
27   @Override
28   public void onCreate(Bundle savedInstanceState) {
29     setTheme(((DictionaryApplication)getApplication()).getSelectedTheme().themeId);
30
31     /**
32      * @author Dominik Köppl
33      * Preference: select default dictionary
34      * As this list is dynamically generated, we have to do it in this fashion
35      */
36     super.onCreate(savedInstanceState);
37     addPreferencesFromResource(R.xml.preferences);
38     ListPreference defaultDic = (ListPreference) findPreference(getResources().getString(R.string.defaultDicKey));
39     DictionaryApplication application = (DictionaryApplication) getApplication();
40     List<DictionaryInfo> dicts = application.getDictionariesOnDevice(null);
41     
42         final CharSequence[] entries = new CharSequence[dicts.size()];
43         final CharSequence[] entryvalues = new CharSequence[dicts.size()];
44
45         for(int i = 0; i < entries.length; ++i)
46         {
47                 entries[i] = dicts.get(i).dictInfo;
48                 entryvalues[i] = dicts.get(i).uncompressedFilename;
49         }
50         
51         defaultDic.setEntries(entries);
52         defaultDic.setEntryValues(entryvalues);
53   }
54
55   @Override
56   public void onContentChanged() {
57     super.onContentChanged();
58   }
59 }