-import com.ibm.icu.text.Collator;
-
-public class DictionaryApplication extends Application {
-
- static final String LOG = "QuickDicApp";
-
- // Static, determined by resources (and locale).
- // Unordered.
- static Map<String,DictionaryInfo> DOWNLOADABLE_NAME_TO_INFO = null;
-
- static final class DictionaryConfig implements Serializable {
- private static final long serialVersionUID = -1444177164708201263L;
- // User-ordered list, persisted, just the ones that are/have been present.
- final List<String> dictionaryFilesOrdered = new ArrayList<String>();
- final Map<String, DictionaryInfo> dictionaryInfoCache = new LinkedHashMap<String, DictionaryInfo>();
- }
- DictionaryConfig dictionaryConfig = null;
-
- static final class DictionaryHistory implements Serializable {
- private static final long serialVersionUID = -4842995032541390284L;
- // User-ordered list, persisted, just the ones that are/have been present.
- final List<DictionaryLink> dictionaryLinks = new ArrayList<DictionaryLink>();
- }
- DictionaryHistory dictionaryHistory = null;
-
- private File dictDir;
-
- static synchronized void staticInit(final Context context) {
- if (DOWNLOADABLE_NAME_TO_INFO != null) {
- return;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+public enum DictionaryApplication {
+ INSTANCE;
+
+ private Context appContext;
+
+ static final String LOG = "QuickDicApp";
+
+ // If set to false, avoid use of ICU collator
+ // Works well enough for most european languages,
+ // gives faster startup and avoids crashes on some
+ // devices due to Dalvik bugs (e.g. ARMv6, S5570i, CM11)
+ // when using ICU4J.
+ // Leave it enabled by default for correctness except
+ // for my known broken development/performance test device config.
+ //static public final boolean USE_COLLATOR = !android.os.Build.FINGERPRINT.equals("Samsung/cm_tassve/tassve:4.4.4/KTU84Q/20150211:userdebug/release-keys");
+ public static final boolean USE_COLLATOR = true;
+
+ public static final TransliteratorManager.ThreadSetup threadBackground = new TransliteratorManager.ThreadSetup() {
+ @Override
+ public void onThreadStart() {
+ // THREAD_PRIORITY_BACKGROUND seemed like a good idea, but it
+ // can make Transliterator go from 20 seconds to 3 minutes (!)
+ android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_LESS_FAVORABLE);
+ }
+ };
+
+ // Static, determined by resources (and locale).
+ // Unordered.
+ static Map<String, DictionaryInfo> DOWNLOADABLE_UNCOMPRESSED_FILENAME_NAME_TO_DICTIONARY_INFO = null;
+
+ enum Theme {
+ DEFAULT(R.style.Theme_Default,
+ R.style.Theme_Default_TokenRow_Fg,
+ R.color.theme_default_token_row_fg,
+ R.drawable.theme_default_token_row_main_bg,
+ R.drawable.theme_default_token_row_other_bg,
+ R.drawable.theme_default_normal_row_bg),
+
+ LIGHT(R.style.Theme_Light,
+ R.style.Theme_Light_TokenRow_Fg,
+ R.color.theme_light_token_row_fg,
+ R.drawable.theme_light_token_row_main_bg,
+ R.drawable.theme_light_token_row_other_bg,
+ R.drawable.theme_light_normal_row_bg);
+
+ Theme(final int themeId, final int tokenRowFg,
+ final int tokenRowFgColor,
+ final int tokenRowMainBg, final int tokenRowOtherBg,
+ final int normalRowBg) {
+ this.themeId = themeId;
+ this.tokenRowFg = tokenRowFg;
+ this.tokenRowFgColor = tokenRowFgColor;
+ this.tokenRowMainBg = tokenRowMainBg;
+ this.tokenRowOtherBg = tokenRowOtherBg;
+ this.normalRowBg = normalRowBg;
+ }
+
+ final int themeId;
+ final int tokenRowFg;
+ final int tokenRowFgColor;
+ final int tokenRowMainBg;
+ final int tokenRowOtherBg;
+ final int normalRowBg;