diff options
-rw-r--r-- | java/res/values/donottranslate.xml | 2 | ||||
-rw-r--r-- | java/res/values/strings.xml | 2 | ||||
-rw-r--r-- | java/res/xml/method.xml | 2 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java | 2 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/latin/SubtypeSwitcher.java | 2 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/latin/Utils.java | 19 | ||||
-rw-r--r-- | tests/src/com/android/inputmethod/latin/SubtypeLocaleTests.java | 49 | ||||
-rw-r--r-- | tests/src/com/android/inputmethod/latin/UserBigramSuggestTests.java | 2 |
8 files changed, 39 insertions, 41 deletions
diff --git a/java/res/values/donottranslate.xml b/java/res/values/donottranslate.xml index 1f7736d9c..e6f036d53 100644 --- a/java/res/values/donottranslate.xml +++ b/java/res/values/donottranslate.xml @@ -161,6 +161,8 @@ <!-- Generic subtype label --> <string name="subtype_generic">%s</string> + <!-- Description for generic QWERTY keyboard subtype --> + <string name="subtype_generic_qwerty">%s (QWERTY)</string> <!-- dictionary pack package name /settings activity (for shared prefs and settings) --> <string name="dictionary_pack_package_name">com.google.android.inputmethod.latin.dictionarypack</string> diff --git a/java/res/values/strings.xml b/java/res/values/strings.xml index d860a1b23..f7d8b4533 100644 --- a/java/res/values/strings.xml +++ b/java/res/values/strings.xml @@ -335,8 +335,6 @@ <!-- Title of the item to change the keyboard theme [CHAR LIMIT=20]--> <string name="keyboard_layout">Keyboard theme</string> - <!-- Description for German QWERTY keyboard subtype [CHAR LIMIT=22] --> - <string name="subtype_de_qwerty">German QWERTY</string> <!-- Description for English (United Kingdom) keyboard subtype [CHAR LIMIT=22] --> <string name="subtype_en_GB">English (UK)</string> <!-- Description for English (United States) keyboard subtype [CHAR LIMIT=22] --> diff --git a/java/res/xml/method.xml b/java/res/xml/method.xml index a3b1d5859..6c827363c 100644 --- a/java/res/xml/method.xml +++ b/java/res/xml/method.xml @@ -71,7 +71,7 @@ android:imeSubtypeExtraValue="AsciiCapable,SupportTouchPositionCorrection" /> <subtype android:icon="@drawable/ic_subtype_keyboard" - android:label="@string/subtype_de_qwerty" + android:label="@string/subtype_generic_qwerty" android:imeSubtypeLocale="de" android:imeSubtypeMode="keyboard" android:imeSubtypeExtraValue="AsciiCapable,KeyboardLocale=de_ZZ,SupportTouchPositionCorrection" diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java index 3433cd455..4d2aeeccf 100644 --- a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java @@ -806,7 +806,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke return bounds.width(); } - // Layout local language name and left and right arrow on spacebar. + // Layout locale language name on spacebar. private static String layoutSpacebar(Paint paint, Locale locale, int width, float origTextSize) { final Rect bounds = new Rect(); diff --git a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java index 42111822d..f5778167a 100644 --- a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java +++ b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java @@ -46,8 +46,8 @@ public class SubtypeSwitcher { private static boolean DBG = LatinImeLogger.sDBG; private static final String TAG = SubtypeSwitcher.class.getSimpleName(); + public static final String KEYBOARD_MODE = "keyboard"; private static final char LOCALE_SEPARATER = '_'; - private static final String KEYBOARD_MODE = "keyboard"; private static final String VOICE_MODE = "voice"; private static final String SUBTYPE_EXTRAVALUE_REQUIRE_NETWORK_CONNECTIVITY = "requireNetworkConnectivity"; diff --git a/java/src/com/android/inputmethod/latin/Utils.java b/java/src/com/android/inputmethod/latin/Utils.java index 38148438b..8e0cfa122 100644 --- a/java/src/com/android/inputmethod/latin/Utils.java +++ b/java/src/com/android/inputmethod/latin/Utils.java @@ -154,10 +154,21 @@ public class Utils { } } - return filteredImisCount > 1 - // imm.getEnabledInputMethodSubtypeList(null, false) will return the current IME's enabled - // input method subtype (The current IME should be LatinIME.) - || imm.getEnabledInputMethodSubtypeList(null, false).size() > 1; + if (filteredImisCount > 1) { + return true; + } + final List<InputMethodSubtypeCompatWrapper> subtypes = + imm.getEnabledInputMethodSubtypeList(null, true); + int keyboardCount = 0; + // imm.getEnabledInputMethodSubtypeList(null, true) will return the current IME's + // both explicitly and implicitly enabled input method subtype. + // (The current IME should be LatinIME.) + for (InputMethodSubtypeCompatWrapper subtype : subtypes) { + if (SubtypeSwitcher.KEYBOARD_MODE.equals(subtype.getMode())) { + ++keyboardCount; + } + } + return keyboardCount > 1; } public static String getInputMethodId(InputMethodManagerCompatWrapper imm, String packageName) { diff --git a/tests/src/com/android/inputmethod/latin/SubtypeLocaleTests.java b/tests/src/com/android/inputmethod/latin/SubtypeLocaleTests.java index fec3e8ee1..7925d1a49 100644 --- a/tests/src/com/android/inputmethod/latin/SubtypeLocaleTests.java +++ b/tests/src/com/android/inputmethod/latin/SubtypeLocaleTests.java @@ -16,10 +16,7 @@ package com.android.inputmethod.latin; -import com.android.inputmethod.latin.LocaleUtils; - import android.content.Context; -import android.content.res.Resources; import android.test.AndroidTestCase; import android.view.inputmethod.InputMethodInfo; import android.view.inputmethod.InputMethodManager; @@ -30,24 +27,22 @@ import java.util.List; import java.util.Locale; public class SubtypeLocaleTests extends AndroidTestCase { - private static final String PACKAGE = LatinIME.class.getPackage().getName(); - - private Resources mRes; - private List<InputMethodSubtype> mKeyboardSubtypes = new ArrayList<InputMethodSubtype>(); + private List<InputMethodSubtype> mKeyboardSubtypes; @Override protected void setUp() throws Exception { super.setUp(); final Context context = getContext(); - mRes = context.getResources(); + final String packageName = context.getApplicationInfo().packageName; SubtypeLocale.init(context); final InputMethodManager imm = (InputMethodManager) context.getSystemService( Context.INPUT_METHOD_SERVICE); for (final InputMethodInfo imi : imm.getInputMethodList()) { - if (imi.getPackageName().equals(PACKAGE)) { + if (imi.getPackageName().equals(packageName)) { + mKeyboardSubtypes = new ArrayList<InputMethodSubtype>(); final int subtypeCount = imi.getSubtypeCount(); for (int i = 0; i < subtypeCount; ++i) { InputMethodSubtype subtype = imi.getSubtypeAt(i); @@ -58,37 +53,29 @@ public class SubtypeLocaleTests extends AndroidTestCase { break; } } - assertNotNull("Can not find input method " + PACKAGE, mKeyboardSubtypes); + assertNotNull("Can not find input method " + packageName, mKeyboardSubtypes); assertTrue("Can not find keyboard subtype", mKeyboardSubtypes.size() > 0); } - private String getStringWithLocale(int resId, Locale locale) { - final Locale savedLocale = Locale.getDefault(); - try { - Locale.setDefault(locale); - return mRes.getString(resId); - } finally { - Locale.setDefault(savedLocale); - } - } - public void testSubtypeLocale() { final StringBuilder messages = new StringBuilder(); int failedCount = 0; for (final InputMethodSubtype subtype : mKeyboardSubtypes) { - final String localeCode = subtype.getLocale(); - final Locale locale = LocaleUtils.constructLocaleFromString(localeCode); - // The locale name which will be displayed on spacebar. For example 'English (US)' or - // 'Francais (Canada)'. (c=\u008d) - final String displayName = SubtypeLocale.getFullDisplayName(locale); - // The subtype name in its locale. For example 'English (US) Keyboard' or - // 'Clavier Francais (Canada)'. (c=\u008d) - final String subtypeName = getStringWithLocale(subtype.getNameResId(), locale); - if (subtypeName.contains(displayName)) { + final Locale locale = LocaleUtils.constructLocaleFromString(subtype.getLocale()); + final String subtypeLocaleString = + subtype.containsExtraValueKey(LatinIME.SUBTYPE_EXTRA_VALUE_KEYBOARD_LOCALE) + ? subtype.getExtraValueOf(LatinIME.SUBTYPE_EXTRA_VALUE_KEYBOARD_LOCALE) + : subtype.getLocale(); + final Locale subtypeLocale = LocaleUtils.constructLocaleFromString(subtypeLocaleString); + // The subtype name in its locale. For example 'English (US)' or 'Deutsch (QWERTY)'. + final String subtypeName = SubtypeLocale.getFullDisplayName(subtypeLocale); + // The locale language name in its locale. + final String languageName = locale.getDisplayLanguage(locale); + if (!subtypeName.contains(languageName)) { failedCount++; messages.append(String.format( - "subtype name is '%s' and should contain locale '%s' name '%s'\n", - subtypeName, localeCode, displayName)); + "subtype name is '%s' and should contain locale '%s' language name '%s'\n", + subtypeName, subtypeLocale, languageName)); } } assertEquals(messages.toString(), 0, failedCount); diff --git a/tests/src/com/android/inputmethod/latin/UserBigramSuggestTests.java b/tests/src/com/android/inputmethod/latin/UserBigramSuggestTests.java index 2bc0aabc0..b7ba9c759 100644 --- a/tests/src/com/android/inputmethod/latin/UserBigramSuggestTests.java +++ b/tests/src/com/android/inputmethod/latin/UserBigramSuggestTests.java @@ -23,7 +23,7 @@ import com.android.inputmethod.latin.tests.R; import java.util.Locale; public class UserBigramSuggestTests extends SuggestTestsBase { - private static final int SUGGESTION_STARTS = 6; + private static final int SUGGESTION_STARTS = 1; private static final int MAX_DATA = 20; private static final int DELETE_DATA = 10; |