From 7c5cd5ec89c0d90c3dbac032c61ee04468ecdc87 Mon Sep 17 00:00:00 2001 From: Jean Chalard <jchalard@google.com> Date: Wed, 30 Jul 2014 12:31:29 +0900 Subject: [PATCH] [SD11] Add script checks for Myanmar, Sinhala, Thai and Telugu Bug: 15840116 Change-Id: I1264fdeea0d4739ca0f360f4934d06e5a824d4e5 --- java/res/values/attrs.xml | 4 ++++ java/res/xml/keyboard_layout_set_myanmar.xml | 2 ++ java/res/xml/keyboard_layout_set_sinhala.xml | 2 ++ java/res/xml/keyboard_layout_set_telugu.xml | 2 ++ java/res/xml/keyboard_layout_set_thai.xml | 2 ++ .../inputmethod/latin/utils/ScriptUtils.java | 21 +++++++++++++++++++ 6 files changed, 33 insertions(+) diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml index 9d828ef917..80a657346a 100644 --- a/java/res/values/attrs.xml +++ b/java/res/values/attrs.xml @@ -490,6 +490,10 @@ <enum name="georgian" value="6" /> <enum name="khmer" value="7" /> <enum name="lao" value="8" /> + <enum name="myanmar" value="9" /> + <enum name="sinhala" value="10" /> + <enum name="thai" value="11" /> + <enum name="telugu" value="12" /> </attr> </declare-styleable> diff --git a/java/res/xml/keyboard_layout_set_myanmar.xml b/java/res/xml/keyboard_layout_set_myanmar.xml index 5c823b2634..5af8c064ea 100644 --- a/java/res/xml/keyboard_layout_set_myanmar.xml +++ b/java/res/xml/keyboard_layout_set_myanmar.xml @@ -20,6 +20,8 @@ <KeyboardLayoutSet xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"> + <Feature + latin:supportedScript="myanmar" /> <Element latin:elementName="alphabet" latin:elementKeyboard="@xml/kbd_myanmar" diff --git a/java/res/xml/keyboard_layout_set_sinhala.xml b/java/res/xml/keyboard_layout_set_sinhala.xml index 8e6e619d23..1955d218f0 100644 --- a/java/res/xml/keyboard_layout_set_sinhala.xml +++ b/java/res/xml/keyboard_layout_set_sinhala.xml @@ -20,6 +20,8 @@ <KeyboardLayoutSet xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"> + <Feature + latin:supportedScript="sinhala" /> <Element latin:elementName="alphabet" latin:elementKeyboard="@xml/kbd_sinhala" diff --git a/java/res/xml/keyboard_layout_set_telugu.xml b/java/res/xml/keyboard_layout_set_telugu.xml index aca47b9d92..2bf65bcbda 100644 --- a/java/res/xml/keyboard_layout_set_telugu.xml +++ b/java/res/xml/keyboard_layout_set_telugu.xml @@ -20,6 +20,8 @@ <KeyboardLayoutSet xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"> + <Feature + latin:supportedScript="telugu" /> <Element latin:elementName="alphabet" latin:elementKeyboard="@xml/kbd_telugu" diff --git a/java/res/xml/keyboard_layout_set_thai.xml b/java/res/xml/keyboard_layout_set_thai.xml index b8f99971b9..f69dfa6bda 100644 --- a/java/res/xml/keyboard_layout_set_thai.xml +++ b/java/res/xml/keyboard_layout_set_thai.xml @@ -20,6 +20,8 @@ <KeyboardLayoutSet xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"> + <Feature + latin:supportedScript="thai" /> <Element latin:elementName="alphabet" latin:elementKeyboard="@xml/kbd_thai" diff --git a/java/src/com/android/inputmethod/latin/utils/ScriptUtils.java b/java/src/com/android/inputmethod/latin/utils/ScriptUtils.java index 73f715a4e0..f3df63f457 100644 --- a/java/src/com/android/inputmethod/latin/utils/ScriptUtils.java +++ b/java/src/com/android/inputmethod/latin/utils/ScriptUtils.java @@ -35,6 +35,10 @@ public class ScriptUtils { public static final int SCRIPT_GEORGIAN = 6; public static final int SCRIPT_KHMER = 7; public static final int SCRIPT_LAO = 8; + public static final int SCRIPT_MYANMAR = 9; + public static final int SCRIPT_SINHALA = 10; + public static final int SCRIPT_THAI = 11; + public static final int SCRIPT_TELUGU = 12; public static final TreeMap<String, Integer> mSpellCheckerLanguageToScript; static { // List of the supported languages and their associated script. We won't check @@ -132,6 +136,23 @@ public class ScriptUtils { case SCRIPT_LAO: // The Lao block is U+0E80..U+0EFF return (codePoint >= 0xE80 && codePoint <= 0xEFF); + case SCRIPT_MYANMAR: + // Myanmar has three unicode blocks : + // Myanmar U+1000..U+109F + // Myanmar extended-A U+AA60..U+AA7F + // Myanmar extended-B U+A9E0..U+A9FF + return (codePoint >= 0x1000 && codePoint <= 0x109F + || codePoint >= 0xAA60 && codePoint <= 0xAA7F + || codePoint >= 0xA9E0 && codePoint <= 0xA9FF); + case SCRIPT_SINHALA: + // Sinhala unicode block is U+0D80..U+0DFF + return (codePoint >= 0xD80 && codePoint <= 0xDFF); + case SCRIPT_THAI: + // Thai unicode block is U+0E00..U+0E7F + return (codePoint >= 0xE00 && codePoint <= 0xE7F); + case SCRIPT_TELUGU: + // Telugu unicode block is U+0C00..U+0C7F + return (codePoint >= 0xC00 && codePoint <= 0xC7F); case SCRIPT_UNKNOWN: return true; default: -- GitLab