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 = 3;
30 final List<DictionaryConfig> dictionaryConfigs = new ArrayList<DictionaryConfig>();
31 int currentVersion = LATEST_VERSION;
33 public QuickDicConfig() {
34 addDefaultDictionaries();
37 public void addDefaultDictionaries() {
39 final DictionaryConfig config = new DictionaryConfig();
40 config.name = "German<->English";
41 config.downloadUrl = "https://sites.google.com/site/quickdic/dictionaries-1/DE-EN_chemnitz_enwiktionary.quickdic.zip?attredirects=0&d=1";
42 config.localFile = "/sdcard/quickDic/DE-EN_chemnitz_enwiktionary.quickdic";
46 for (final String iso : Language.isoCodeToWikiName.keySet()) {
47 if (iso.equals("EN") || iso.equals("DE")) {
50 final DictionaryConfig config = new DictionaryConfig();
51 config.name = String.format("EN<->%s English<->%s (Wiktionary)", iso, Language.isoCodeToWikiName.get(iso));
52 config.downloadUrl = String.format("https://sites.google.com/site/quickdic/dictionaries-1/EN-%s_enwiktionary.quickdic.zip?attredirects=0&d=1", iso);
53 config.localFile = String.format("/sdcard/quickDic/EN-%s_enwiktionary.quickdic", iso);
59 private void addOrReplace(final DictionaryConfig dictionaryConfig) {
60 for (int i = 0; i < dictionaryConfigs.size(); ++i) {
61 if (dictionaryConfigs.get(i).name.equals(dictionaryConfig.name)) {
62 dictionaryConfigs.set(i, dictionaryConfig);
66 dictionaryConfigs.add(dictionaryConfig);