Revert "[ML1] Introduce RichInputMethodSubtype"

This reverts commit 8ffe4bc932.

Change-Id: I9d4c98b0adfdb78b0f4d376f7691e50d1bd2228f
main
Jean Chalard 2014-08-22 09:40:27 +00:00
parent 8ffe4bc932
commit a63d0a8ee6
18 changed files with 282 additions and 352 deletions

View File

@ -121,7 +121,7 @@ public final class MainKeyboardAccessibilityDelegate
*/ */
private void announceKeyboardLanguage(final Keyboard keyboard) { private void announceKeyboardLanguage(final Keyboard keyboard) {
final String languageText = SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale( final String languageText = SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(
keyboard.mId.mSubtype.getRawSubtype()); keyboard.mId.mSubtype);
sendWindowStateChanged(languageText); sendWindowStateChanged(languageText);
} }

View File

@ -20,7 +20,7 @@ import android.os.Build;
import android.view.inputmethod.InputMethodSubtype; import android.view.inputmethod.InputMethodSubtype;
import com.android.inputmethod.annotations.UsedForTesting; import com.android.inputmethod.annotations.UsedForTesting;
import com.android.inputmethod.latin.RichInputMethodSubtype; import com.android.inputmethod.latin.Constants;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.Method; import java.lang.reflect.Method;
@ -64,12 +64,9 @@ public final class InputMethodSubtypeCompatUtils {
overridesImplicitlyEnabledSubtype, id); overridesImplicitlyEnabledSubtype, id);
} }
public static boolean isAsciiCapable(final RichInputMethodSubtype subtype) {
return isAsciiCapable(subtype.getRawSubtype());
}
public static boolean isAsciiCapable(final InputMethodSubtype subtype) { public static boolean isAsciiCapable(final InputMethodSubtype subtype) {
return InputMethodSubtypeCompatUtils.isAsciiCapableWithAPI(subtype); return isAsciiCapableWithAPI(subtype)
|| subtype.containsExtraValueKey(Constants.Subtype.ExtraValue.ASCII_CAPABLE);
} }
@UsedForTesting @UsedForTesting

View File

