From c899038eee5c01d520a2707cca01ee093a674d05 Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Wed, 20 Apr 2011 16:52:07 +0900 Subject: Move language-specific keyboard setting to resources. Some flag settings used to be stored in a keyboard layout extravalue setting. This change: - Introduces the capability of setting such specific flags in values/config.xml - Retains the ability to use extravalues (for layout-specific settings), though there is no more any such setting at the moment. - Fixes a bug where loading a dictionary from outside does not initialize the flags. - Moves Flag to another class. Note: this needs I705ec68c to avoid breaking the build Change-Id: Ia7703aae3215b06c0b3cb792821649806e8998c1 --- .../inputmethod/latin/BinaryDictionary.java | 34 +++++++--------------- 1 file changed, 10 insertions(+), 24 deletions(-) (limited to 'java/src/com/android/inputmethod/latin/BinaryDictionary.java') diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionary.java b/java/src/com/android/inputmethod/latin/BinaryDictionary.java index fa90fce67..58e9099a9 100644 --- a/java/src/com/android/inputmethod/latin/BinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/BinaryDictionary.java @@ -63,18 +63,12 @@ public class BinaryDictionary extends Dictionary { private final KeyboardSwitcher mKeyboardSwitcher = KeyboardSwitcher.getInstance(); - public static class Flag { - public final String mName; - public final int mValue; - - public Flag(String name, int value) { - mName = name; - mValue = value; - } - } - public static final Flag FLAG_REQUIRES_GERMAN_UMLAUT_PROCESSING = - new Flag("requiresGermanUmlautProcessing", 0x1); + new Flag(R.bool.config_require_umlaut_processing, 0x1); + + // Can create a new flag from extravalue : + // public static final Flag FLAG_MYFLAG = + // new Flag("my_flag", 0x02); private static final Flag[] ALL_FLAGS = { // Here should reside all flags that trigger some special processing @@ -118,12 +112,12 @@ public class BinaryDictionary extends Dictionary { return null; } } - sInstance.mFlags = initFlags(ALL_FLAGS, SubtypeSwitcher.getInstance()); + sInstance.mFlags = Flag.initFlags(ALL_FLAGS, context, SubtypeSwitcher.getInstance()); return sInstance; } - /* package for test */ static BinaryDictionary initDictionary(File dictionary, long startOffset, - long length, int dicTypeId, Flag[] flagArray) { + /* package for test */ static BinaryDictionary initDictionary(Context context, File dictionary, + long startOffset, long length, int dicTypeId, Flag[] flagArray) { synchronized (sInstance) { sInstance.closeInternal(); if (dictionary.isFile()) { @@ -134,19 +128,10 @@ public class BinaryDictionary extends Dictionary { return null; } } - sInstance.mFlags = initFlags(flagArray, null); + sInstance.mFlags = Flag.initFlags(flagArray, context, null); return sInstance; } - private static int initFlags(Flag[] flagArray, SubtypeSwitcher switcher) { - int flags = 0; - for (Flag entry : flagArray) { - if (switcher == null || switcher.currentSubtypeContainsExtraValueKey(entry.mName)) - flags |= entry.mValue; - } - return flags; - } - static { Utils.loadNativeLibrary(); } @@ -179,6 +164,7 @@ public class BinaryDictionary extends Dictionary { sInstance.mDicTypeId = dicTypeId; } } + sInstance.mFlags = Flag.initFlags(ALL_FLAGS, context, SubtypeSwitcher.getInstance()); return sInstance; } -- cgit v1.2.3-83-g751a