aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2012-11-19 11:25:30 +0900
committerTadashi G. Takaoka <takaoka@google.com>2012-11-19 15:39:44 +0900
commit76d4ffeebfd084913a8c1b7433dff48f5b2063df (patch)
tree1e14d121b810a1447792e93eb5a5b3e58fb92c93 /java
parent9904c9ebbddb04cb770fb9b4f891514851b07f93 (diff)
downloadlatinime-76d4ffeebfd084913a8c1b7433dff48f5b2063df.tar.gz
latinime-76d4ffeebfd084913a8c1b7433dff48f5b2063df.tar.xz
latinime-76d4ffeebfd084913a8c1b7433dff48f5b2063df.zip
Add Spanish United States keyboard
The subtype locale name on the spacebar will be suppressed when only one subtype is enabled and - Subtype locale is equal to the system locale. or - Subtype language is equal to the system language but the subtype is implicitly enabled. Thus the "es_ES" system locale chooses "es" subtype keyboard implicitly but the keyboard doesn't have the subtype name on its spacebar. This change also removes Spanish Latin America keyboard. Bug: 7531804 Change-Id: Ib929e8235d643c0ba039eb010e18ab721a734e15
Diffstat (limited to 'java')
-rw-r--r--java/res/values/donottranslate.xml2
-rw-r--r--java/res/xml/method.xml14
-rw-r--r--java/src/com/android/inputmethod/keyboard/MainKeyboardView.java25
-rw-r--r--java/src/com/android/inputmethod/latin/AdditionalSubtypeSettings.java8
-rw-r--r--java/src/com/android/inputmethod/latin/RichInputMethodManager.java34
-rw-r--r--java/src/com/android/inputmethod/latin/SubtypeLocale.java25
-rw-r--r--java/src/com/android/inputmethod/latin/SubtypeSwitcher.java7
7 files changed, 78 insertions, 37 deletions
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 @@
<string-array name="subtype_locale_exception_keys">
<item>en_US</item>
<item>en_GB</item>
+ <item>es_US</item>
</string-array>
<string-array name="subtype_locale_exception_values">
<item>English (US)</item>
<item>English (UK)</item>
+ <item>Español (EE.UU.)</item>
</string-array>
<!-- Generic subtype label -->
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
@@ -186,11 +187,20 @@
/>
<subtype android:icon="@drawable/ic_subtype_keyboard"
android:label="@string/subtype_generic"
+ android:subtypeId="0x84d2efc6"
+ android:imeSubtypeLocale="es_US"
+ android:imeSubtypeMode="keyboard"
+ android:imeSubtypeExtraValue="KeyboardLayoutSet=spanish,AsciiCapable"
+ />
+ <!--
+ <subtype android:icon="@drawable/ic_subtype_keyboard"
+ android:label="@string/subtype_generic"
android:subtypeId="0x623f9286"
android:imeSubtypeLocale="es_419"
android:imeSubtypeMode="keyboard"
- android:imeSubtypeExtraValue="KeyboardLayoutSet=qwerty,AsciiCapable"
+ android:imeSubtypeExtraValue="KeyboardLayoutSet=spanish,AsciiCapable"
/>
+ -->
<subtype android:icon="@drawable/ic_subtype_keyboard"
android:label="@string/subtype_generic"
android:subtypeId="0xec2d3955"
diff --git a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
index e60a8a942..d5f40ad36 100644
--- a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
@@ -1029,18 +1029,19 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
// InputMethodSubtype's display name for spacebar text in its locale.
// isAdditionalSubtype (T=true, F=false)
- // locale layout | Short Middle Full
- // ------ ------ - ---- --------- ----------------------
- // en_US qwerty F En English English (US) exception
- // en_GB qwerty F En English English (UK) exception
- // fr azerty F Fr Français Français
- // fr_CA qwerty F Fr Français Français (Canada)
- // de qwertz F De Deutsch Deutsch
- // zz qwerty F QWERTY QWERTY
- // fr qwertz T Fr Français Français (QWERTZ)
- // de qwerty T De Deutsch Deutsch (QWERTY)
- // en_US azerty T En English English (US) (AZERTY)
- // zz azerty T AZERTY AZERTY
+ // locale layout | Short Middle Full
+ // ------ ------- - ---- --------- ----------------------
+ // en_US qwerty F En English English (US) exception
+ // en_GB qwerty F En English English (UK) exception
+ // es_US spanish F Es Español Español (EE.UU.) exception
+ // fr azerty F Fr Français Français
+ // fr_CA qwerty F Fr Français Français (Canada)
+ // de qwertz F De Deutsch Deutsch
+ // zz qwerty F QWERTY QWERTY
+ // fr qwertz T Fr Français Français (QWERTZ)
+ // de qwerty T De Deutsch Deutsch (QWERTY)
+ // en_US azerty T En English English (US) (AZERTY)
+ // zz azerty T AZERTY AZERTY
// Get InputMethodSubtype's full display name in its locale.
static String getFullDisplayName(final InputMethodSubtype subtype, final Resources res) {
diff --git a/java/src/com/android/inputmethod/latin/AdditionalSubtypeSettings.java b/java/src/com/android/inputmethod/latin/AdditionalSubtypeSettings.java
index a071bc9fb..96c08b3cd 100644
--- a/java/src/com/android/inputmethod/latin/AdditionalSubtypeSettings.java
+++ b/java/src/com/android/inputmethod/latin/AdditionalSubtypeSettings.java
@@ -87,6 +87,9 @@ public final class AdditionalSubtypeSettings extends PreferenceFragment {
}
static final class SubtypeLocaleAdapter extends ArrayAdapter<SubtypeLocaleItem> {
+ 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<InputMethodSubtype> 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<InputMethodSubtype> 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;