@ -21,9 +21,9 @@ import static com.android.inputmethod.latin.Constants.Subtype.ExtraValue.KEYBOAR
import android.text.InputType; import android.text.InputType;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodSubtype;
import com.android.inputmethod.compat.EditorInfoCompatUtils; import com.android.inputmethod.compat.EditorInfoCompatUtils;
import com.android.inputmethod.latin.RichInputMethodSubtype;
import com.android.inputmethod.latin.utils.InputTypeUtils; import com.android.inputmethod.latin.utils.InputTypeUtils;
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils; import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
@ -62,7 +62,7 @@ public final class KeyboardId {
public static final int ELEMENT_EMOJI_CATEGORY5 = 15; public static final int ELEMENT_EMOJI_CATEGORY5 = 15;
public static final int ELEMENT_EMOJI_CATEGORY6 = 16; public static final int ELEMENT_EMOJI_CATEGORY6 = 16;
public final RichInputMethodSubtype mSubtype; public final InputMethodSubtype mSubtype;
public final Locale mLocale; public final Locale mLocale;
public final int mWidth; public final int mWidth;
public final int mHeight; public final int mHeight;

View File

@ -28,6 +28,7 @@ import android.util.Log;
import android.util.SparseArray; import android.util.SparseArray;
import android.util.Xml; import android.util.Xml;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodSubtype;
import com.android.inputmethod.compat.EditorInfoCompatUtils; import com.android.inputmethod.compat.EditorInfoCompatUtils;
import com.android.inputmethod.compat.InputMethodSubtypeCompatUtils; import com.android.inputmethod.compat.InputMethodSubtypeCompatUtils;
@ -36,7 +37,6 @@ import com.android.inputmethod.keyboard.internal.KeyboardParams;
import com.android.inputmethod.keyboard.internal.KeysCache; import com.android.inputmethod.keyboard.internal.KeysCache;
import com.android.inputmethod.latin.InputAttributes; import com.android.inputmethod.latin.InputAttributes;
import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.RichInputMethodSubtype;
import com.android.inputmethod.latin.SubtypeSwitcher; import com.android.inputmethod.latin.SubtypeSwitcher;
import com.android.inputmethod.latin.define.DebugFlags; import com.android.inputmethod.latin.define.DebugFlags;
import com.android.inputmethod.latin.utils.InputTypeUtils; import com.android.inputmethod.latin.utils.InputTypeUtils;
@ -109,7 +109,7 @@ public final class KeyboardLayoutSet {
boolean mVoiceInputKeyEnabled; boolean mVoiceInputKeyEnabled;
boolean mNoSettingsKey; boolean mNoSettingsKey;
boolean mLanguageSwitchKeyEnabled; boolean mLanguageSwitchKeyEnabled;
RichInputMethodSubtype mSubtype; InputMethodSubtype mSubtype;
boolean mIsSpellChecker; boolean mIsSpellChecker;
int mKeyboardWidth; int mKeyboardWidth;
int mKeyboardHeight; int mKeyboardHeight;
@ -245,7 +245,7 @@ public final class KeyboardLayoutSet {
return this; return this;
} }
public Builder setSubtype(final RichInputMethodSubtype subtype) { public Builder setSubtype(final InputMethodSubtype subtype) {
final boolean asciiCapable = InputMethodSubtypeCompatUtils.isAsciiCapable(subtype); final boolean asciiCapable = InputMethodSubtypeCompatUtils.isAsciiCapable(subtype);
// TODO: Consolidate with {@link InputAttributes}. // TODO: Consolidate with {@link InputAttributes}.
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@ -254,7 +254,7 @@ public final class KeyboardLayoutSet {
final boolean forceAscii = EditorInfoCompatUtils.hasFlagForceAscii( final boolean forceAscii = EditorInfoCompatUtils.hasFlagForceAscii(
mParams.mEditorInfo.imeOptions) mParams.mEditorInfo.imeOptions)
|| deprecatedForceAscii; || deprecatedForceAscii;
final RichInputMethodSubtype keyboardSubtype = (forceAscii && !asciiCapable) final InputMethodSubtype keyboardSubtype = (forceAscii && !asciiCapable)
? SubtypeSwitcher.getInstance().getNoLanguageSubtype() ? SubtypeSwitcher.getInstance().getNoLanguageSubtype()
: subtype; : subtype;
mParams.mSubtype = keyboardSubtype; mParams.mSubtype = keyboardSubtype;

View File

@ -34,6 +34,7 @@ import android.view.LayoutInflater;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.inputmethod.InputMethodSubtype;
import com.android.inputmethod.accessibility.AccessibilityUtils; import com.android.inputmethod.accessibility.AccessibilityUtils;
import com.android.inputmethod.accessibility.MainKeyboardAccessibilityDelegate; import com.android.inputmethod.accessibility.MainKeyboardAccessibilityDelegate;
@ -53,10 +54,10 @@ import com.android.inputmethod.keyboard.internal.SlidingKeyInputDrawingPreview;
import com.android.inputmethod.keyboard.internal.TimerHandler; import com.android.inputmethod.keyboard.internal.TimerHandler;
import com.android.inputmethod.latin.Constants; import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.RichInputMethodSubtype;
import com.android.inputmethod.latin.SuggestedWords; import com.android.inputmethod.latin.SuggestedWords;
import com.android.inputmethod.latin.settings.DebugSettings; import com.android.inputmethod.latin.settings.DebugSettings;
import com.android.inputmethod.latin.utils.CoordinateUtils; import com.android.inputmethod.latin.utils.CoordinateUtils;
import com.android.inputmethod.latin.utils.SpacebarLanguageUtils;
import com.android.inputmethod.latin.utils.TypefaceUtils; import com.android.inputmethod.latin.utils.TypefaceUtils;
import java.util.WeakHashMap; import java.util.WeakHashMap;
@ -848,16 +849,16 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
// Layout language name on spacebar. // Layout language name on spacebar.
private String layoutLanguageOnSpacebar(final Paint paint, private String layoutLanguageOnSpacebar(final Paint paint,
final RichInputMethodSubtype subtype, final int width) { final InputMethodSubtype subtype, final int width) {
// Choose appropriate language name to fit into the width. // Choose appropriate language name to fit into the width.
if (mLanguageOnSpacebarFormatType == LanguageOnSpacebarHelper.FORMAT_TYPE_FULL_LOCALE) { if (mLanguageOnSpacebarFormatType == LanguageOnSpacebarHelper.FORMAT_TYPE_FULL_LOCALE) {
final String fullText = subtype.getFullDisplayName(); final String fullText = SpacebarLanguageUtils.getFullDisplayName(subtype);
if (fitsTextIntoWidth(width, fullText, paint)) { if (fitsTextIntoWidth(width, fullText, paint)) {
return fullText; return fullText;
} }
} }
final String middleText = subtype.getMiddleDisplayName(); final String middleText = SpacebarLanguageUtils.getMiddleDisplayName(subtype);
if (fitsTextIntoWidth(width, middleText, paint)) { if (fitsTextIntoWidth(width, middleText, paint)) {
return middleText; return middleText;
} }
@ -871,7 +872,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
paint.setTextAlign(Align.CENTER); paint.setTextAlign(Align.CENTER);
paint.setTypeface(Typeface.DEFAULT); paint.setTypeface(Typeface.DEFAULT);
paint.setTextSize(mLanguageOnSpacebarTextSize); paint.setTextSize(mLanguageOnSpacebarTextSize);
final RichInputMethodSubtype subtype = getKeyboard().mId.mSubtype; final InputMethodSubtype subtype = getKeyboard().mId.mSubtype;
final String language = layoutLanguageOnSpacebar(paint, subtype, width); final String language = layoutLanguageOnSpacebar(paint, subtype, width);
// Draw language text with shadow // Draw language text with shadow
final float descent = paint.descent(); final float descent = paint.descent();

View File

@ -18,7 +18,6 @@ package com.android.inputmethod.keyboard.internal;
import android.view.inputmethod.InputMethodSubtype; import android.view.inputmethod.InputMethodSubtype;
import com.android.inputmethod.latin.RichInputMethodSubtype;
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils; import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
import java.util.Collections; import java.util.Collections;
@ -35,8 +34,8 @@ public final class LanguageOnSpacebarHelper {
private List<InputMethodSubtype> mEnabledSubtypes = Collections.emptyList(); private List<InputMethodSubtype> mEnabledSubtypes = Collections.emptyList();
private boolean mIsSystemLanguageSameAsInputLanguage; private boolean mIsSystemLanguageSameAsInputLanguage;
public int getLanguageOnSpacebarFormatType(final RichInputMethodSubtype subtype) { public int getLanguageOnSpacebarFormatType(final InputMethodSubtype subtype) {
if (subtype.isNoLanguage()) { if (SubtypeLocaleUtils.isNoLanguage(subtype)) {
return FORMAT_TYPE_FULL_LOCALE; return FORMAT_TYPE_FULL_LOCALE;
} }
// Only this subtype is enabled and equals to the system locale. // Only this subtype is enabled and equals to the system locale.

View File

@ -747,8 +747,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
public void onCurrentInputMethodSubtypeChanged(final InputMethodSubtype subtype) { public void onCurrentInputMethodSubtypeChanged(final InputMethodSubtype subtype) {
// Note that the calling sequence of onCreate() and onCurrentInputMethodSubtypeChanged() // Note that the calling sequence of onCreate() and onCurrentInputMethodSubtypeChanged()
// is not guaranteed. It may even be called at the same time on a different thread. // is not guaranteed. It may even be called at the same time on a different thread.
final RichInputMethodSubtype richSubtype = new RichInputMethodSubtype(subtype); mSubtypeSwitcher.onSubtypeChanged(subtype);
mSubtypeSwitcher.onSubtypeChanged(richSubtype);
mInputLogic.onSubtypeChanged(SubtypeLocaleUtils.getCombiningRulesExtraValue(subtype)); mInputLogic.onSubtypeChanged(SubtypeLocaleUtils.getCombiningRulesExtraValue(subtype));
loadKeyboard(); loadKeyboard();
} }

View File

@ -297,14 +297,10 @@ public final class RichInputMethodManager {
return INDEX_NOT_FOUND; return INDEX_NOT_FOUND;
} }
public RichInputMethodSubtype getCurrentInputMethodSubtype( public InputMethodSubtype getCurrentInputMethodSubtype(
final RichInputMethodSubtype defaultSubtype) { final InputMethodSubtype defaultSubtype) {
final InputMethodSubtype currentSubtype = mImmWrapper.mImm.getCurrentInputMethodSubtype(); final InputMethodSubtype currentSubtype = mImmWrapper.mImm.getCurrentInputMethodSubtype();
if (currentSubtype == null) { return (currentSubtype != null) ? currentSubtype : defaultSubtype;
return defaultSubtype;
}
// TODO: Determine locales to use for multi-lingual use.
return new RichInputMethodSubtype(currentSubtype);
} }
public boolean hasMultipleEnabledIMEsOrSubtypes(final boolean shouldIncludeAuxiliarySubtypes) { public boolean hasMultipleEnabledIMEsOrSubtypes(final boolean shouldIncludeAuxiliarySubtypes) {

View File

@ -1,125 +0,0 @@
/*
* Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.inputmethod.latin;
import android.view.inputmethod.InputMethodSubtype;
import com.android.inputmethod.latin.utils.LocaleUtils;
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
import java.util.Arrays;
import java.util.Locale;
/**
* Enrichment class for InputMethodSubtype to enable concurrent multi-lingual input.
*
* Right now, this returns the extra value of its primary subtype.
*/
public final class RichInputMethodSubtype {
private final InputMethodSubtype mSubtype;
private final Locale[] mLocales;
public RichInputMethodSubtype(final InputMethodSubtype subtype, final Locale... locales) {
mSubtype = subtype;
mLocales = new Locale[locales.length+1];
mLocales[0] = LocaleUtils.constructLocaleFromString(mSubtype.getLocale());
System.arraycopy(locales, 0, mLocales, 1, locales.length);
}
// Extra values are determined by the primary subtype. This is probably right, but
// we may have to revisit this later.
public String getExtraValueOf(final String key) {
return mSubtype.getExtraValueOf(key);
}
// The mode is also determined by the primary subtype.
public String getMode() {
return mSubtype.getMode();
}
public boolean isNoLanguage() {
if (mLocales.length > 1) {
return false;
}
return SubtypeLocaleUtils.NO_LANGUAGE.equals(mSubtype.getLocale());
}
public String getNameForLogging() {
return toString();
}
// InputMethodSubtype's display name for spacebar text in its locale.
// isAdditionalSubtype (T=true, F=false)
// locale layout | Middle Full
// ------ ------- - --------- ----------------------
// en_US qwerty F English English (US) exception
// en_GB qwerty F English English (UK) exception
// es_US spanish F Español Español (EE.UU.) exception
// fr azerty F Français Français
// fr_CA qwerty F Français Français (Canada)
// fr_CH swiss F Français Français (Suisse)
// de qwertz F Deutsch Deutsch
// de_CH swiss T Deutsch Deutsch (Schweiz)
// zz qwerty F QWERTY QWERTY
// fr qwertz T Français Français
// de qwerty T Deutsch Deutsch
// en_US azerty T English English (US)
// zz azerty T AZERTY AZERTY
// Get the RichInputMethodSubtype's full display name in its locale.
public String getFullDisplayName() {
if (isNoLanguage()) {
return SubtypeLocaleUtils.getKeyboardLayoutSetDisplayName(mSubtype);
}
return SubtypeLocaleUtils.getSubtypeLocaleDisplayName(mSubtype.getLocale());
}
// Get the RichInputMethodSubtype's middle display name in its locale.
public String getMiddleDisplayName() {
if (isNoLanguage()) {
return SubtypeLocaleUtils.getKeyboardLayoutSetDisplayName(mSubtype);
}
return SubtypeLocaleUtils.getSubtypeLanguageDisplayName(mSubtype.getLocale());
}
@Override
public boolean equals(Object o) {
if (!(o instanceof RichInputMethodSubtype)) {
return false;
}
final RichInputMethodSubtype other = (RichInputMethodSubtype)o;
return mSubtype.equals(other.mSubtype) && Arrays.equals(mLocales, other.mLocales);
}
@Override
public int hashCode() {
return mSubtype.hashCode() + Arrays.hashCode(mLocales);
}
@Override
public String toString() {
return "Multi-lingual subtype: " + mSubtype.toString() + ", " + Arrays.toString(mLocales);
}
// TODO: remove this method! We can always have several locales. Multi-lingual input will only
// be done when this method is gone.
public String getLocale() {
return mSubtype.getLocale();
}
// TODO: remove this method
public InputMethodSubtype getRawSubtype() { return mSubtype; }
}

View File

@ -58,8 +58,8 @@ public final class SubtypeSwitcher {
new LanguageOnSpacebarHelper(); new LanguageOnSpacebarHelper();
private InputMethodInfo mShortcutInputMethodInfo; private InputMethodInfo mShortcutInputMethodInfo;
private InputMethodSubtype mShortcutSubtype; private InputMethodSubtype mShortcutSubtype;
private RichInputMethodSubtype mNoLanguageSubtype; private InputMethodSubtype mNoLanguageSubtype;
private RichInputMethodSubtype mEmojiSubtype; private InputMethodSubtype mEmojiSubtype;
private boolean mIsNetworkConnected; private boolean mIsNetworkConnected;
private static final String KEYBOARD_MODE = "keyboard"; private static final String KEYBOARD_MODE = "keyboard";
@ -70,26 +70,26 @@ public final class SubtypeSwitcher {
+ "," + Constants.Subtype.ExtraValue.ASCII_CAPABLE + "," + Constants.Subtype.ExtraValue.ASCII_CAPABLE
+ "," + Constants.Subtype.ExtraValue.ENABLED_WHEN_DEFAULT_IS_NOT_ASCII_CAPABLE + "," + Constants.Subtype.ExtraValue.ENABLED_WHEN_DEFAULT_IS_NOT_ASCII_CAPABLE
+ "," + Constants.Subtype.ExtraValue.EMOJI_CAPABLE; + "," + Constants.Subtype.ExtraValue.EMOJI_CAPABLE;
private static final RichInputMethodSubtype DUMMY_NO_LANGUAGE_SUBTYPE = private static final InputMethodSubtype DUMMY_NO_LANGUAGE_SUBTYPE =
new RichInputMethodSubtype(InputMethodSubtypeCompatUtils.newInputMethodSubtype( InputMethodSubtypeCompatUtils.newInputMethodSubtype(
R.string.subtype_no_language_qwerty, R.drawable.ic_ime_switcher_dark, R.string.subtype_no_language_qwerty, R.drawable.ic_ime_switcher_dark,
SubtypeLocaleUtils.NO_LANGUAGE, KEYBOARD_MODE, SubtypeLocaleUtils.NO_LANGUAGE, KEYBOARD_MODE,
EXTRA_VALUE_OF_DUMMY_NO_LANGUAGE_SUBTYPE, EXTRA_VALUE_OF_DUMMY_NO_LANGUAGE_SUBTYPE,
false /* isAuxiliary */, false /* overridesImplicitlyEnabledSubtype */, false /* isAuxiliary */, false /* overridesImplicitlyEnabledSubtype */,
SUBTYPE_ID_OF_DUMMY_NO_LANGUAGE_SUBTYPE)); SUBTYPE_ID_OF_DUMMY_NO_LANGUAGE_SUBTYPE);
// Caveat: We probably should remove this when we add an Emoji subtype in {@link R.xml.method}. // Caveat: We probably should remove this when we add an Emoji subtype in {@link R.xml.method}.
// Dummy Emoji subtype. See {@link R.xml.method}. // Dummy Emoji subtype. See {@link R.xml.method}.
private static final int SUBTYPE_ID_OF_DUMMY_EMOJI_SUBTYPE = 0xd78b2ed0; private static final int SUBTYPE_ID_OF_DUMMY_EMOJI_SUBTYPE = 0xd78b2ed0;
private static final String EXTRA_VALUE_OF_DUMMY_EMOJI_SUBTYPE = private static final String EXTRA_VALUE_OF_DUMMY_EMOJI_SUBTYPE =
"KeyboardLayoutSet=" + SubtypeLocaleUtils.EMOJI "KeyboardLayoutSet=" + SubtypeLocaleUtils.EMOJI
+ "," + Constants.Subtype.ExtraValue.EMOJI_CAPABLE; + "," + Constants.Subtype.ExtraValue.EMOJI_CAPABLE;
private static final RichInputMethodSubtype DUMMY_EMOJI_SUBTYPE = new RichInputMethodSubtype( private static final InputMethodSubtype DUMMY_EMOJI_SUBTYPE =
InputMethodSubtypeCompatUtils.newInputMethodSubtype( InputMethodSubtypeCompatUtils.newInputMethodSubtype(
R.string.subtype_emoji, R.drawable.ic_ime_switcher_dark, R.string.subtype_emoji, R.drawable.ic_ime_switcher_dark,
SubtypeLocaleUtils.NO_LANGUAGE, KEYBOARD_MODE, SubtypeLocaleUtils.NO_LANGUAGE, KEYBOARD_MODE,
EXTRA_VALUE_OF_DUMMY_EMOJI_SUBTYPE, EXTRA_VALUE_OF_DUMMY_EMOJI_SUBTYPE,
false /* isAuxiliary */, false /* overridesImplicitlyEnabledSubtype */, false /* isAuxiliary */, false /* overridesImplicitlyEnabledSubtype */,
SUBTYPE_ID_OF_DUMMY_EMOJI_SUBTYPE)); SUBTYPE_ID_OF_DUMMY_EMOJI_SUBTYPE);
public static SubtypeSwitcher getInstance() { public static SubtypeSwitcher getInstance() {
return sInstance; return sInstance;
@ -165,17 +165,18 @@ public final class SubtypeSwitcher {
} }
// Update the current subtype. LatinIME.onCurrentInputMethodSubtypeChanged calls this function. // Update the current subtype. LatinIME.onCurrentInputMethodSubtypeChanged calls this function.
public void onSubtypeChanged(final RichInputMethodSubtype newSubtype) { public void onSubtypeChanged(final InputMethodSubtype newSubtype) {
if (DBG) { if (DBG) {
Log.w(TAG, "onSubtypeChanged: " + newSubtype.getNameForLogging()); Log.w(TAG, "onSubtypeChanged: "
+ SubtypeLocaleUtils.getSubtypeNameForLogging(newSubtype));
} }
final Locale newLocale = SubtypeLocaleUtils.getSubtypeLocale(newSubtype); final Locale newLocale = SubtypeLocaleUtils.getSubtypeLocale(newSubtype);
final Locale systemLocale = mResources.getConfiguration().locale; final Locale systemLocale = mResources.getConfiguration().locale;
final boolean sameLocale = systemLocale.equals(newLocale); final boolean sameLocale = systemLocale.equals(newLocale);
final boolean sameLanguage = systemLocale.getLanguage().equals(newLocale.getLanguage()); final boolean sameLanguage = systemLocale.getLanguage().equals(newLocale.getLanguage());
final boolean implicitlyEnabled = mRichImm final boolean implicitlyEnabled =
.checkIfSubtypeBelongsToThisImeAndImplicitlyEnabled(newSubtype.getRawSubtype()); mRichImm.checkIfSubtypeBelongsToThisImeAndImplicitlyEnabled(newSubtype);
mLanguageOnSpacebarHelper.updateIsSystemLanguageSameAsInputLanguage( mLanguageOnSpacebarHelper.updateIsSystemLanguageSameAsInputLanguage(
sameLocale || (sameLanguage && implicitlyEnabled)); sameLocale || (sameLanguage && implicitlyEnabled));
@ -249,7 +250,7 @@ public final class SubtypeSwitcher {
// Subtype Switching functions // // Subtype Switching functions //
////////////////////////////////// //////////////////////////////////
public int getLanguageOnSpacebarFormatType(final RichInputMethodSubtype subtype) { public int getLanguageOnSpacebarFormatType(final InputMethodSubtype subtype) {
return mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(subtype); return mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(subtype);
} }
@ -278,10 +279,10 @@ public final class SubtypeSwitcher {
return true; return true;
} }
private static RichInputMethodSubtype sForcedSubtypeForTesting = null; private static InputMethodSubtype sForcedSubtypeForTesting = null;
@UsedForTesting @UsedForTesting
void forceSubtype(final InputMethodSubtype subtype) { void forceSubtype(final InputMethodSubtype subtype) {
sForcedSubtypeForTesting = new RichInputMethodSubtype(subtype); sForcedSubtypeForTesting = subtype;
} }
public Locale getCurrentSubtypeLocale() { public Locale getCurrentSubtypeLocale() {
@ -291,18 +292,17 @@ public final class SubtypeSwitcher {
return SubtypeLocaleUtils.getSubtypeLocale(getCurrentSubtype()); return SubtypeLocaleUtils.getSubtypeLocale(getCurrentSubtype());
} }
public RichInputMethodSubtype getCurrentSubtype() { public InputMethodSubtype getCurrentSubtype() {
if (null != sForcedSubtypeForTesting) { if (null != sForcedSubtypeForTesting) {
return sForcedSubtypeForTesting; return sForcedSubtypeForTesting;
} }
return mRichImm.getCurrentInputMethodSubtype(getNoLanguageSubtype()); return mRichImm.getCurrentInputMethodSubtype(getNoLanguageSubtype());
} }
public RichInputMethodSubtype getNoLanguageSubtype() { public InputMethodSubtype getNoLanguageSubtype() {
if (mNoLanguageSubtype == null) { if (mNoLanguageSubtype == null) {
mNoLanguageSubtype = new RichInputMethodSubtype( mNoLanguageSubtype = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( SubtypeLocaleUtils.NO_LANGUAGE, SubtypeLocaleUtils.QWERTY);
SubtypeLocaleUtils.NO_LANGUAGE, SubtypeLocaleUtils.QWERTY));
} }
if (mNoLanguageSubtype != null) { if (mNoLanguageSubtype != null) {
return mNoLanguageSubtype; return mNoLanguageSubtype;
@ -313,11 +313,10 @@ public final class SubtypeSwitcher {
return DUMMY_NO_LANGUAGE_SUBTYPE; return DUMMY_NO_LANGUAGE_SUBTYPE;
} }
public RichInputMethodSubtype getEmojiSubtype() { public InputMethodSubtype getEmojiSubtype() {
if (mEmojiSubtype == null) { if (mEmojiSubtype == null) {
mEmojiSubtype = new RichInputMethodSubtype( mEmojiSubtype = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( SubtypeLocaleUtils.NO_LANGUAGE, SubtypeLocaleUtils.EMOJI);
SubtypeLocaleUtils.NO_LANGUAGE, SubtypeLocaleUtils.EMOJI));
} }
if (mEmojiSubtype != null) { if (mEmojiSubtype != null) {
return mEmojiSubtype; return mEmojiSubtype;
@ -329,6 +328,6 @@ public final class SubtypeSwitcher {
} }
public String getCombiningRulesExtraValueOfCurrentSubtype() { public String getCombiningRulesExtraValueOfCurrentSubtype() {
return SubtypeLocaleUtils.getCombiningRulesExtraValue(getCurrentSubtype().getRawSubtype()); return SubtypeLocaleUtils.getCombiningRulesExtraValue(getCurrentSubtype());
} }
} }

View File

@ -39,7 +39,6 @@ import com.android.inputmethod.latin.DictionaryFacilitator;
import com.android.inputmethod.latin.DictionaryFactory; import com.android.inputmethod.latin.DictionaryFactory;
import com.android.inputmethod.latin.PrevWordsInfo; import com.android.inputmethod.latin.PrevWordsInfo;
import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.RichInputMethodSubtype;
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo; import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
import com.android.inputmethod.latin.settings.SettingsValuesForSuggestion; import com.android.inputmethod.latin.settings.SettingsValuesForSuggestion;
import com.android.inputmethod.latin.UserBinaryDictionary; import com.android.inputmethod.latin.UserBinaryDictionary;
@ -335,7 +334,7 @@ public final class AndroidSpellCheckerService extends SpellCheckerService
final KeyboardLayoutSet.Builder builder = new KeyboardLayoutSet.Builder(this, editorInfo); final KeyboardLayoutSet.Builder builder = new KeyboardLayoutSet.Builder(this, editorInfo);
builder.setKeyboardGeometry( builder.setKeyboardGeometry(
SPELLCHECKER_DUMMY_KEYBOARD_WIDTH, SPELLCHECKER_DUMMY_KEYBOARD_HEIGHT); SPELLCHECKER_DUMMY_KEYBOARD_WIDTH, SPELLCHECKER_DUMMY_KEYBOARD_HEIGHT);
builder.setSubtype(new RichInputMethodSubtype(subtype)); builder.setSubtype(subtype);
builder.setIsSpellChecker(true /* isSpellChecker */); builder.setIsSpellChecker(true /* isSpellChecker */);
builder.disableTouchPositionCorrectionData(); builder.disableTouchPositionCorrectionData();
return builder.build(); return builder.build();

View File

@ -35,7 +35,6 @@ import com.android.inputmethod.keyboard.KeyboardId;
import com.android.inputmethod.keyboard.KeyboardLayoutSet; import com.android.inputmethod.keyboard.KeyboardLayoutSet;
import com.android.inputmethod.latin.DictionaryFacilitator; import com.android.inputmethod.latin.DictionaryFacilitator;
import com.android.inputmethod.latin.PrevWordsInfo; import com.android.inputmethod.latin.PrevWordsInfo;
import com.android.inputmethod.latin.RichInputMethodSubtype;
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo; import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
import com.android.inputmethod.latin.WordComposer; import com.android.inputmethod.latin.WordComposer;
import com.android.inputmethod.latin.settings.SettingsValuesForSuggestion; import com.android.inputmethod.latin.settings.SettingsValuesForSuggestion;
@ -132,7 +131,7 @@ public class DistracterFilterCheckingExactMatchesAndSuggestions implements Distr
final int keyboardWidth = ResourceUtils.getDefaultKeyboardWidth(res); final int keyboardWidth = ResourceUtils.getDefaultKeyboardWidth(res);
final int keyboardHeight = ResourceUtils.getDefaultKeyboardHeight(res); final int keyboardHeight = ResourceUtils.getDefaultKeyboardHeight(res);
builder.setKeyboardGeometry(keyboardWidth, keyboardHeight); builder.setKeyboardGeometry(keyboardWidth, keyboardHeight);
builder.setSubtype(new RichInputMethodSubtype(subtype)); builder.setSubtype(subtype);
builder.setIsSpellChecker(false /* isSpellChecker */); builder.setIsSpellChecker(false /* isSpellChecker */);
final KeyboardLayoutSet layoutSet = builder.build(); final KeyboardLayoutSet layoutSet = builder.build();
mKeyboard = layoutSet.getKeyboard(KeyboardId.ELEMENT_ALPHABET); mKeyboard = layoutSet.getKeyboard(KeyboardId.ELEMENT_ALPHABET);

View File

@ -0,0 +1,58 @@
/*
* Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.inputmethod.latin.utils;
import android.view.inputmethod.InputMethodSubtype;
public final class SpacebarLanguageUtils {
private SpacebarLanguageUtils() {
// Intentional empty constructor for utility class.
}
// InputMethodSubtype's display name for spacebar text in its locale.
// isAdditionalSubtype (T=true, F=false)
// locale layout | Middle Full
// ------ ------- - --------- ----------------------
// en_US qwerty F English English (US) exception
// en_GB qwerty F English English (UK) exception
// es_US spanish F Español Español (EE.UU.) exception
// fr azerty F Français Français
// fr_CA qwerty F Français Français (Canada)
// fr_CH swiss F Français Français (Suisse)
// de qwertz F Deutsch Deutsch
// de_CH swiss T Deutsch Deutsch (Schweiz)
// zz qwerty F QWERTY QWERTY
// fr qwertz T Français Français
// de qwerty T Deutsch Deutsch
// en_US azerty T English English (US)
// zz azerty T AZERTY AZERTY
// Get InputMethodSubtype's full display name in its locale.
public static String getFullDisplayName(final InputMethodSubtype subtype) {
if (SubtypeLocaleUtils.isNoLanguage(subtype)) {
return SubtypeLocaleUtils.getKeyboardLayoutSetDisplayName(subtype);
}
return SubtypeLocaleUtils.getSubtypeLocaleDisplayName(subtype.getLocale());
}
// Get InputMethodSubtype's middle display name in its locale.
public static String getMiddleDisplayName(final InputMethodSubtype subtype) {
if (SubtypeLocaleUtils.isNoLanguage(subtype)) {
return SubtypeLocaleUtils.getKeyboardLayoutSetDisplayName(subtype);
}
return SubtypeLocaleUtils.getSubtypeLanguageDisplayName(subtype.getLocale());
}
}

View File

@ -27,17 +27,12 @@ import android.view.inputmethod.InputMethodSubtype;
import com.android.inputmethod.latin.Constants; import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.RichInputMethodSubtype;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Locale; import java.util.Locale;
/**
* A helper class to deal with subtype locales.
*/
// TODO: consolidate this into RichInputMethodSubtype
public final class SubtypeLocaleUtils { public final class SubtypeLocaleUtils {
private static final String TAG = SubtypeLocaleUtils.class.getSimpleName(); private static final String TAG = SubtypeLocaleUtils.class.getSimpleName();
@ -114,10 +109,10 @@ public final class SubtypeLocaleUtils {
sKeyboardLayoutToNameIdsMap.put(key, noLanguageResId); sKeyboardLayoutToNameIdsMap.put(key, noLanguageResId);
} }
final String[] exceptionalLocaleInRootLocale = res.getStringArray( final String[] excetionalLocaleInRootLocale = res.getStringArray(
R.array.subtype_locale_displayed_in_root_locale); R.array.subtype_locale_displayed_in_root_locale);
for (int i = 0; i < exceptionalLocaleInRootLocale.length; i++) { for (int i = 0; i < excetionalLocaleInRootLocale.length; i++) {
sExceptionalLocaleDisplayedInRootLocale.add(exceptionalLocaleInRootLocale[i]); sExceptionalLocaleDisplayedInRootLocale.add(excetionalLocaleInRootLocale[i]);
} }
final String[] exceptionalLocales = res.getStringArray( final String[] exceptionalLocales = res.getStringArray(
@ -265,7 +260,6 @@ public final class SubtypeLocaleUtils {
private static String getSubtypeDisplayNameInternal(final InputMethodSubtype subtype, private static String getSubtypeDisplayNameInternal(final InputMethodSubtype subtype,
final Locale displayLocale) { final Locale displayLocale) {
final String replacementString = getReplacementString(subtype, displayLocale); final String replacementString = getReplacementString(subtype, displayLocale);
// TODO: rework this for multi-lingual subtypes
final int nameResId = subtype.getNameResId(); final int nameResId = subtype.getNameResId();
final RunInLocale<String> getSubtypeName = new RunInLocale<String>() { final RunInLocale<String> getSubtypeName = new RunInLocale<String>() {
@Override @Override
@ -288,14 +282,12 @@ public final class SubtypeLocaleUtils {
getSubtypeName.runInLocale(sResources, displayLocale), displayLocale); getSubtypeName.runInLocale(sResources, displayLocale), displayLocale);
} }
public static Locale getSubtypeLocale(final InputMethodSubtype subtype) { public static boolean isNoLanguage(final InputMethodSubtype subtype) {
final String localeString = subtype.getLocale(); final String localeString = subtype.getLocale();
return LocaleUtils.constructLocaleFromString(localeString); return NO_LANGUAGE.equals(localeString);
} }
// TODO: remove this. When RichInputMethodSubtype#getLocale is removed we can do away with this public static Locale getSubtypeLocale(final InputMethodSubtype subtype) {
// method at the same time.
public static Locale getSubtypeLocale(final RichInputMethodSubtype subtype) {
final String localeString = subtype.getLocale(); final String localeString = subtype.getLocale();
return LocaleUtils.constructLocaleFromString(localeString); return LocaleUtils.constructLocaleFromString(localeString);
} }
@ -309,10 +301,6 @@ public final class SubtypeLocaleUtils {
return sKeyboardLayoutToDisplayNameMap.get(layoutName); return sKeyboardLayoutToDisplayNameMap.get(layoutName);
} }
public static String getKeyboardLayoutSetName(final RichInputMethodSubtype subtype) {
return getKeyboardLayoutSetName(subtype.getRawSubtype());
}
public static String getKeyboardLayoutSetName(final InputMethodSubtype subtype) { public static String getKeyboardLayoutSetName(final InputMethodSubtype subtype) {
String keyboardLayoutSet = subtype.getExtraValueOf(KEYBOARD_LAYOUT_SET); String keyboardLayoutSet = subtype.getExtraValueOf(KEYBOARD_LAYOUT_SET);
if (keyboardLayoutSet == null) { if (keyboardLayoutSet == null) {
@ -348,7 +336,7 @@ public final class SubtypeLocaleUtils {
return Arrays.binarySearch(SORTED_RTL_LANGUAGES, language) >= 0; return Arrays.binarySearch(SORTED_RTL_LANGUAGES, language) >= 0;
} }
public static boolean isRtlLanguage(final RichInputMethodSubtype subtype) { public static boolean isRtlLanguage(final InputMethodSubtype subtype) {
return isRtlLanguage(getSubtypeLocale(subtype)); return isRtlLanguage(getSubtypeLocale(subtype));
} }

View File

@ -29,7 +29,6 @@ import com.android.inputmethod.keyboard.KeyboardLayoutSet.Builder;
import com.android.inputmethod.latin.Constants; import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.RichInputMethodManager; import com.android.inputmethod.latin.RichInputMethodManager;
import com.android.inputmethod.latin.RichInputMethodSubtype;
import com.android.inputmethod.latin.utils.AdditionalSubtypeUtils; import com.android.inputmethod.latin.utils.AdditionalSubtypeUtils;
import com.android.inputmethod.latin.utils.ResourceUtils; import com.android.inputmethod.latin.utils.ResourceUtils;
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils; import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
@ -128,7 +127,7 @@ public abstract class KeyboardLayoutSetTestsBase extends AndroidTestCase {
final int keyboardHeight = ResourceUtils.getDefaultKeyboardHeight(res); final int keyboardHeight = ResourceUtils.getDefaultKeyboardHeight(res);
final Builder builder = new Builder(context, editorInfo); final Builder builder = new Builder(context, editorInfo);
builder.setKeyboardGeometry(keyboardWidth, keyboardHeight) builder.setKeyboardGeometry(keyboardWidth, keyboardHeight)
.setSubtype(new RichInputMethodSubtype(subtype)) .setSubtype(subtype)
.setVoiceInputKeyEnabled(voiceInputKeyEnabled) .setVoiceInputKeyEnabled(voiceInputKeyEnabled)
.setLanguageSwitchKeyEnabled(languageSwitchKeyEnabled); .setLanguageSwitchKeyEnabled(languageSwitchKeyEnabled);
return builder.build(); return builder.build();

View File

@ -26,7 +26,6 @@ import android.test.suitebuilder.annotation.SmallTest;
import android.view.inputmethod.InputMethodSubtype; import android.view.inputmethod.InputMethodSubtype;
import com.android.inputmethod.latin.RichInputMethodManager; import com.android.inputmethod.latin.RichInputMethodManager;
import com.android.inputmethod.latin.RichInputMethodSubtype;
import com.android.inputmethod.latin.utils.AdditionalSubtypeUtils; import com.android.inputmethod.latin.utils.AdditionalSubtypeUtils;
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils; import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
@ -41,14 +40,14 @@ public class LanguageOnSpacebarHelperTests extends AndroidTestCase {
private RichInputMethodManager mRichImm; private RichInputMethodManager mRichImm;
RichInputMethodSubtype EN_US_QWERTY; InputMethodSubtype EN_US_QWERTY;
RichInputMethodSubtype EN_GB_QWERTY; InputMethodSubtype EN_GB_QWERTY;
RichInputMethodSubtype FR_AZERTY; InputMethodSubtype FR_AZERTY;
RichInputMethodSubtype FR_CA_QWERTY; InputMethodSubtype FR_CA_QWERTY;
RichInputMethodSubtype FR_CH_SWISS; InputMethodSubtype FR_CH_SWISS;
RichInputMethodSubtype FR_CH_QWERTY; InputMethodSubtype FR_CH_QWERTY;
RichInputMethodSubtype FR_CH_QWERTZ; InputMethodSubtype FR_CH_QWERTZ;
RichInputMethodSubtype ZZ_QWERTY; InputMethodSubtype ZZ_QWERTY;
@Override @Override
protected void setUp() throws Exception { protected void setUp() throws Exception {
@ -58,22 +57,22 @@ public class LanguageOnSpacebarHelperTests extends AndroidTestCase {
mRichImm = RichInputMethodManager.getInstance(); mRichImm = RichInputMethodManager.getInstance();
SubtypeLocaleUtils.init(context); SubtypeLocaleUtils.init(context);
EN_US_QWERTY = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( EN_US_QWERTY = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
Locale.US.toString(), "qwerty")); Locale.US.toString(), "qwerty");
EN_GB_QWERTY = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( EN_GB_QWERTY = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
Locale.UK.toString(), "qwerty")); Locale.UK.toString(), "qwerty");
FR_AZERTY = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( FR_AZERTY = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
Locale.FRENCH.toString(), "azerty")); Locale.FRENCH.toString(), "azerty");
FR_CA_QWERTY = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( FR_CA_QWERTY = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
Locale.CANADA_FRENCH.toString(), "qwerty")); Locale.CANADA_FRENCH.toString(), "qwerty");
FR_CH_SWISS = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( FR_CH_SWISS = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
"fr_CH", "swiss")); "fr_CH", "swiss");
FR_CH_QWERTZ = new RichInputMethodSubtype( FR_CH_QWERTZ = AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype("fr_CH", "qwertz")); "fr_CH", "qwertz");
FR_CH_QWERTY = new RichInputMethodSubtype( FR_CH_QWERTY = AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype("fr_CH", "qwerty")); "fr_CH", "qwerty");
ZZ_QWERTY = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( ZZ_QWERTY = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
SubtypeLocaleUtils.NO_LANGUAGE, "qwerty")); SubtypeLocaleUtils.NO_LANGUAGE, "qwerty");
} }
private static List<InputMethodSubtype> asList(final InputMethodSubtype ... subtypes) { private static List<InputMethodSubtype> asList(final InputMethodSubtype ... subtypes) {
@ -81,14 +80,14 @@ public class LanguageOnSpacebarHelperTests extends AndroidTestCase {
} }
public void testOneSubtype() { public void testOneSubtype() {
mLanguageOnSpacebarHelper.updateEnabledSubtypes(asList(EN_US_QWERTY.getRawSubtype())); mLanguageOnSpacebarHelper.updateEnabledSubtypes(asList(EN_US_QWERTY));
mLanguageOnSpacebarHelper.updateIsSystemLanguageSameAsInputLanguage(true /* isSame */); mLanguageOnSpacebarHelper.updateIsSystemLanguageSameAsInputLanguage(true /* isSame */);
assertEquals("one same English (US)", FORMAT_TYPE_NONE, assertEquals("one same English (US)", FORMAT_TYPE_NONE,
mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(EN_US_QWERTY)); mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(EN_US_QWERTY));
assertEquals("one same NoLanguage", FORMAT_TYPE_FULL_LOCALE, assertEquals("one same NoLanguage", FORMAT_TYPE_FULL_LOCALE,
mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(ZZ_QWERTY)); mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(ZZ_QWERTY));
mLanguageOnSpacebarHelper.updateEnabledSubtypes(asList(FR_AZERTY.getRawSubtype())); mLanguageOnSpacebarHelper.updateEnabledSubtypes(asList(FR_AZERTY));
mLanguageOnSpacebarHelper.updateIsSystemLanguageSameAsInputLanguage(false /* isSame */); mLanguageOnSpacebarHelper.updateIsSystemLanguageSameAsInputLanguage(false /* isSame */);
assertEquals("one diff English (US)", FORMAT_TYPE_LANGUAGE_ONLY, assertEquals("one diff English (US)", FORMAT_TYPE_LANGUAGE_ONLY,
mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(EN_US_QWERTY)); mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(EN_US_QWERTY));
@ -97,8 +96,8 @@ public class LanguageOnSpacebarHelperTests extends AndroidTestCase {
} }
public void testTwoSubtypes() { public void testTwoSubtypes() {
mLanguageOnSpacebarHelper.updateEnabledSubtypes(asList(EN_US_QWERTY.getRawSubtype(), mLanguageOnSpacebarHelper.updateEnabledSubtypes(asList(EN_US_QWERTY, FR_AZERTY));
FR_AZERTY.getRawSubtype()));
mLanguageOnSpacebarHelper.updateIsSystemLanguageSameAsInputLanguage(true /* isSame */); mLanguageOnSpacebarHelper.updateIsSystemLanguageSameAsInputLanguage(true /* isSame */);
assertEquals("two same English (US)", FORMAT_TYPE_LANGUAGE_ONLY, assertEquals("two same English (US)", FORMAT_TYPE_LANGUAGE_ONLY,
mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(EN_US_QWERTY)); mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(EN_US_QWERTY));
@ -118,8 +117,7 @@ public class LanguageOnSpacebarHelperTests extends AndroidTestCase {
public void testSameLanuageSubtypes() { public void testSameLanuageSubtypes() {
mLanguageOnSpacebarHelper.updateEnabledSubtypes( mLanguageOnSpacebarHelper.updateEnabledSubtypes(
asList(EN_US_QWERTY.getRawSubtype(), EN_GB_QWERTY.getRawSubtype(), asList(EN_US_QWERTY, EN_GB_QWERTY, FR_AZERTY, ZZ_QWERTY));
FR_AZERTY.getRawSubtype(), ZZ_QWERTY.getRawSubtype()));
mLanguageOnSpacebarHelper.updateIsSystemLanguageSameAsInputLanguage(true /* isSame */); mLanguageOnSpacebarHelper.updateIsSystemLanguageSameAsInputLanguage(true /* isSame */);
assertEquals("two same English (US)", FORMAT_TYPE_FULL_LOCALE, assertEquals("two same English (US)", FORMAT_TYPE_FULL_LOCALE,
@ -140,9 +138,7 @@ public class LanguageOnSpacebarHelperTests extends AndroidTestCase {
public void testMultiSameLanuageSubtypes() { public void testMultiSameLanuageSubtypes() {
mLanguageOnSpacebarHelper.updateEnabledSubtypes( mLanguageOnSpacebarHelper.updateEnabledSubtypes(
asList(FR_AZERTY.getRawSubtype(), FR_CA_QWERTY.getRawSubtype(), asList(FR_AZERTY, FR_CA_QWERTY, FR_CH_SWISS, FR_CH_QWERTY, FR_CH_QWERTZ));
FR_CH_SWISS.getRawSubtype(), FR_CH_QWERTY.getRawSubtype(),
FR_CH_QWERTZ.getRawSubtype()));
mLanguageOnSpacebarHelper.updateIsSystemLanguageSameAsInputLanguage(true /* isSame */); mLanguageOnSpacebarHelper.updateIsSystemLanguageSameAsInputLanguage(true /* isSame */);
assertEquals("multi same French", FORMAT_TYPE_LANGUAGE_ONLY, assertEquals("multi same French", FORMAT_TYPE_LANGUAGE_ONLY,

View File

@ -24,7 +24,6 @@ import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodSubtype; import android.view.inputmethod.InputMethodSubtype;
import com.android.inputmethod.latin.RichInputMethodManager; import com.android.inputmethod.latin.RichInputMethodManager;
import com.android.inputmethod.latin.RichInputMethodSubtype;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Locale; import java.util.Locale;
@ -32,28 +31,28 @@ import java.util.Locale;
@SmallTest @SmallTest
public class SpacebarLanguageUtilsTests extends AndroidTestCase { public class SpacebarLanguageUtilsTests extends AndroidTestCase {
// All input method subtypes of LatinIME. // All input method subtypes of LatinIME.
private final ArrayList<RichInputMethodSubtype> mSubtypesList = new ArrayList<>(); private final ArrayList<InputMethodSubtype> mSubtypesList = new ArrayList<>();
private RichInputMethodManager mRichImm; private RichInputMethodManager mRichImm;
private Resources mRes; private Resources mRes;
RichInputMethodSubtype EN_US; InputMethodSubtype EN_US;
RichInputMethodSubtype EN_GB; InputMethodSubtype EN_GB;
RichInputMethodSubtype ES_US; InputMethodSubtype ES_US;
RichInputMethodSubtype FR; InputMethodSubtype FR;
RichInputMethodSubtype FR_CA; InputMethodSubtype FR_CA;
RichInputMethodSubtype FR_CH; InputMethodSubtype FR_CH;
RichInputMethodSubtype DE; InputMethodSubtype DE;
RichInputMethodSubtype DE_CH; InputMethodSubtype DE_CH;
RichInputMethodSubtype HI_ZZ; InputMethodSubtype HI_ZZ;
RichInputMethodSubtype ZZ; InputMethodSubtype ZZ;
RichInputMethodSubtype DE_QWERTY; InputMethodSubtype DE_QWERTY;
RichInputMethodSubtype FR_QWERTZ; InputMethodSubtype FR_QWERTZ;
RichInputMethodSubtype EN_US_AZERTY; InputMethodSubtype EN_US_AZERTY;
RichInputMethodSubtype EN_UK_DVORAK; InputMethodSubtype EN_UK_DVORAK;
RichInputMethodSubtype ES_US_COLEMAK; InputMethodSubtype ES_US_COLEMAK;
RichInputMethodSubtype ZZ_AZERTY; InputMethodSubtype ZZ_AZERTY;
RichInputMethodSubtype ZZ_PC; InputMethodSubtype ZZ_PC;
@Override @Override
protected void setUp() throws Exception { protected void setUp() throws Exception {
@ -68,60 +67,53 @@ public class SpacebarLanguageUtilsTests extends AndroidTestCase {
final int subtypeCount = imi.getSubtypeCount(); final int subtypeCount = imi.getSubtypeCount();
for (int index = 0; index < subtypeCount; index++) { for (int index = 0; index < subtypeCount; index++) {
final InputMethodSubtype subtype = imi.getSubtypeAt(index); final InputMethodSubtype subtype = imi.getSubtypeAt(index);
mSubtypesList.add(new RichInputMethodSubtype(subtype)); mSubtypesList.add(subtype);
} }
EN_US = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( EN_US = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
Locale.US.toString(), "qwerty")); Locale.US.toString(), "qwerty");
EN_GB = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( EN_GB = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
Locale.UK.toString(), "qwerty")); Locale.UK.toString(), "qwerty");
ES_US = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( ES_US = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
"es_US", "spanish")); "es_US", "spanish");
FR = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( FR = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
Locale.FRENCH.toString(), "azerty")); Locale.FRENCH.toString(), "azerty");
FR_CA = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( FR_CA = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
Locale.CANADA_FRENCH.toString(), "qwerty")); Locale.CANADA_FRENCH.toString(), "qwerty");
FR_CH = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( FR_CH = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
"fr_CH", "swiss")); "fr_CH", "swiss");
DE = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( DE = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
Locale.GERMAN.toString(), "qwertz")); Locale.GERMAN.toString(), "qwertz");
DE_CH = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( DE_CH = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
"de_CH", "swiss")); "de_CH", "swiss");
HI_ZZ = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( HI_ZZ = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
"hi_ZZ", "qwerty")); "hi_ZZ", "qwerty");
ZZ = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( ZZ = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
SubtypeLocaleUtils.NO_LANGUAGE, "qwerty")); SubtypeLocaleUtils.NO_LANGUAGE, "qwerty");
DE_QWERTY = new RichInputMethodSubtype( DE_QWERTY = AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype( Locale.GERMAN.toString(), "qwerty");
Locale.GERMAN.toString(), "qwerty")); FR_QWERTZ = AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
FR_QWERTZ = new RichInputMethodSubtype( Locale.FRENCH.toString(), "qwertz");
AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype( EN_US_AZERTY = AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
Locale.FRENCH.toString(), "qwertz")); Locale.US.toString(), "azerty");
EN_US_AZERTY = new RichInputMethodSubtype( EN_UK_DVORAK = AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype( Locale.UK.toString(), "dvorak");
Locale.US.toString(), "azerty")); ES_US_COLEMAK = AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
EN_UK_DVORAK = new RichInputMethodSubtype( "es_US", "colemak");
AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype( ZZ_AZERTY = AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
Locale.UK.toString(), "dvorak")); SubtypeLocaleUtils.NO_LANGUAGE, "azerty");
ES_US_COLEMAK = new RichInputMethodSubtype( ZZ_PC = AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype( SubtypeLocaleUtils.NO_LANGUAGE, "pcqwerty");
"es_US", "colemak"));
ZZ_AZERTY = new RichInputMethodSubtype(
AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
SubtypeLocaleUtils.NO_LANGUAGE, "azerty"));
ZZ_PC = new RichInputMethodSubtype(
AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
SubtypeLocaleUtils.NO_LANGUAGE, "pcqwerty"));
} }
public void testAllFullDisplayNameForSpacebar() { public void testAllFullDisplayNameForSpacebar() {
for (final RichInputMethodSubtype subtype : mSubtypesList) { for (final InputMethodSubtype subtype : mSubtypesList) {
final String subtypeName = SubtypeLocaleUtils final String subtypeName = SubtypeLocaleUtils
.getSubtypeDisplayNameInSystemLocale(subtype.getRawSubtype()); .getSubtypeDisplayNameInSystemLocale(subtype);
final String spacebarText = subtype.getFullDisplayName(); final String spacebarText = SpacebarLanguageUtils.getFullDisplayName(subtype);
final String languageName = SubtypeLocaleUtils final String languageName = SubtypeLocaleUtils
.getSubtypeLocaleDisplayName(subtype.getLocale()); .getSubtypeLocaleDisplayName(subtype.getLocale());
if (subtype.isNoLanguage()) { if (SubtypeLocaleUtils.isNoLanguage(subtype)) {
assertFalse(subtypeName, spacebarText.contains(languageName)); assertFalse(subtypeName, spacebarText.contains(languageName));
} else { } else {
assertTrue(subtypeName, spacebarText.contains(languageName)); assertTrue(subtypeName, spacebarText.contains(languageName));
@ -130,19 +122,19 @@ public class SpacebarLanguageUtilsTests extends AndroidTestCase {
} }
public void testAllMiddleDisplayNameForSpacebar() { public void testAllMiddleDisplayNameForSpacebar() {
for (final RichInputMethodSubtype subtype : mSubtypesList) { for (final InputMethodSubtype subtype : mSubtypesList) {
final String subtypeName = SubtypeLocaleUtils final String subtypeName = SubtypeLocaleUtils
.getSubtypeDisplayNameInSystemLocale(subtype.getRawSubtype()); .getSubtypeDisplayNameInSystemLocale(subtype);
if (SubtypeLocaleUtils.sExceptionalLocaleDisplayedInRootLocale.contains( if (SubtypeLocaleUtils.sExceptionalLocaleDisplayedInRootLocale.contains(
subtype.getLocale())) { subtype.getLocale())) {
// Skip test because the language part of this locale string doesn't represent // Skip test because the language part of this locale string doesn't represent
// the locale to be displayed on the spacebar (for example hi_ZZ and Hinglish). // the locale to be displayed on the spacebar (for example hi_ZZ and Hinglish).
continue; continue;
} }
final String spacebarText = subtype.getMiddleDisplayName(); final String spacebarText = SpacebarLanguageUtils.getMiddleDisplayName(subtype);
if (subtype.isNoLanguage()) { if (SubtypeLocaleUtils.isNoLanguage(subtype)) {
assertEquals(subtypeName, SubtypeLocaleUtils.getKeyboardLayoutSetDisplayName( assertEquals(subtypeName,
subtype.getRawSubtype()), spacebarText); SubtypeLocaleUtils.getKeyboardLayoutSetDisplayName(subtype), spacebarText);
} else { } else {
final Locale locale = SubtypeLocaleUtils.getSubtypeLocale(subtype); final Locale locale = SubtypeLocaleUtils.getSubtypeLocale(subtype);
assertEquals(subtypeName, assertEquals(subtypeName,
@ -174,27 +166,47 @@ public class SpacebarLanguageUtilsTests extends AndroidTestCase {
private final RunInLocale<Void> testsPredefinedSubtypesForSpacebar = new RunInLocale<Void>() { private final RunInLocale<Void> testsPredefinedSubtypesForSpacebar = new RunInLocale<Void>() {
@Override @Override
protected Void job(final Resources res) { protected Void job(final Resources res) {
assertEquals("en_US", "English (US)", EN_US.getFullDisplayName()); assertEquals("en_US", "English (US)",
assertEquals("en_GB", "English (UK)", EN_GB.getFullDisplayName()); SpacebarLanguageUtils.getFullDisplayName(EN_US));
assertEquals("es_US", "Español (EE.UU.)", ES_US.getFullDisplayName()); assertEquals("en_GB", "English (UK)",
assertEquals("fr", "Français", FR.getFullDisplayName()); SpacebarLanguageUtils.getFullDisplayName(EN_GB));
assertEquals("fr_CA", "Français (Canada)", FR_CA.getFullDisplayName()); assertEquals("es_US", "Español (EE.UU.)",
assertEquals("fr_CH", "Français (Suisse)", FR_CH.getFullDisplayName()); SpacebarLanguageUtils.getFullDisplayName(ES_US));
assertEquals("de", "Deutsch", DE.getFullDisplayName()); assertEquals("fr", "Français",
assertEquals("de_CH", "Deutsch (Schweiz)", DE_CH.getFullDisplayName()); SpacebarLanguageUtils.getFullDisplayName(FR));
assertEquals("hi_ZZ", "Hinglish", HI_ZZ.getFullDisplayName()); assertEquals("fr_CA", "Français (Canada)",
assertEquals("zz", "QWERTY", ZZ.getFullDisplayName()); SpacebarLanguageUtils.getFullDisplayName(FR_CA));
assertEquals("fr_CH", "Français (Suisse)",
SpacebarLanguageUtils.getFullDisplayName(FR_CH));
assertEquals("de", "Deutsch",
SpacebarLanguageUtils.getFullDisplayName(DE));
assertEquals("de_CH", "Deutsch (Schweiz)",
SpacebarLanguageUtils.getFullDisplayName(DE_CH));
assertEquals("hi_ZZ", "Hinglish",
SpacebarLanguageUtils.getFullDisplayName(HI_ZZ));
assertEquals("zz", "QWERTY",
SpacebarLanguageUtils.getFullDisplayName(ZZ));
assertEquals("en_US", "English", EN_US.getMiddleDisplayName()); assertEquals("en_US", "English",
assertEquals("en_GB", "English", EN_GB.getMiddleDisplayName()); SpacebarLanguageUtils.getMiddleDisplayName(EN_US));
assertEquals("es_US", "Español", ES_US.getMiddleDisplayName()); assertEquals("en_GB", "English",
assertEquals("fr", "Français", FR.getMiddleDisplayName()); SpacebarLanguageUtils.getMiddleDisplayName(EN_GB));
assertEquals("fr_CA", "Français", FR_CA.getMiddleDisplayName()); assertEquals("es_US", "Español",
assertEquals("fr_CH", "Français", FR_CH.getMiddleDisplayName()); SpacebarLanguageUtils.getMiddleDisplayName(ES_US));
assertEquals("de", "Deutsch", DE.getMiddleDisplayName()); assertEquals("fr", "Français",
assertEquals("de_CH", "Deutsch", DE_CH.getMiddleDisplayName()); SpacebarLanguageUtils.getMiddleDisplayName(FR));
assertEquals("hi_ZZ", "Hinglish", HI_ZZ.getMiddleDisplayName()); assertEquals("fr_CA", "Français",
assertEquals("zz", "QWERTY", ZZ.getMiddleDisplayName()); SpacebarLanguageUtils.getMiddleDisplayName(FR_CA));
assertEquals("fr_CH", "Français",
SpacebarLanguageUtils.getMiddleDisplayName(FR_CH));
assertEquals("de", "Deutsch",
SpacebarLanguageUtils.getMiddleDisplayName(DE));
assertEquals("de_CH", "Deutsch",
SpacebarLanguageUtils.getMiddleDisplayName(DE_CH));
assertEquals("hi_ZZ", "Hinglish",
SpacebarLanguageUtils.getMiddleDisplayName(HI_ZZ));
assertEquals("zz", "QWERTY",
SpacebarLanguageUtils.getMiddleDisplayName(ZZ));
return null; return null;
} }
}; };
@ -202,21 +214,35 @@ public class SpacebarLanguageUtilsTests extends AndroidTestCase {
private final RunInLocale<Void> testsAdditionalSubtypesForSpacebar = new RunInLocale<Void>() { private final RunInLocale<Void> testsAdditionalSubtypesForSpacebar = new RunInLocale<Void>() {
@Override @Override
protected Void job(final Resources res) { protected Void job(final Resources res) {
assertEquals("fr qwertz", "Français", FR_QWERTZ.getFullDisplayName()); assertEquals("fr qwertz", "Français",
assertEquals("de qwerty", "Deutsch", DE_QWERTY.getFullDisplayName()); SpacebarLanguageUtils.getFullDisplayName(FR_QWERTZ));
assertEquals("en_US azerty", "English (US)", EN_US_AZERTY.getFullDisplayName()); assertEquals("de qwerty", "Deutsch",
assertEquals("en_UK dvorak", "English (UK)", EN_UK_DVORAK.getFullDisplayName()); SpacebarLanguageUtils.getFullDisplayName(DE_QWERTY));
assertEquals("es_US colemak", "Español (EE.UU.)", ES_US_COLEMAK.getFullDisplayName()); assertEquals("en_US azerty", "English (US)",
assertEquals("zz azerty", "AZERTY", ZZ_AZERTY.getFullDisplayName()); SpacebarLanguageUtils.getFullDisplayName(EN_US_AZERTY));
assertEquals("zz pc", "PC", ZZ_PC.getFullDisplayName()); assertEquals("en_UK dvorak", "English (UK)",
SpacebarLanguageUtils.getFullDisplayName(EN_UK_DVORAK));
assertEquals("es_US colemak", "Español (EE.UU.)",
SpacebarLanguageUtils.getFullDisplayName(ES_US_COLEMAK));
assertEquals("zz azerty", "AZERTY",
SpacebarLanguageUtils.getFullDisplayName(ZZ_AZERTY));
assertEquals("zz pc", "PC",
SpacebarLanguageUtils.getFullDisplayName(ZZ_PC));
assertEquals("fr qwertz", "Français", FR_QWERTZ.getMiddleDisplayName()); assertEquals("fr qwertz", "Français",
assertEquals("de qwerty", "Deutsch", DE_QWERTY.getMiddleDisplayName()); SpacebarLanguageUtils.getMiddleDisplayName(FR_QWERTZ));
assertEquals("en_US azerty", "English", EN_US_AZERTY.getMiddleDisplayName()); assertEquals("de qwerty", "Deutsch",
assertEquals("en_UK dvorak", "English", EN_UK_DVORAK.getMiddleDisplayName()); SpacebarLanguageUtils.getMiddleDisplayName(DE_QWERTY));
assertEquals("es_US colemak", "Español", ES_US_COLEMAK.getMiddleDisplayName()); assertEquals("en_US azerty", "English",
assertEquals("zz azerty", "AZERTY", ZZ_AZERTY.getMiddleDisplayName()); SpacebarLanguageUtils.getMiddleDisplayName(EN_US_AZERTY));
assertEquals("zz pc", "PC", ZZ_PC.getMiddleDisplayName()); assertEquals("en_UK dvorak", "English",
SpacebarLanguageUtils.getMiddleDisplayName(EN_UK_DVORAK));
assertEquals("es_US colemak", "Español",
SpacebarLanguageUtils.getMiddleDisplayName(ES_US_COLEMAK));
assertEquals("zz azerty", "AZERTY",
SpacebarLanguageUtils.getMiddleDisplayName(ZZ_AZERTY));
assertEquals("zz pc", "PC",
SpacebarLanguageUtils.getMiddleDisplayName(ZZ_PC));
return null; return null;
} }
}; };

View File

@ -24,7 +24,6 @@ import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodSubtype; import android.view.inputmethod.InputMethodSubtype;
import com.android.inputmethod.latin.RichInputMethodManager; import com.android.inputmethod.latin.RichInputMethodManager;
import com.android.inputmethod.latin.RichInputMethodSubtype;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Locale; import java.util.Locale;
@ -32,7 +31,7 @@ import java.util.Locale;
@SmallTest @SmallTest
public class SubtypeLocaleUtilsTests extends AndroidTestCase { public class SubtypeLocaleUtilsTests extends AndroidTestCase {
// All input method subtypes of LatinIME. // All input method subtypes of LatinIME.
private final ArrayList<RichInputMethodSubtype> mSubtypesList = new ArrayList<>(); private final ArrayList<InputMethodSubtype> mSubtypesList = new ArrayList<>();
private RichInputMethodManager mRichImm; private RichInputMethodManager mRichImm;
private Resources mRes; private Resources mRes;
@ -68,7 +67,7 @@ public class SubtypeLocaleUtilsTests extends AndroidTestCase {
final int subtypeCount = imi.getSubtypeCount(); final int subtypeCount = imi.getSubtypeCount();
for (int index = 0; index < subtypeCount; index++) { for (int index = 0; index < subtypeCount; index++) {
final InputMethodSubtype subtype = imi.getSubtypeAt(index); final InputMethodSubtype subtype = imi.getSubtypeAt(index);
mSubtypesList.add(new RichInputMethodSubtype(subtype)); mSubtypesList.add(subtype);
} }
EN_US = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( EN_US = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
@ -108,12 +107,12 @@ public class SubtypeLocaleUtilsTests extends AndroidTestCase {
} }
public void testAllFullDisplayName() { public void testAllFullDisplayName() {
for (final RichInputMethodSubtype subtype : mSubtypesList) { for (final InputMethodSubtype subtype : mSubtypesList) {
final String subtypeName = SubtypeLocaleUtils final String subtypeName = SubtypeLocaleUtils
.getSubtypeDisplayNameInSystemLocale(subtype.getRawSubtype()); .getSubtypeDisplayNameInSystemLocale(subtype);
if (subtype.isNoLanguage()) { if (SubtypeLocaleUtils.isNoLanguage(subtype)) {
final String layoutName = SubtypeLocaleUtils final String layoutName = SubtypeLocaleUtils
.getKeyboardLayoutSetDisplayName(subtype.getRawSubtype()); .getKeyboardLayoutSetDisplayName(subtype);
assertTrue(subtypeName, subtypeName.contains(layoutName)); assertTrue(subtypeName, subtypeName.contains(layoutName));
} else { } else {
final String languageName = SubtypeLocaleUtils final String languageName = SubtypeLocaleUtils
@ -309,9 +308,9 @@ public class SubtypeLocaleUtilsTests extends AndroidTestCase {
.findSubtypeByLocaleAndKeyboardLayoutSet("iw", "hebrew"); .findSubtypeByLocaleAndKeyboardLayoutSet("iw", "hebrew");
assertNotNull("Hebrew", HEBREW); assertNotNull("Hebrew", HEBREW);
for (final RichInputMethodSubtype subtype : mSubtypesList) { for (final InputMethodSubtype subtype : mSubtypesList) {
final String subtypeName = SubtypeLocaleUtils final String subtypeName = SubtypeLocaleUtils
.getSubtypeDisplayNameInSystemLocale(subtype.getRawSubtype()); .getSubtypeDisplayNameInSystemLocale(subtype);
if (subtype.equals(ARABIC) || subtype.equals(FARSI) || subtype.equals(HEBREW)) { if (subtype.equals(ARABIC) || subtype.equals(FARSI) || subtype.equals(HEBREW)) {
assertTrue(subtypeName, SubtypeLocaleUtils.isRtlLanguage(subtype)); assertTrue(subtypeName, SubtypeLocaleUtils.isRtlLanguage(subtype));
} else { } else {