diff options
author | 2014-06-30 18:25:56 +0900 | |
---|---|---|
committer | 2014-07-01 15:01:41 +0900 | |
commit | 0dab3171d442a4d0acc87cc0019bfcbd4ea4123f (patch) | |
tree | 0d047ce6abbe7355121e4539b119ee6b90180876 | |
parent | a86e4a2e3bab2416878f9e7ab30724705f8e2180 (diff) | |
download | latinime-0dab3171d442a4d0acc87cc0019bfcbd4ea4123f.tar.gz latinime-0dab3171d442a4d0acc87cc0019bfcbd4ea4123f.tar.xz latinime-0dab3171d442a4d0acc87cc0019bfcbd4ea4123f.zip |
[SD9] Add armenian and georgian scripts
Bug: 15840116
Change-Id: I91719e4fc2e3fe29320e4cb8b1a2f8f93c44cc4d
6 files changed, 42 insertions, 24 deletions
diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml index 7dda0a652..3206413ca 100644 --- a/java/res/values/attrs.xml +++ b/java/res/values/attrs.xml @@ -496,6 +496,8 @@ <enum name="greek" value="2" /> <enum name="arabic" value="3" /> <enum name="hebrew" value="4" /> + <enum name="armenian" value="5" /> + <enum name="georgian" value="6" /> </attr> </declare-styleable> diff --git a/java/res/xml/keyboard_layout_set_armenian_phonetic.xml b/java/res/xml/keyboard_layout_set_armenian_phonetic.xml index 35bd43fb9..c3a11898d 100644 --- a/java/res/xml/keyboard_layout_set_armenian_phonetic.xml +++ b/java/res/xml/keyboard_layout_set_armenian_phonetic.xml @@ -20,6 +20,8 @@ <KeyboardLayoutSet xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"> + <Feature + latin:supportedScript="armenian" /> <Element latin:elementName="alphabet" latin:elementKeyboard="@xml/kbd_armenian_phonetic" diff --git a/java/res/xml/keyboard_layout_set_georgian.xml b/java/res/xml/keyboard_layout_set_georgian.xml index 36d091653..a0a060832 100644 --- a/java/res/xml/keyboard_layout_set_georgian.xml +++ b/java/res/xml/keyboard_layout_set_georgian.xml @@ -20,6 +20,8 @@ <KeyboardLayoutSet xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"> + <Feature + latin:supportedScript="georgian" /> <Element latin:elementName="alphabet" latin:elementKeyboard="@xml/kbd_georgian" diff --git a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java index d0316242b..b57eab31b 100644 --- a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java +++ b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java @@ -48,7 +48,6 @@ import java.util.HashSet; import java.util.Iterator; import java.util.Locale; import java.util.Map; -import java.util.TreeMap; /** * Service for spell checking, using LatinIME's dictionaries and mechanisms. @@ -373,7 +372,7 @@ public final class AndroidSpellCheckerService extends SpellCheckerService } public DictAndKeyboard createDictAndKeyboard(final Locale locale) { - final int script = ScriptUtils.getScriptFromLocale(locale); + final int script = ScriptUtils.getScriptFromSpellCheckerLocale(locale); final String keyboardLayoutName = getKeyboardLayoutNameForScript(script); final InputMethodSubtype subtype = AdditionalSubtypeUtils.createAdditionalSubtype( locale.toString(), keyboardLayoutName, null); diff --git a/java/src/com/android/inputmethod/latin/spellcheck/AndroidWordLevelSpellCheckerSession.java b/java/src/com/android/inputmethod/latin/spellcheck/AndroidWordLevelSpellCheckerSession.java index 848268d78..4825b9e2c 100644 --- a/java/src/com/android/inputmethod/latin/spellcheck/AndroidWordLevelSpellCheckerSession.java +++ b/java/src/com/android/inputmethod/latin/spellcheck/AndroidWordLevelSpellCheckerSession.java @@ -117,7 +117,7 @@ public abstract class AndroidWordLevelSpellCheckerSession extends Session { final String localeString = getLocale(); mDictionaryPool = mService.getDictionaryPool(localeString); mLocale = LocaleUtils.constructLocaleFromString(localeString); - mScript = ScriptUtils.getScriptFromLocale(mLocale); + mScript = ScriptUtils.getScriptFromSpellCheckerLocale(mLocale); } @Override diff --git a/java/src/com/android/inputmethod/latin/utils/ScriptUtils.java b/java/src/com/android/inputmethod/latin/utils/ScriptUtils.java index 283bbf976..a76a6dfd7 100644 --- a/java/src/com/android/inputmethod/latin/utils/ScriptUtils.java +++ b/java/src/com/android/inputmethod/latin/utils/ScriptUtils.java @@ -31,7 +31,9 @@ public class ScriptUtils { public static final int SCRIPT_GREEK = 2; public static final int SCRIPT_ARABIC = 3; public static final int SCRIPT_HEBREW = 4; - public static final TreeMap<String, Integer> mLanguageToScript; + public static final int SCRIPT_ARMENIAN = 5; + public static final int SCRIPT_GEORGIAN = 6; + public static final TreeMap<String, Integer> mSpellCheckerLanguageToScript; static { // List of the supported languages and their associated script. We won't check // words written in another script than the selected script, because we know we @@ -41,24 +43,24 @@ public class ScriptUtils { // proximity to pass to the dictionary descent algorithm. // IMPORTANT: this only contains languages - do not write countries in there. // Only the language is searched from the map. - mLanguageToScript = new TreeMap<>(); - mLanguageToScript.put("cs", SCRIPT_LATIN); - mLanguageToScript.put("da", SCRIPT_LATIN); - mLanguageToScript.put("de", SCRIPT_LATIN); - mLanguageToScript.put("el", SCRIPT_GREEK); - mLanguageToScript.put("en", SCRIPT_LATIN); - mLanguageToScript.put("es", SCRIPT_LATIN); - mLanguageToScript.put("fi", SCRIPT_LATIN); - mLanguageToScript.put("fr", SCRIPT_LATIN); - mLanguageToScript.put("hr", SCRIPT_LATIN); - mLanguageToScript.put("it", SCRIPT_LATIN); - mLanguageToScript.put("lt", SCRIPT_LATIN); - mLanguageToScript.put("lv", SCRIPT_LATIN); - mLanguageToScript.put("nb", SCRIPT_LATIN); - mLanguageToScript.put("nl", SCRIPT_LATIN); - mLanguageToScript.put("pt", SCRIPT_LATIN); - mLanguageToScript.put("sl", SCRIPT_LATIN); - mLanguageToScript.put("ru", SCRIPT_CYRILLIC); + mSpellCheckerLanguageToScript = new TreeMap<>(); + mSpellCheckerLanguageToScript.put("cs", SCRIPT_LATIN); + mSpellCheckerLanguageToScript.put("da", SCRIPT_LATIN); + mSpellCheckerLanguageToScript.put("de", SCRIPT_LATIN); + mSpellCheckerLanguageToScript.put("el", SCRIPT_GREEK); + mSpellCheckerLanguageToScript.put("en", SCRIPT_LATIN); + mSpellCheckerLanguageToScript.put("es", SCRIPT_LATIN); + mSpellCheckerLanguageToScript.put("fi", SCRIPT_LATIN); + mSpellCheckerLanguageToScript.put("fr", SCRIPT_LATIN); + mSpellCheckerLanguageToScript.put("hr", SCRIPT_LATIN); + mSpellCheckerLanguageToScript.put("it", SCRIPT_LATIN); + mSpellCheckerLanguageToScript.put("lt", SCRIPT_LATIN); + mSpellCheckerLanguageToScript.put("lv", SCRIPT_LATIN); + mSpellCheckerLanguageToScript.put("nb", SCRIPT_LATIN); + mSpellCheckerLanguageToScript.put("nl", SCRIPT_LATIN); + mSpellCheckerLanguageToScript.put("pt", SCRIPT_LATIN); + mSpellCheckerLanguageToScript.put("sl", SCRIPT_LATIN); + mSpellCheckerLanguageToScript.put("ru", SCRIPT_CYRILLIC); } /* * Returns whether the code point is a letter that makes sense for the specified @@ -109,6 +111,17 @@ public class ScriptUtils { // Hebrew part of that block, which is U+FB1D..U+FB4F. return (codePoint >= 0x590 && codePoint <= 0x5FF || codePoint >= 0xFB1D && codePoint <= 0xFB4F); + case SCRIPT_ARMENIAN: + // Armenian letters are in the Armenian unicode block, U+0530..U+058F and + // Alphabetic Presentation Forms block, U+FB00..U+FB4F, but only in the Armenian part + // of that block, which is U+FB13..U+FB17. + return (codePoint >= 0x530 && codePoint <= 0x58F + || codePoint >= 0xFB13 && codePoint <= 0xFB17); + case SCRIPT_GEORGIAN: + // Georgian letters are in the Georgian unicode block, U+10A0..U+10FF, + // or Georgian supplement block, U+2D00..U+2D2F + return (codePoint >= 0x10A0 && codePoint <= 0x10FF + || codePoint >= 0x2D00 && codePoint <= 0x2D2F); case SCRIPT_UNKNOWN: return true; default: @@ -117,8 +130,8 @@ public class ScriptUtils { } } - public static int getScriptFromLocale(final Locale locale) { - final Integer script = mLanguageToScript.get(locale.getLanguage()); + public static int getScriptFromSpellCheckerLocale(final Locale locale) { + final Integer script = mSpellCheckerLanguageToScript.get(locale.getLanguage()); if (null == script) { throw new RuntimeException("We have been called with an unsupported language: \"" + locale.getLanguage() + "\". Framework bug?"); |