]> gitweb.fperrin.net Git - Dictionary.git/blob - src/com/hughes/android/dictionary/QuickDicConfig.java
Added Apache license.
[Dictionary.git] / src / com / hughes / android / dictionary / QuickDicConfig.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.io.Serializable;
18 import java.util.ArrayList;
19 import java.util.List;
20
21 public final class QuickDicConfig implements Serializable {
22   
23   private static final long serialVersionUID = 6711617368780900979L;
24   
25   static final int LATEST_VERSION = 1;
26   
27   final List<DictionaryConfig> dictionaryConfigs = new ArrayList<DictionaryConfig>();
28   int currentVersion = LATEST_VERSION;
29   
30   public QuickDicConfig() {
31     addDefaultDictionaries();
32   }
33
34   public void addDefaultDictionaries() {
35     {
36       final DictionaryConfig de_en_chemnitz = new DictionaryConfig();
37       de_en_chemnitz.name = "DE<->EN (Chemnitz)";
38       de_en_chemnitz.downloadUrl = "https://sites.google.com/site/quickdic/dictionaries-1/DE-EN_chemnitz.quickdic.zip?attredirects=0&d=1";
39       de_en_chemnitz.localFile = "/sdcard/quickDic/DE-EN_chemnitz.quickdic";
40       addOrReplace(de_en_chemnitz);
41     }
42
43     {
44       final DictionaryConfig en_it_wiktionary = new DictionaryConfig();
45       en_it_wiktionary.name = "EN<->IT (EN Wiktionary)";
46       en_it_wiktionary.downloadUrl = "https://sites.google.com/site/quickdic/dictionaries-1/EN-IT_enwiktionary.quickdic.zip?attredirects=0&d=1";
47       en_it_wiktionary.localFile = "/sdcard/quickDic/EN-IT_enwiktionary.quickdic";
48       addOrReplace(en_it_wiktionary);
49     }
50   }
51
52   private void addOrReplace(final DictionaryConfig dictionaryConfig) {
53     for (int i = 0; i < dictionaryConfigs.size(); ++i) {
54       if (dictionaryConfigs.get(i).name.equals(dictionaryConfig.name)) {
55         dictionaryConfigs.set(i, dictionaryConfig);
56         return;
57       }
58     }
59     dictionaryConfigs.add(dictionaryConfig);
60   }
61
62 }