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 com.hughes.android.dictionary.engine.Language;
23 public final class QuickDicConfig implements Serializable {
25 private static final long serialVersionUID = 6711617368780900979L;
27 // Just increment this to have them all update...
28 static final int LATEST_VERSION = 4;
30 final List<DictionaryConfig> dictionaryConfigs = new ArrayList<DictionaryConfig>();
31 int currentVersion = LATEST_VERSION;
33 public QuickDicConfig() {
34 addDefaultDictionaries();
37 static final String BASE_URL = "http://quickdic-dictionary.googlecode.com/files/";
39 public void addDefaultDictionaries() {
41 final DictionaryConfig config = new DictionaryConfig();
42 config.name = "German-English";
43 config.downloadUrl = BASE_URL + "DE-EN_chemnitz_enwiktionary.quickdic.zip";
44 config.localFile = "/sdcard/quickDic/DE-EN_chemnitz_enwiktionary.quickdic";
48 for (final String iso : Language.isoCodeToWikiName.keySet()) {
49 if (iso.equals("EN") || iso.equals("DE")) {
52 final DictionaryConfig config = new DictionaryConfig();
53 config.name = String.format("English-%s", Language.isoCodeToWikiName.get(iso));
54 config.downloadUrl = String.format("%sEN-%s_enwiktionary.quickdic.zip", BASE_URL, iso);
55 config.localFile = String.format("/sdcard/quickDic/EN-%s_enwiktionary.quickdic", iso);
61 private void addOrReplace(final DictionaryConfig dictionaryConfig) {
62 for (int i = 0; i < dictionaryConfigs.size(); ++i) {
63 if (dictionaryConfigs.get(i).name.equals(dictionaryConfig.name)) {
64 dictionaryConfigs.set(i, dictionaryConfig);
68 dictionaryConfigs.add(dictionaryConfig);