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.io.Serializable;
18 import java.util.ArrayList;
19 import java.util.List;
21 import android.os.Environment;
23 import com.hughes.android.dictionary.engine.Language;
25 public final class QuickDicConfig implements Serializable {
27 private static final long serialVersionUID = 6711617368780900979L;
29 // Just increment this to have them all update...
30 static final int LATEST_VERSION = 6;
32 final List<DictionaryInfo> dictionaryConfigs = new ArrayList<DictionaryInfo>();
33 int currentVersion = LATEST_VERSION;
35 public QuickDicConfig() {
36 addDefaultDictionaries();
39 static final String BASE_URL = "http://quickdic-dictionary.googlecode.com/files/";
41 // TODO: read this from a resource file....
43 public void addDefaultDictionaries() {
45 final DictionaryInfo config = new DictionaryInfo();
46 config.name = "German-English";
47 config.downloadUrl = String.format("%sDE-EN_chemnitz_enwiktionary.quickdic.%s.zip", BASE_URL, VERSION_SUFFIX);
48 config.localFile = String.format("%s/quickDic/DE-EN_chemnitz_enwiktionary.quickdic", Environment.getExternalStorageDirectory());
52 for (final String iso : Language.isoCodeToResourceName.keySet()) {
53 if (iso.equals("EN") || iso.equals("DE")) {
56 final DictionaryInfo config = new DictionaryInfo();
57 config.name = String.format("English-%s", Language.isoCodeToWikiName.get(iso));
58 config.downloadUrl = String.format("%sEN-%s_enwiktionary.quickdic.%s.zip", BASE_URL, iso, VERSION_SUFFIX);
59 config.localFile = String.format("%s/quickDic/EN-%s_enwiktionary.quickdic", Environment.getExternalStorageDirectory(), iso);
64 private void addOrReplace(final DictionaryInfo dictionaryConfig) {
65 for (int i = 0; i < dictionaryConfigs.size(); ++i) {
66 if (dictionaryConfigs.get(i).name.equals(dictionaryConfig.name)) {
67 dictionaryConfigs.set(i, dictionaryConfig);
71 dictionaryConfigs.add(dictionaryConfig);