am 8cfad7ed: Merge "Make LanguageOnSpacebarHelper as utility class"

* commit '8cfad7ed64d08c5a131c9c539aa4fc964030c214':
  Make LanguageOnSpacebarHelper as utility class
main
Tadashi G. Takaoka 2014-12-12 04:49:24 +00:00 committed by Android Git Automerger
commit 1f890c4d82
5 changed files with 49 additions and 53 deletions

View File

@ -40,6 +40,7 @@ import com.android.inputmethod.latin.define.ProductionFlags;
import com.android.inputmethod.latin.settings.Settings; import com.android.inputmethod.latin.settings.Settings;
import com.android.inputmethod.latin.settings.SettingsValues; import com.android.inputmethod.latin.settings.SettingsValues;
import com.android.inputmethod.latin.utils.CapsModeUtils; import com.android.inputmethod.latin.utils.CapsModeUtils;
import com.android.inputmethod.latin.utils.LanguageOnSpacebarUtils;
import com.android.inputmethod.latin.utils.NetworkConnectivityUtils; import com.android.inputmethod.latin.utils.NetworkConnectivityUtils;
import com.android.inputmethod.latin.utils.RecapitalizeStatus; import com.android.inputmethod.latin.utils.RecapitalizeStatus;
import com.android.inputmethod.latin.utils.ResourceUtils; import com.android.inputmethod.latin.utils.ResourceUtils;
@ -56,6 +57,7 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions,
private MainKeyboardView mKeyboardView; private MainKeyboardView mKeyboardView;
private EmojiPalettesView mEmojiPalettesView; private EmojiPalettesView mEmojiPalettesView;
private LatinIME mLatinIME; private LatinIME mLatinIME;
private RichInputMethodManager mRichImm;
private boolean mIsHardwareAcceleratedDrawingEnabled; private boolean mIsHardwareAcceleratedDrawingEnabled;
private KeyboardState mState; private KeyboardState mState;
@ -83,6 +85,7 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions,
private void initInternal(final LatinIME latinIme) { private void initInternal(final LatinIME latinIme) {
mLatinIME = latinIme; mLatinIME = latinIme;
mRichImm = RichInputMethodManager.getInstance();
mSubtypeSwitcher = SubtypeSwitcher.getInstance(); mSubtypeSwitcher = SubtypeSwitcher.getInstance();
mState = new KeyboardState(this); mState = new KeyboardState(this);
mIsHardwareAcceleratedDrawingEnabled = mIsHardwareAcceleratedDrawingEnabled =
@ -116,7 +119,7 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions,
final int keyboardWidth = ResourceUtils.getDefaultKeyboardWidth(res); final int keyboardWidth = ResourceUtils.getDefaultKeyboardWidth(res);
final int keyboardHeight = ResourceUtils.getKeyboardHeight(res, settingsValues); final int keyboardHeight = ResourceUtils.getKeyboardHeight(res, settingsValues);
builder.setKeyboardGeometry(keyboardWidth, keyboardHeight); builder.setKeyboardGeometry(keyboardWidth, keyboardHeight);
builder.setSubtype(RichInputMethodManager.getInstance().getCurrentSubtype()); builder.setSubtype(mRichImm.getCurrentSubtype());
builder.setVoiceInputKeyEnabled(settingsValues.mShowsVoiceInputKey); builder.setVoiceInputKeyEnabled(settingsValues.mShowsVoiceInputKey);
builder.setLanguageSwitchKeyEnabled(mLatinIME.shouldShowLanguageSwitchKey()); builder.setLanguageSwitchKeyEnabled(mLatinIME.shouldShowLanguageSwitchKey());
builder.setSplitLayoutEnabledByUser(ProductionFlags.IS_SPLIT_KEYBOARD_SUPPORTED builder.setSplitLayoutEnabledByUser(ProductionFlags.IS_SPLIT_KEYBOARD_SUPPORTED
@ -125,9 +128,7 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions,
try { try {
mState.onLoadKeyboard(currentAutoCapsState, currentRecapitalizeState); mState.onLoadKeyboard(currentAutoCapsState, currentRecapitalizeState);
// TODO: revisit this for multi-lingual input // TODO: revisit this for multi-lingual input
mKeyboardTextsSet.setLocale( mKeyboardTextsSet.setLocale(mRichImm.getCurrentSubtypeLocales()[0], mThemeContext);
RichInputMethodManager.getInstance().getCurrentSubtypeLocales()[0],
mThemeContext);
} catch (KeyboardLayoutSetException e) { } catch (KeyboardLayoutSetException e) {
Log.w(TAG, "loading keyboard failed: " + e.mKeyboardId, e.getCause()); Log.w(TAG, "loading keyboard failed: " + e.mKeyboardId, e.getCause());
return; return;
@ -166,12 +167,12 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions,
currentSettingsValues.mKeyPreviewDismissEndXScale, currentSettingsValues.mKeyPreviewDismissEndXScale,
currentSettingsValues.mKeyPreviewDismissEndYScale, currentSettingsValues.mKeyPreviewDismissEndYScale,
currentSettingsValues.mKeyPreviewDismissDuration); currentSettingsValues.mKeyPreviewDismissDuration);
keyboardView.updateShortcutKey(RichInputMethodManager.getInstance().isShortcutImeReady()); keyboardView.updateShortcutKey(mRichImm.isShortcutImeReady());
final boolean subtypeChanged = (oldKeyboard == null) final boolean subtypeChanged = (oldKeyboard == null)
|| !keyboard.mId.mSubtype.equals(oldKeyboard.mId.mSubtype); || !keyboard.mId.mSubtype.equals(oldKeyboard.mId.mSubtype);
final int languageOnSpacebarFormatType = mSubtypeSwitcher.getLanguageOnSpacebarFormatType( final int languageOnSpacebarFormatType = LanguageOnSpacebarUtils
keyboard.mId.mSubtype); .getLanguageOnSpacebarFormatType(keyboard.mId.mSubtype);
final boolean hasMultipleEnabledIMEsOrSubtypes = RichInputMethodManager.getInstance() final boolean hasMultipleEnabledIMEsOrSubtypes = mRichImm
.hasMultipleEnabledIMEsOrSubtypes(true /* shouldIncludeAuxiliarySubtypes */); .hasMultipleEnabledIMEsOrSubtypes(true /* shouldIncludeAuxiliarySubtypes */);
keyboardView.startDisplayLanguageOnSpacebar(subtypeChanged, languageOnSpacebarFormatType, keyboardView.startDisplayLanguageOnSpacebar(subtypeChanged, languageOnSpacebarFormatType,
hasMultipleEnabledIMEsOrSubtypes); hasMultipleEnabledIMEsOrSubtypes);
@ -422,7 +423,7 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions,
if (mKeyboardView == null) { if (mKeyboardView == null) {
return; return;
} }
mKeyboardView.updateShortcutKey(RichInputMethodManager.getInstance().isShortcutImeReady()); mKeyboardView.updateShortcutKey(mRichImm.isShortcutImeReady());
} }
public int getKeyboardShiftMode() { public int getKeyboardShiftMode() {

View File

@ -47,7 +47,6 @@ import com.android.inputmethod.keyboard.internal.KeyDrawParams;
import com.android.inputmethod.keyboard.internal.KeyPreviewChoreographer; import com.android.inputmethod.keyboard.internal.KeyPreviewChoreographer;
import com.android.inputmethod.keyboard.internal.KeyPreviewDrawParams; import com.android.inputmethod.keyboard.internal.KeyPreviewDrawParams;
import com.android.inputmethod.keyboard.internal.KeyPreviewView; import com.android.inputmethod.keyboard.internal.KeyPreviewView;
import com.android.inputmethod.keyboard.internal.LanguageOnSpacebarHelper;
import com.android.inputmethod.keyboard.internal.MoreKeySpec; import com.android.inputmethod.keyboard.internal.MoreKeySpec;
import com.android.inputmethod.keyboard.internal.NonDistinctMultitouchHelper; import com.android.inputmethod.keyboard.internal.NonDistinctMultitouchHelper;
import com.android.inputmethod.keyboard.internal.SlidingKeyInputDrawingPreview; import com.android.inputmethod.keyboard.internal.SlidingKeyInputDrawingPreview;
@ -58,6 +57,7 @@ import com.android.inputmethod.latin.SuggestedWords;
import com.android.inputmethod.latin.common.Constants; import com.android.inputmethod.latin.common.Constants;
import com.android.inputmethod.latin.common.CoordinateUtils; import com.android.inputmethod.latin.common.CoordinateUtils;
import com.android.inputmethod.latin.settings.DebugSettings; import com.android.inputmethod.latin.settings.DebugSettings;
import com.android.inputmethod.latin.utils.LanguageOnSpacebarUtils;
import com.android.inputmethod.latin.utils.TypefaceUtils; import com.android.inputmethod.latin.utils.TypefaceUtils;
import java.util.Locale; import java.util.Locale;
@ -783,10 +783,10 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy
mHasMultipleEnabledIMEsOrSubtypes = hasMultipleEnabledIMEsOrSubtypes; mHasMultipleEnabledIMEsOrSubtypes = hasMultipleEnabledIMEsOrSubtypes;
final ObjectAnimator animator = mLanguageOnSpacebarFadeoutAnimator; final ObjectAnimator animator = mLanguageOnSpacebarFadeoutAnimator;
if (animator == null) { if (animator == null) {
mLanguageOnSpacebarFormatType = LanguageOnSpacebarHelper.FORMAT_TYPE_NONE; mLanguageOnSpacebarFormatType = LanguageOnSpacebarUtils.FORMAT_TYPE_NONE;
} else { } else {
if (subtypeChanged if (subtypeChanged
&& languageOnSpacebarFormatType != LanguageOnSpacebarHelper.FORMAT_TYPE_NONE) { && languageOnSpacebarFormatType != LanguageOnSpacebarUtils.FORMAT_TYPE_NONE) {
setLanguageOnSpacebarAnimAlpha(Constants.Color.ALPHA_OPAQUE); setLanguageOnSpacebarAnimAlpha(Constants.Color.ALPHA_OPAQUE);
if (animator.isStarted()) { if (animator.isStarted()) {
animator.cancel(); animator.cancel();
@ -811,7 +811,7 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy
final int code = key.getCode(); final int code = key.getCode();
if (code == Constants.CODE_SPACE) { if (code == Constants.CODE_SPACE) {
// If input language are explicitly selected. // If input language are explicitly selected.
if (mLanguageOnSpacebarFormatType != LanguageOnSpacebarHelper.FORMAT_TYPE_NONE) { if (mLanguageOnSpacebarFormatType != LanguageOnSpacebarUtils.FORMAT_TYPE_NONE) {
drawLanguageOnSpacebar(key, canvas, paint); drawLanguageOnSpacebar(key, canvas, paint);
} }
// Whether space key needs to show the "..." popup hint for special purposes // Whether space key needs to show the "..." popup hint for special purposes
@ -843,7 +843,7 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy
// 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 RichInputMethodSubtype subtype, final int width) {
if (mLanguageOnSpacebarFormatType == LanguageOnSpacebarHelper.FORMAT_TYPE_MULTIPLE) { if (mLanguageOnSpacebarFormatType == LanguageOnSpacebarUtils.FORMAT_TYPE_MULTIPLE) {
final Locale[] locales = subtype.getLocales(); final Locale[] locales = subtype.getLocales();
final String[] languages = new String[locales.length]; final String[] languages = new String[locales.length];
for (int i = 0; i < locales.length; ++i) { for (int i = 0; i < locales.length; ++i) {
@ -853,7 +853,7 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy
} }
// 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 == LanguageOnSpacebarUtils.FORMAT_TYPE_FULL_LOCALE) {
final String fullText = subtype.getFullDisplayName(); final String fullText = subtype.getFullDisplayName();
if (fitsTextIntoWidth(width, fullText, paint)) { if (fitsTextIntoWidth(width, fullText, paint)) {
return fullText; return fullText;

View File

@ -20,7 +20,7 @@ import android.content.Context;
import android.content.res.Resources; import android.content.res.Resources;
import android.view.inputmethod.InputMethodSubtype; import android.view.inputmethod.InputMethodSubtype;
import com.android.inputmethod.keyboard.internal.LanguageOnSpacebarHelper; import com.android.inputmethod.latin.utils.LanguageOnSpacebarUtils;
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils; import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
import java.util.List; import java.util.List;
@ -33,9 +33,6 @@ public final class SubtypeSwitcher {
private /* final */ RichInputMethodManager mRichImm; private /* final */ RichInputMethodManager mRichImm;
private /* final */ Resources mResources; private /* final */ Resources mResources;
private final LanguageOnSpacebarHelper mLanguageOnSpacebarHelper =
new LanguageOnSpacebarHelper();
public static SubtypeSwitcher getInstance() { public static SubtypeSwitcher getInstance() {
return sInstance; return sInstance;
} }
@ -68,18 +65,14 @@ public final class SubtypeSwitcher {
public void updateParametersOnStartInputView() { public void updateParametersOnStartInputView() {
final List<InputMethodSubtype> enabledSubtypesOfThisIme = final List<InputMethodSubtype> enabledSubtypesOfThisIme =
mRichImm.getMyEnabledInputMethodSubtypeList(true); mRichImm.getMyEnabledInputMethodSubtypeList(true);
mLanguageOnSpacebarHelper.onUpdateEnabledSubtypes(enabledSubtypesOfThisIme); LanguageOnSpacebarUtils.setEnabledSubtypes(enabledSubtypesOfThisIme);
} }
// Update the current subtype. LatinIME.onCurrentInputMethodSubtypeChanged calls this function. // Update the current subtype. LatinIME.onCurrentInputMethodSubtypeChanged calls this function.
public void onSubtypeChanged(@Nonnull final RichInputMethodSubtype richSubtype) { public void onSubtypeChanged(@Nonnull final RichInputMethodSubtype richSubtype) {
final boolean implicitlyEnabledSubtype = mRichImm final boolean implicitlyEnabledSubtype = mRichImm
.checkIfSubtypeBelongsToThisImeAndImplicitlyEnabled(richSubtype.getRawSubtype()); .checkIfSubtypeBelongsToThisImeAndImplicitlyEnabled(richSubtype.getRawSubtype());
mLanguageOnSpacebarHelper.onSubtypeChanged( LanguageOnSpacebarUtils.onSubtypeChanged(
richSubtype, implicitlyEnabledSubtype, mResources.getConfiguration().locale); richSubtype, implicitlyEnabledSubtype, mResources.getConfiguration().locale);
} }
public int getLanguageOnSpacebarFormatType(final RichInputMethodSubtype subtype) {
return mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(subtype);
}
} }

View File

@ -14,12 +14,11 @@
* limitations under the License. * limitations under the License.
*/ */
package com.android.inputmethod.keyboard.internal; package com.android.inputmethod.latin.utils;
import android.view.inputmethod.InputMethodSubtype; import android.view.inputmethod.InputMethodSubtype;
import com.android.inputmethod.latin.RichInputMethodSubtype; import com.android.inputmethod.latin.RichInputMethodSubtype;
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -30,21 +29,26 @@ import javax.annotation.Nonnull;
/** /**
* This class determines that the language name on the spacebar should be displayed in what format. * This class determines that the language name on the spacebar should be displayed in what format.
*/ */
public final class LanguageOnSpacebarHelper { public final class LanguageOnSpacebarUtils {
public static final int FORMAT_TYPE_NONE = 0; public static final int FORMAT_TYPE_NONE = 0;
public static final int FORMAT_TYPE_LANGUAGE_ONLY = 1; public static final int FORMAT_TYPE_LANGUAGE_ONLY = 1;
public static final int FORMAT_TYPE_FULL_LOCALE = 2; public static final int FORMAT_TYPE_FULL_LOCALE = 2;
public static final int FORMAT_TYPE_MULTIPLE = 3; public static final int FORMAT_TYPE_MULTIPLE = 3;
private List<InputMethodSubtype> mEnabledSubtypes = Collections.emptyList(); private static List<InputMethodSubtype> sEnabledSubtypes = Collections.emptyList();
private boolean mIsSystemLanguageSameAsInputLanguage; private static boolean sIsSystemLanguageSameAsInputLanguage;
public int getLanguageOnSpacebarFormatType(@Nonnull final RichInputMethodSubtype subtype) { private LanguageOnSpacebarUtils() {
// This utility class is not publicly instantiable.
}
public static int getLanguageOnSpacebarFormatType(
@Nonnull final RichInputMethodSubtype subtype) {
if (subtype.isNoLanguage()) { if (subtype.isNoLanguage()) {
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.
if (mEnabledSubtypes.size() < 2 && mIsSystemLanguageSameAsInputLanguage) { if (sEnabledSubtypes.size() < 2 && sIsSystemLanguageSameAsInputLanguage) {
return FORMAT_TYPE_NONE; return FORMAT_TYPE_NONE;
} }
final Locale[] locales = subtype.getLocales(); final Locale[] locales = subtype.getLocales();
@ -54,7 +58,7 @@ public final class LanguageOnSpacebarHelper {
final String keyboardLanguage = locales[0].getLanguage(); final String keyboardLanguage = locales[0].getLanguage();
final String keyboardLayout = subtype.getKeyboardLayoutSetName(); final String keyboardLayout = subtype.getKeyboardLayoutSetName();
int sameLanguageAndLayoutCount = 0; int sameLanguageAndLayoutCount = 0;
for (final InputMethodSubtype ims : mEnabledSubtypes) { for (final InputMethodSubtype ims : sEnabledSubtypes) {
final String language = SubtypeLocaleUtils.getSubtypeLocale(ims).getLanguage(); final String language = SubtypeLocaleUtils.getSubtypeLocale(ims).getLanguage();
if (keyboardLanguage.equals(language) && keyboardLayout.equals( if (keyboardLanguage.equals(language) && keyboardLayout.equals(
SubtypeLocaleUtils.getKeyboardLayoutSetName(ims))) { SubtypeLocaleUtils.getKeyboardLayoutSetName(ims))) {
@ -67,30 +71,30 @@ public final class LanguageOnSpacebarHelper {
: FORMAT_TYPE_LANGUAGE_ONLY; : FORMAT_TYPE_LANGUAGE_ONLY;
} }
public void onUpdateEnabledSubtypes(@Nonnull final List<InputMethodSubtype> enabledSubtypes) { public static void setEnabledSubtypes(@Nonnull final List<InputMethodSubtype> enabledSubtypes) {
mEnabledSubtypes = enabledSubtypes; sEnabledSubtypes = enabledSubtypes;
} }
public void onSubtypeChanged(@Nonnull final RichInputMethodSubtype subtype, public static void onSubtypeChanged(@Nonnull final RichInputMethodSubtype subtype,
final boolean implicitlyEnabledSubtype, @Nonnull final Locale systemLocale) { final boolean implicitlyEnabledSubtype, @Nonnull final Locale systemLocale) {
final Locale[] newLocales = subtype.getLocales(); final Locale[] newLocales = subtype.getLocales();
if (newLocales.length > 1) { if (newLocales.length > 1) {
// In multi-locales mode, the system language is never the same as the input language // In multi-locales mode, the system language is never the same as the input language
// because there is no single input language. // because there is no single input language.
mIsSystemLanguageSameAsInputLanguage = false; sIsSystemLanguageSameAsInputLanguage = false;
return; return;
} }
final Locale newLocale = newLocales[0]; final Locale newLocale = newLocales[0];
if (systemLocale.equals(newLocale)) { if (systemLocale.equals(newLocale)) {
mIsSystemLanguageSameAsInputLanguage = true; sIsSystemLanguageSameAsInputLanguage = true;
return; return;
} }
if (!systemLocale.getLanguage().equals(newLocale.getLanguage())) { if (!systemLocale.getLanguage().equals(newLocale.getLanguage())) {
mIsSystemLanguageSameAsInputLanguage = false; sIsSystemLanguageSameAsInputLanguage = false;
return; return;
} }
// If the subtype is enabled explicitly, the language name should be displayed even when // If the subtype is enabled explicitly, the language name should be displayed even when
// the keyboard language and the system language are equal. // the keyboard language and the system language are equal.
mIsSystemLanguageSameAsInputLanguage = implicitlyEnabledSubtype; sIsSystemLanguageSameAsInputLanguage = implicitlyEnabledSubtype;
} }
} }

View File

@ -14,11 +14,11 @@
* limitations under the License. * limitations under the License.
*/ */
package com.android.inputmethod.keyboard.internal; package com.android.inputmethod.latin.utils;
import static com.android.inputmethod.keyboard.internal.LanguageOnSpacebarHelper.FORMAT_TYPE_FULL_LOCALE; import static com.android.inputmethod.latin.utils.LanguageOnSpacebarUtils.FORMAT_TYPE_FULL_LOCALE;
import static com.android.inputmethod.keyboard.internal.LanguageOnSpacebarHelper.FORMAT_TYPE_LANGUAGE_ONLY; import static com.android.inputmethod.latin.utils.LanguageOnSpacebarUtils.FORMAT_TYPE_LANGUAGE_ONLY;
import static com.android.inputmethod.keyboard.internal.LanguageOnSpacebarHelper.FORMAT_TYPE_NONE; import static com.android.inputmethod.latin.utils.LanguageOnSpacebarUtils.FORMAT_TYPE_NONE;
import android.content.Context; import android.content.Context;
import android.test.AndroidTestCase; import android.test.AndroidTestCase;
@ -28,6 +28,7 @@ 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.RichInputMethodSubtype;
import com.android.inputmethod.latin.utils.AdditionalSubtypeUtils; import com.android.inputmethod.latin.utils.AdditionalSubtypeUtils;
import com.android.inputmethod.latin.utils.LanguageOnSpacebarUtils;
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils; import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
import java.util.ArrayList; import java.util.ArrayList;
@ -36,10 +37,7 @@ import java.util.Locale;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
@SmallTest @SmallTest
public class LanguageOnSpacebarHelperTests extends AndroidTestCase { public class LanguageOnSpacebarUtilsTests extends AndroidTestCase {
private final LanguageOnSpacebarHelper mLanguageOnSpacebarHelper =
new LanguageOnSpacebarHelper();
private RichInputMethodManager mRichImm; private RichInputMethodManager mRichImm;
RichInputMethodSubtype EN_US_QWERTY; RichInputMethodSubtype EN_US_QWERTY;
@ -84,21 +82,21 @@ public class LanguageOnSpacebarHelperTests extends AndroidTestCase {
return new RichInputMethodSubtype(subtype); return new RichInputMethodSubtype(subtype);
} }
private void enableSubtypes(final RichInputMethodSubtype ... subtypes) { private static void enableSubtypes(final RichInputMethodSubtype ... subtypes) {
final ArrayList<InputMethodSubtype> enabledSubtypes = new ArrayList<>(); final ArrayList<InputMethodSubtype> enabledSubtypes = new ArrayList<>();
for (final RichInputMethodSubtype subtype : subtypes) { for (final RichInputMethodSubtype subtype : subtypes) {
enabledSubtypes.add(subtype.getRawSubtype()); enabledSubtypes.add(subtype.getRawSubtype());
} }
mLanguageOnSpacebarHelper.onUpdateEnabledSubtypes(enabledSubtypes); LanguageOnSpacebarUtils.setEnabledSubtypes(enabledSubtypes);
} }
private void assertFormatType(final RichInputMethodSubtype subtype, private static void assertFormatType(final RichInputMethodSubtype subtype,
final boolean implicitlyEnabledSubtype, final Locale systemLocale, final boolean implicitlyEnabledSubtype, final Locale systemLocale,
final int expectedFormat) { final int expectedFormat) {
mLanguageOnSpacebarHelper.onSubtypeChanged(subtype, implicitlyEnabledSubtype, systemLocale); LanguageOnSpacebarUtils.onSubtypeChanged(subtype, implicitlyEnabledSubtype, systemLocale);
assertEquals(subtype.getLocales()[0] + " implicitly=" + implicitlyEnabledSubtype assertEquals(subtype.getLocales()[0] + " implicitly=" + implicitlyEnabledSubtype
+ " in " + systemLocale, expectedFormat, + " in " + systemLocale, expectedFormat,
mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(subtype)); LanguageOnSpacebarUtils.getLanguageOnSpacebarFormatType(subtype));
} }
public void testOneSubtypeImplicitlyEnabled() { public void testOneSubtypeImplicitlyEnabled() {