diff --git a/java/res/values/donottranslate.xml b/java/res/values/donottranslate.xml
index 9e07b2248..8db436bef 100644
--- a/java/res/values/donottranslate.xml
+++ b/java/res/values/donottranslate.xml
@@ -140,10 +140,12 @@
- en_US
- en_GB
+ - es_US
- English (US)
- English (UK)
+ - Español (EE.UU.)
diff --git a/java/res/xml/method.xml b/java/res/xml/method.xml
index 4ba52d9fa..aa59c577c 100644
--- a/java/res/xml/method.xml
+++ b/java/res/xml/method.xml
@@ -36,7 +36,8 @@
en_GB: English Great Britain/qwerty
eo: Esperanto/spanish
es: Spanish/spanish
- es_419: Spanish Latin America/qwerty
+ es_US: Spanish United States/spanish
+ (es_419: Spanish Latin America/qwerty)
et: Estonian/nordic
fa: Persian/arabic
fi: Finnish/nordic
@@ -184,13 +185,22 @@
android:imeSubtypeMode="keyboard"
android:imeSubtypeExtraValue="AsciiCapable,SupportTouchPositionCorrection"
/>
+
+
{
+ private static final String TAG = SubtypeLocaleAdapter.class.getSimpleName();
+ private static final boolean DEBUG_SUBTYPE_ID = false;
+
public SubtypeLocaleAdapter(final Context context) {
super(context, android.R.layout.simple_spinner_item);
setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
@@ -97,6 +100,11 @@ public final class AdditionalSubtypeSettings extends PreferenceFragment {
final int count = imi.getSubtypeCount();
for (int i = 0; i < count; i++) {
final InputMethodSubtype subtype = imi.getSubtypeAt(i);
+ if (DEBUG_SUBTYPE_ID) {
+ android.util.Log.d(TAG, String.format("%-6s 0x%08x %11d %s",
+ subtype.getLocale(), subtype.hashCode(), subtype.hashCode(),
+ SubtypeLocale.getSubtypeDisplayName(subtype, context.getResources())));
+ }
if (subtype.containsExtraValueKey(ASCII_CAPABLE)) {
items.add(createItem(context, subtype.getLocale()));
}
diff --git a/java/src/com/android/inputmethod/latin/RichInputMethodManager.java b/java/src/com/android/inputmethod/latin/RichInputMethodManager.java
index b3832303d..63dfd3250 100644
--- a/java/src/com/android/inputmethod/latin/RichInputMethodManager.java
+++ b/java/src/com/android/inputmethod/latin/RichInputMethodManager.java
@@ -96,28 +96,42 @@ public final class RichInputMethodManager {
return mInputMethodInfoOfThisIme.getId();
}
- public boolean checkIfSubtypeBelongsToThisImeAndEnabled(final InputMethodSubtype ims) {
- return checkIfSubtypeBelongsToImeAndEnabled(mInputMethodInfoOfThisIme, ims);
+ public boolean checkIfSubtypeBelongsToThisImeAndEnabled(final InputMethodSubtype subtype) {
+ return checkIfSubtypeBelongsToImeAndEnabled(mInputMethodInfoOfThisIme, subtype);
+ }
+
+ public boolean checkIfSubtypeBelongsToThisImeAndImplicitlyEnabled(
+ final InputMethodSubtype subtype) {
+ final boolean subtypeEnabled = checkIfSubtypeBelongsToThisImeAndEnabled(subtype);
+ final boolean subtypeExplicitlyEnabled = checkIfSubtypeBelongsToList(
+ subtype, mImmWrapper.mImm.getEnabledInputMethodSubtypeList(
+ mInputMethodInfoOfThisIme, false /* allowsImplicitlySelectedSubtypes */));
+ return subtypeEnabled && !subtypeExplicitlyEnabled;
}
public boolean checkIfSubtypeBelongsToImeAndEnabled(final InputMethodInfo imi,
- final InputMethodSubtype ims) {
- final List subtypes = mImmWrapper.mImm.getEnabledInputMethodSubtypeList(
- imi, true /* allowsImplicitlySelectedSubtypes */);
- for (final InputMethodSubtype subtype : subtypes) {
- if (subtype.equals(ims)) {
+ final InputMethodSubtype subtype) {
+ return checkIfSubtypeBelongsToList(
+ subtype, mImmWrapper.mImm.getEnabledInputMethodSubtypeList(
+ imi, true /* allowsImplicitlySelectedSubtypes */));
+ }
+
+ private static boolean checkIfSubtypeBelongsToList(final InputMethodSubtype subtype,
+ final List subtypes) {
+ for (final InputMethodSubtype ims : subtypes) {
+ if (ims.equals(subtype)) {
return true;
}
}
return false;
}
- public boolean checkIfSubtypeBelongsToThisIme(final InputMethodSubtype ims) {
+ public boolean checkIfSubtypeBelongsToThisIme(final InputMethodSubtype subtype) {
final InputMethodInfo myImi = mInputMethodInfoOfThisIme;
final int count = myImi.getSubtypeCount();
for (int i = 0; i < count; i++) {
- final InputMethodSubtype subtype = myImi.getSubtypeAt(i);
- if (subtype.equals(ims)) {
+ final InputMethodSubtype ims = myImi.getSubtypeAt(i);
+ if (ims.equals(subtype)) {
return true;
}
}
diff --git a/java/src/com/android/inputmethod/latin/SubtypeLocale.java b/java/src/com/android/inputmethod/latin/SubtypeLocale.java
index 579f96bb4..5d8c0b17d 100644
--- a/java/src/com/android/inputmethod/latin/SubtypeLocale.java
+++ b/java/src/com/android/inputmethod/latin/SubtypeLocale.java
@@ -151,18 +151,19 @@ public final class SubtypeLocale {
// InputMethodSubtype's display name in its locale.
// isAdditionalSubtype (T=true, F=false)
- // locale layout | display name
- // ------ ------ - ----------------------
- // en_US qwerty F English (US) exception
- // en_GB qwerty F English (UK) exception
- // fr azerty F Français
- // fr_CA qwerty F Français (Canada)
- // de qwertz F Deutsch
- // zz qwerty F No language (QWERTY) in system locale
- // fr qwertz T Français (QWERTZ)
- // de qwerty T Deutsch (QWERTY)
- // en_US azerty T English (US) (AZERTY)
- // zz azerty T No language (AZERTY) in system locale
+ // locale layout | display name
+ // ------ ------- - ----------------------
+ // en_US qwerty F English (US) exception
+ // en_GB qwerty F English (UK) exception
+ // es_US spanish F Español (EE.UU.) exception
+ // fr azerty F Français
+ // fr_CA qwerty F Français (Canada)
+ // de qwertz F Deutsch
+ // zz qwerty F No language (QWERTY) in system locale
+ // fr qwertz T Français (QWERTZ)
+ // de qwerty T Deutsch (QWERTY)
+ // en_US azerty T English (US) (AZERTY)
+ // zz azerty T No language (AZERTY) in system locale
public static String getSubtypeDisplayName(final InputMethodSubtype subtype, Resources res) {
final String replacementString = (Build.VERSION.SDK_INT >= /* JELLY_BEAN */ 15
diff --git a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java
index 0f339eb3b..8f2e27549 100644
--- a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java
+++ b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java
@@ -193,8 +193,13 @@ public final class SubtypeSwitcher {
}
final Locale newLocale = SubtypeLocale.getSubtypeLocale(newSubtype);
+ final boolean sameLocale = mCurrentSystemLocale.equals(newLocale);
+ final boolean sameLanguage = mCurrentSystemLocale.getLanguage().equals(
+ newLocale.getLanguage());
+ final boolean implicitlyEnabled =
+ mRichImm.checkIfSubtypeBelongsToThisImeAndImplicitlyEnabled(newSubtype);
mNeedsToDisplayLanguage.updateIsSystemLanguageSameAsInputLanguage(
- mCurrentSystemLocale.equals(newLocale));
+ sameLocale || (sameLanguage && implicitlyEnabled));
if (newSubtype.equals(mCurrentSubtype)) return;
diff --git a/tests/src/com/android/inputmethod/latin/SubtypeLocaleTests.java b/tests/src/com/android/inputmethod/latin/SubtypeLocaleTests.java
index 0a48f0d8b..4e81de668 100644
--- a/tests/src/com/android/inputmethod/latin/SubtypeLocaleTests.java
+++ b/tests/src/com/android/inputmethod/latin/SubtypeLocaleTests.java
@@ -59,24 +59,27 @@ public class SubtypeLocaleTests extends AndroidTestCase {
// InputMethodSubtype's display name in its locale.
// isAdditionalSubtype (T=true, F=false)
- // locale layout | display name
- // ------ ------ - ----------------------
- // en_US qwerty F English (US) exception
- // en_GB qwerty F English (UK) exception
- // fr azerty F Français
- // fr_CA qwerty F Français (Canada)
- // de qwertz F Deutsch
- // zz qwerty F No language (QWERTY) in system locale
- // fr qwertz T Français (QWERTZ)
- // de qwerty T Deutsch (QWERTY)
- // en_US azerty T English (US) (AZERTY)
- // zz azerty T No language (AZERTY) in system locale
+ // locale layout | display name
+ // ------ ------- - ----------------------
+ // en_US qwerty F English (US) exception
+ // en_GB qwerty F English (UK) exception
+ // es_US spanish F Español (EE.UU.) exception
+ // fr azerty F Français
+ // fr_CA qwerty F Français (Canada)
+ // de qwertz F Deutsch
+ // zz qwerty F No language (QWERTY) in system locale
+ // fr qwertz T Français (QWERTZ)
+ // de qwerty T Deutsch (QWERTY)
+ // en_US azerty T English (US) (AZERTY)
+ // zz azerty T No language (AZERTY) in system locale
public void testPredefinedSubtypesInEnglish() {
final InputMethodSubtype EN_US = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
Locale.US.toString(), "qwerty");
final InputMethodSubtype EN_GB = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
Locale.UK.toString(), "qwerty");
+ final InputMethodSubtype ES_US = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
+ "es_US", "spanish");
final InputMethodSubtype FR = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
Locale.FRENCH.toString(), "azerty");
final InputMethodSubtype FR_CA = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
@@ -88,6 +91,7 @@ public class SubtypeLocaleTests extends AndroidTestCase {
assertEquals("en_US", "qwerty", SubtypeLocale.getKeyboardLayoutSetName(EN_US));
assertEquals("en_GB", "qwerty", SubtypeLocale.getKeyboardLayoutSetName(EN_GB));
+ assertEquals("es_US", "spanish", SubtypeLocale.getKeyboardLayoutSetName(ES_US));
assertEquals("fr ", "azerty", SubtypeLocale.getKeyboardLayoutSetName(FR));
assertEquals("fr_CA", "qwerty", SubtypeLocale.getKeyboardLayoutSetName(FR_CA));
assertEquals("de ", "qwertz", SubtypeLocale.getKeyboardLayoutSetName(DE));
@@ -100,6 +104,8 @@ public class SubtypeLocaleTests extends AndroidTestCase {
SubtypeLocale.getSubtypeDisplayName(EN_US, res));
assertEquals("en_GB", "English (UK)",
SubtypeLocale.getSubtypeDisplayName(EN_GB, res));
+ assertEquals("es_US", "Español (EE.UU.)",
+ SubtypeLocale.getSubtypeDisplayName(ES_US, res));
assertEquals("fr ", "Français",
SubtypeLocale.getSubtypeDisplayName(FR, res));
assertEquals("fr_CA", "Français (Canada)",
@@ -146,6 +152,8 @@ public class SubtypeLocaleTests extends AndroidTestCase {
Locale.US.toString(), "qwerty");
final InputMethodSubtype EN_GB = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
Locale.UK.toString(), "qwerty");
+ final InputMethodSubtype ES_US = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
+ "es_US", "spanish");
final InputMethodSubtype FR = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
Locale.FRENCH.toString(), "azerty");
final InputMethodSubtype FR_CA = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
@@ -162,6 +170,8 @@ public class SubtypeLocaleTests extends AndroidTestCase {
SubtypeLocale.getSubtypeDisplayName(EN_US, res));
assertEquals("en_GB", "English (UK)",
SubtypeLocale.getSubtypeDisplayName(EN_GB, res));
+ assertEquals("es_US", "Español (EE.UU.)",
+ SubtypeLocale.getSubtypeDisplayName(ES_US, res));
assertEquals("fr ", "Français",
SubtypeLocale.getSubtypeDisplayName(FR, res));
assertEquals("fr_CA", "Français (Canada)",