am 9ef59af7: Merge "Move subtype related utility class to utils package"

* commit '9ef59af7ceda6facf37b382dfa504b9f3b3f9845':
  Move subtype related utility class to utils package
main
Tadashi G. Takaoka 2013-07-24 06:39:19 -07:00 committed by Android Git Automerger
commit 2e94df081e
13 changed files with 171 additions and 162 deletions

View File

@ -25,8 +25,8 @@ import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodSubtype; import android.view.inputmethod.InputMethodSubtype;
import com.android.inputmethod.compat.EditorInfoCompatUtils; import com.android.inputmethod.compat.EditorInfoCompatUtils;
import com.android.inputmethod.latin.SubtypeLocale;
import com.android.inputmethod.latin.utils.InputTypeUtils; import com.android.inputmethod.latin.utils.InputTypeUtils;
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
import java.util.Arrays; import java.util.Arrays;
import java.util.Locale; import java.util.Locale;
@ -76,7 +76,7 @@ public final class KeyboardId {
public KeyboardId(final int elementId, final KeyboardLayoutSet.Params params) { public KeyboardId(final int elementId, final KeyboardLayoutSet.Params params) {
mSubtype = params.mSubtype; mSubtype = params.mSubtype;
mLocale = SubtypeLocale.getSubtypeLocale(mSubtype); mLocale = SubtypeLocaleUtils.getSubtypeLocale(mSubtype);
mOrientation = params.mOrientation; mOrientation = params.mOrientation;
mWidth = params.mKeyboardWidth; mWidth = params.mKeyboardWidth;
mHeight = params.mKeyboardHeight; mHeight = params.mKeyboardHeight;

View File

@ -41,15 +41,15 @@ import com.android.inputmethod.compat.EditorInfoCompatUtils;
import com.android.inputmethod.keyboard.internal.KeyboardBuilder; import com.android.inputmethod.keyboard.internal.KeyboardBuilder;
import com.android.inputmethod.keyboard.internal.KeyboardParams; 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.AdditionalSubtype;
import com.android.inputmethod.latin.InputAttributes; import com.android.inputmethod.latin.InputAttributes;
import com.android.inputmethod.latin.LatinImeLogger; import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.SubtypeLocale;
import com.android.inputmethod.latin.SubtypeSwitcher; import com.android.inputmethod.latin.SubtypeSwitcher;
import com.android.inputmethod.latin.utils.AdditionalSubtypeUtils;
import com.android.inputmethod.latin.utils.CollectionUtils; import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.InputTypeUtils; import com.android.inputmethod.latin.utils.InputTypeUtils;
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.XmlParseUtils; import com.android.inputmethod.latin.utils.XmlParseUtils;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
@ -288,7 +288,7 @@ public final class KeyboardLayoutSet {
: subtype; : subtype;
mParams.mSubtype = keyboardSubtype; mParams.mSubtype = keyboardSubtype;
mParams.mKeyboardLayoutSetName = KEYBOARD_LAYOUT_SET_RESOURCE_PREFIX mParams.mKeyboardLayoutSetName = KEYBOARD_LAYOUT_SET_RESOURCE_PREFIX
+ SubtypeLocale.getKeyboardLayoutSetName(keyboardSubtype); + SubtypeLocaleUtils.getKeyboardLayoutSetName(keyboardSubtype);
return this; return this;
} }
@ -445,7 +445,7 @@ public final class KeyboardLayoutSet {
public static KeyboardLayoutSet createKeyboardSetForSpellChecker(final Context context, public static KeyboardLayoutSet createKeyboardSetForSpellChecker(final Context context,
final String locale, final String layout) { final String locale, final String layout) {
final InputMethodSubtype subtype = final InputMethodSubtype subtype =
AdditionalSubtype.createAdditionalSubtype(locale, layout, null); AdditionalSubtypeUtils.createAdditionalSubtype(locale, layout, null);
return createKeyboardSet(context, subtype, SPELLCHECKER_DUMMY_KEYBOARD_WIDTH, return createKeyboardSet(context, subtype, SPELLCHECKER_DUMMY_KEYBOARD_WIDTH,
SPELLCHECKER_DUMMY_KEYBOARD_HEIGHT, false /* testCasesHaveTouchCoordinates */, SPELLCHECKER_DUMMY_KEYBOARD_HEIGHT, false /* testCasesHaveTouchCoordinates */,
true /* isSpellChecker */); true /* isSpellChecker */);

View File

@ -59,7 +59,6 @@ import com.android.inputmethod.keyboard.internal.TouchScreenRegulator;
import com.android.inputmethod.latin.Constants; import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.LatinImeLogger; import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.SubtypeLocale;
import com.android.inputmethod.latin.SuggestedWords; import com.android.inputmethod.latin.SuggestedWords;
import com.android.inputmethod.latin.define.ProductionFlag; import com.android.inputmethod.latin.define.ProductionFlag;
import com.android.inputmethod.latin.settings.DebugSettings; import com.android.inputmethod.latin.settings.DebugSettings;
@ -67,6 +66,7 @@ import com.android.inputmethod.latin.settings.Settings;
import com.android.inputmethod.latin.utils.CollectionUtils; import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.CoordinateUtils; import com.android.inputmethod.latin.utils.CoordinateUtils;
import com.android.inputmethod.latin.utils.StaticInnerHandlerWrapper; import com.android.inputmethod.latin.utils.StaticInnerHandlerWrapper;
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
import com.android.inputmethod.latin.utils.TypefaceUtils; import com.android.inputmethod.latin.utils.TypefaceUtils;
import com.android.inputmethod.latin.utils.UsabilityStudyLogUtils; import com.android.inputmethod.latin.utils.UsabilityStudyLogUtils;
import com.android.inputmethod.latin.utils.ViewLayoutUtils; import com.android.inputmethod.latin.utils.ViewLayoutUtils;
@ -1342,17 +1342,17 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
private static String layoutLanguageOnSpacebar(final Paint paint, private static String layoutLanguageOnSpacebar(final Paint paint,
final InputMethodSubtype 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.
final String fullText = SubtypeLocale.getFullDisplayName(subtype); final String fullText = SubtypeLocaleUtils.getFullDisplayName(subtype);
if (fitsTextIntoWidth(width, fullText, paint)) { if (fitsTextIntoWidth(width, fullText, paint)) {
return fullText; return fullText;
} }
final String middleText = SubtypeLocale.getMiddleDisplayName(subtype); final String middleText = SubtypeLocaleUtils.getMiddleDisplayName(subtype);
if (fitsTextIntoWidth(width, middleText, paint)) { if (fitsTextIntoWidth(width, middleText, paint)) {
return middleText; return middleText;
} }
final String shortText = SubtypeLocale.getShortDisplayName(subtype); final String shortText = SubtypeLocaleUtils.getShortDisplayName(subtype);
if (fitsTextIntoWidth(width, shortText, paint)) { if (fitsTextIntoWidth(width, shortText, paint)) {
return shortText; return shortText;
} }

View File

@ -30,10 +30,10 @@ import com.android.inputmethod.keyboard.Key;
import com.android.inputmethod.keyboard.Keyboard; import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.keyboard.KeyboardId; import com.android.inputmethod.keyboard.KeyboardId;
import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.SubtypeLocale;
import com.android.inputmethod.latin.utils.LocaleUtils.RunInLocale; import com.android.inputmethod.latin.utils.LocaleUtils.RunInLocale;
import com.android.inputmethod.latin.utils.ResourceUtils; import com.android.inputmethod.latin.utils.ResourceUtils;
import com.android.inputmethod.latin.utils.StringUtils; import com.android.inputmethod.latin.utils.StringUtils;
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
import com.android.inputmethod.latin.utils.XmlParseUtils; import com.android.inputmethod.latin.utils.XmlParseUtils;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
@ -285,7 +285,7 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
} }
}; };
// Null means the current system locale. // Null means the current system locale.
final Locale locale = SubtypeLocale.isNoLanguage(params.mId.mSubtype) final Locale locale = SubtypeLocaleUtils.isNoLanguage(params.mId.mSubtype)
? null : params.mId.mLocale; ? null : params.mId.mLocale;
job.runInLocale(mResources, locale); job.runInLocale(mResources, locale);

View File

@ -29,7 +29,9 @@ import android.view.inputmethod.InputMethodSubtype;
import com.android.inputmethod.compat.InputMethodManagerCompatWrapper; import com.android.inputmethod.compat.InputMethodManagerCompatWrapper;
import com.android.inputmethod.latin.settings.Settings; import com.android.inputmethod.latin.settings.Settings;
import com.android.inputmethod.latin.utils.AdditionalSubtypeUtils;
import com.android.inputmethod.latin.utils.CollectionUtils; import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
@ -84,11 +86,11 @@ public final class RichInputMethodManager {
mInputMethodInfoOfThisIme = getInputMethodInfoOfThisIme(context); mInputMethodInfoOfThisIme = getInputMethodInfoOfThisIme(context);
// Initialize additional subtypes. // Initialize additional subtypes.
SubtypeLocale.init(context); SubtypeLocaleUtils.init(context);
final String prefAdditionalSubtypes = Settings.readPrefAdditionalSubtypes( final String prefAdditionalSubtypes = Settings.readPrefAdditionalSubtypes(
prefs, context.getResources()); prefs, context.getResources());
final InputMethodSubtype[] additionalSubtypes = final InputMethodSubtype[] additionalSubtypes =
AdditionalSubtype.createAdditionalSubtypesArray(prefAdditionalSubtypes); AdditionalSubtypeUtils.createAdditionalSubtypesArray(prefAdditionalSubtypes);
setAdditionalInputMethodSubtypes(additionalSubtypes); setAdditionalInputMethodSubtypes(additionalSubtypes);
} }
@ -134,7 +136,7 @@ public final class RichInputMethodManager {
final int currentIndex = getSubtypeIndexInList(currentSubtype, enabledSubtypes); final int currentIndex = getSubtypeIndexInList(currentSubtype, enabledSubtypes);
if (currentIndex == INDEX_NOT_FOUND) { if (currentIndex == INDEX_NOT_FOUND) {
Log.w(TAG, "Can't find current subtype in enabled subtypes: subtype=" Log.w(TAG, "Can't find current subtype in enabled subtypes: subtype="
+ SubtypeLocale.getSubtypeNameForLogging(currentSubtype)); + SubtypeLocaleUtils.getSubtypeNameForLogging(currentSubtype));
return false; return false;
} }
final int nextIndex = (currentIndex + 1) % enabledSubtypes.size(); final int nextIndex = (currentIndex + 1) % enabledSubtypes.size();
@ -342,7 +344,7 @@ public final class RichInputMethodManager {
final int count = myImi.getSubtypeCount(); final int count = myImi.getSubtypeCount();
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
final InputMethodSubtype subtype = myImi.getSubtypeAt(i); final InputMethodSubtype subtype = myImi.getSubtypeAt(i);
final String layoutName = SubtypeLocale.getKeyboardLayoutSetName(subtype); final String layoutName = SubtypeLocaleUtils.getKeyboardLayoutSetName(subtype);
if (localeString.equals(subtype.getLocale()) if (localeString.equals(subtype.getLocale())
&& keyboardLayoutSetName.equals(layoutName)) { && keyboardLayoutSetName.equals(layoutName)) {
return subtype; return subtype;

View File

@ -33,6 +33,7 @@ import android.view.inputmethod.InputMethodSubtype;
import com.android.inputmethod.annotations.UsedForTesting; import com.android.inputmethod.annotations.UsedForTesting;
import com.android.inputmethod.keyboard.KeyboardSwitcher; import com.android.inputmethod.keyboard.KeyboardSwitcher;
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
@ -82,7 +83,7 @@ public final class SubtypeSwitcher {
} }
public static void init(final Context context) { public static void init(final Context context) {
SubtypeLocale.init(context); SubtypeLocaleUtils.init(context);
RichInputMethodManager.init(context); RichInputMethodManager.init(context);
sInstance.initialize(context); sInstance.initialize(context);
} }
@ -153,10 +154,11 @@ 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 InputMethodSubtype newSubtype) { public void onSubtypeChanged(final InputMethodSubtype newSubtype) {
if (DBG) { if (DBG) {
Log.w(TAG, "onSubtypeChanged: " + SubtypeLocale.getSubtypeNameForLogging(newSubtype)); Log.w(TAG, "onSubtypeChanged: "
+ SubtypeLocaleUtils.getSubtypeNameForLogging(newSubtype));
} }
final Locale newLocale = SubtypeLocale.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());
@ -232,7 +234,7 @@ public final class SubtypeSwitcher {
////////////////////////////////// //////////////////////////////////
public boolean needsToDisplayLanguage(final Locale keyboardLocale) { public boolean needsToDisplayLanguage(final Locale keyboardLocale) {
if (keyboardLocale.toString().equals(SubtypeLocale.NO_LANGUAGE)) { if (keyboardLocale.toString().equals(SubtypeLocaleUtils.NO_LANGUAGE)) {
return true; return true;
} }
if (!keyboardLocale.equals(getCurrentSubtypeLocale())) { if (!keyboardLocale.equals(getCurrentSubtypeLocale())) {
@ -249,7 +251,7 @@ public final class SubtypeSwitcher {
public Locale getCurrentSubtypeLocale() { public Locale getCurrentSubtypeLocale() {
if (null != sForcedLocaleForTesting) return sForcedLocaleForTesting; if (null != sForcedLocaleForTesting) return sForcedLocaleForTesting;
return SubtypeLocale.getSubtypeLocale(getCurrentSubtype()); return SubtypeLocaleUtils.getSubtypeLocale(getCurrentSubtype());
} }
public InputMethodSubtype getCurrentSubtype() { public InputMethodSubtype getCurrentSubtype() {
@ -259,7 +261,7 @@ public final class SubtypeSwitcher {
public InputMethodSubtype getNoLanguageSubtype() { public InputMethodSubtype getNoLanguageSubtype() {
if (mNoLanguageSubtype == null) { if (mNoLanguageSubtype == null) {
mNoLanguageSubtype = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( mNoLanguageSubtype = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
SubtypeLocale.NO_LANGUAGE, SubtypeLocale.QWERTY); SubtypeLocaleUtils.NO_LANGUAGE, SubtypeLocaleUtils.QWERTY);
} }
if (mNoLanguageSubtype != null) { if (mNoLanguageSubtype != null) {
return mNoLanguageSubtype; return mNoLanguageSubtype;

View File

@ -29,6 +29,7 @@ import android.text.TextUtils;
import com.android.inputmethod.compat.UserDictionaryCompatUtils; import com.android.inputmethod.compat.UserDictionaryCompatUtils;
import com.android.inputmethod.latin.utils.LocaleUtils; import com.android.inputmethod.latin.utils.LocaleUtils;
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
import java.util.Arrays; import java.util.Arrays;
import java.util.Locale; import java.util.Locale;
@ -76,7 +77,7 @@ public class UserBinaryDictionary extends ExpandableBinaryDictionary {
final boolean alsoUseMoreRestrictiveLocales) { final boolean alsoUseMoreRestrictiveLocales) {
super(context, getFilenameWithLocale(NAME, locale), Dictionary.TYPE_USER); super(context, getFilenameWithLocale(NAME, locale), Dictionary.TYPE_USER);
if (null == locale) throw new NullPointerException(); // Catch the error earlier if (null == locale) throw new NullPointerException(); // Catch the error earlier
if (SubtypeLocale.NO_LANGUAGE.equals(locale)) { if (SubtypeLocaleUtils.NO_LANGUAGE.equals(locale)) {
// If we don't have a locale, insert into the "all locales" user dictionary. // If we don't have a locale, insert into the "all locales" user dictionary.
mLocale = USER_DICTIONARY_ALL_LANGUAGES; mLocale = USER_DICTIONARY_ALL_LANGUAGES;
} else { } else {

View File

@ -44,12 +44,12 @@ import android.widget.Spinner;
import android.widget.SpinnerAdapter; import android.widget.SpinnerAdapter;
import android.widget.Toast; import android.widget.Toast;
import com.android.inputmethod.latin.AdditionalSubtype;
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.SubtypeLocale; import com.android.inputmethod.latin.utils.AdditionalSubtypeUtils;
import com.android.inputmethod.latin.utils.CollectionUtils; import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.IntentUtils; import com.android.inputmethod.latin.utils.IntentUtils;
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.TreeSet; import java.util.TreeSet;
@ -78,7 +78,7 @@ public final class AdditionalSubtypeSettings extends PreferenceFragment {
public SubtypeLocaleItem(final String localeString) { public SubtypeLocaleItem(final String localeString) {
this(localeString, this(localeString,
SubtypeLocale.getSubtypeLocaleDisplayNameInSystemLocale(localeString)); SubtypeLocaleUtils.getSubtypeLocaleDisplayNameInSystemLocale(localeString));
} }
@Override @Override
@ -109,7 +109,7 @@ public final class AdditionalSubtypeSettings extends PreferenceFragment {
if (DEBUG_SUBTYPE_ID) { if (DEBUG_SUBTYPE_ID) {
android.util.Log.d(TAG, String.format("%-6s 0x%08x %11d %s", android.util.Log.d(TAG, String.format("%-6s 0x%08x %11d %s",
subtype.getLocale(), subtype.hashCode(), subtype.hashCode(), subtype.getLocale(), subtype.hashCode(), subtype.hashCode(),
SubtypeLocale.getSubtypeDisplayNameInSystemLocale(subtype))); SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(subtype)));
} }
if (subtype.containsExtraValueKey(ASCII_CAPABLE)) { if (subtype.containsExtraValueKey(ASCII_CAPABLE)) {
items.add(createItem(context, subtype.getLocale())); items.add(createItem(context, subtype.getLocale()));
@ -121,7 +121,7 @@ public final class AdditionalSubtypeSettings extends PreferenceFragment {
public static SubtypeLocaleItem createItem(final Context context, public static SubtypeLocaleItem createItem(final Context context,
final String localeString) { final String localeString) {
if (localeString.equals(SubtypeLocale.NO_LANGUAGE)) { if (localeString.equals(SubtypeLocaleUtils.NO_LANGUAGE)) {
final String displayName = context.getString(R.string.subtype_no_language); final String displayName = context.getString(R.string.subtype_no_language);
return new SubtypeLocaleItem(localeString, displayName); return new SubtypeLocaleItem(localeString, displayName);
} else { } else {
@ -132,8 +132,8 @@ public final class AdditionalSubtypeSettings extends PreferenceFragment {
static final class KeyboardLayoutSetItem extends Pair<String, String> { static final class KeyboardLayoutSetItem extends Pair<String, String> {
public KeyboardLayoutSetItem(final InputMethodSubtype subtype) { public KeyboardLayoutSetItem(final InputMethodSubtype subtype) {
super(SubtypeLocale.getKeyboardLayoutSetName(subtype), super(SubtypeLocaleUtils.getKeyboardLayoutSetName(subtype),
SubtypeLocale.getKeyboardLayoutSetDisplayName(subtype)); SubtypeLocaleUtils.getKeyboardLayoutSetDisplayName(subtype));
} }
@Override @Override
@ -148,10 +148,10 @@ public final class AdditionalSubtypeSettings extends PreferenceFragment {
setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
// TODO: Should filter out already existing combinations of locale and layout. // TODO: Should filter out already existing combinations of locale and layout.
for (final String layout : SubtypeLocale.getPredefinedKeyboardLayoutSet()) { for (final String layout : SubtypeLocaleUtils.getPredefinedKeyboardLayoutSet()) {
// This is a dummy subtype with NO_LANGUAGE, only for display. // This is a dummy subtype with NO_LANGUAGE, only for display.
final InputMethodSubtype subtype = AdditionalSubtype.createAdditionalSubtype( final InputMethodSubtype subtype = AdditionalSubtypeUtils.createAdditionalSubtype(
SubtypeLocale.NO_LANGUAGE, layout, null); SubtypeLocaleUtils.NO_LANGUAGE, layout, null);
add(new KeyboardLayoutSetItem(subtype)); add(new KeyboardLayoutSetItem(subtype));
} }
} }
@ -212,11 +212,11 @@ public final class AdditionalSubtypeSettings extends PreferenceFragment {
setKey(KEY_NEW_SUBTYPE); setKey(KEY_NEW_SUBTYPE);
} else { } else {
final String displayName = final String displayName =
SubtypeLocale.getSubtypeDisplayNameInSystemLocale(subtype); SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(subtype);
setTitle(displayName); setTitle(displayName);
setDialogTitle(displayName); setDialogTitle(displayName);
setKey(KEY_PREFIX + subtype.getLocale() + "_" setKey(KEY_PREFIX + subtype.getLocale() + "_"
+ SubtypeLocale.getKeyboardLayoutSetName(subtype)); + SubtypeLocaleUtils.getKeyboardLayoutSetName(subtype));
} }
} }
@ -286,7 +286,7 @@ public final class AdditionalSubtypeSettings extends PreferenceFragment {
(SubtypeLocaleItem) mSubtypeLocaleSpinner.getSelectedItem(); (SubtypeLocaleItem) mSubtypeLocaleSpinner.getSelectedItem();
final KeyboardLayoutSetItem layout = final KeyboardLayoutSetItem layout =
(KeyboardLayoutSetItem) mKeyboardLayoutSetSpinner.getSelectedItem(); (KeyboardLayoutSetItem) mKeyboardLayoutSetSpinner.getSelectedItem();
final InputMethodSubtype subtype = AdditionalSubtype.createAdditionalSubtype( final InputMethodSubtype subtype = AdditionalSubtypeUtils.createAdditionalSubtype(
locale.first, layout.first, ASCII_CAPABLE); locale.first, layout.first, ASCII_CAPABLE);
setSubtype(subtype); setSubtype(subtype);
notifyChanged(); notifyChanged();
@ -504,13 +504,13 @@ public final class AdditionalSubtypeSettings extends PreferenceFragment {
final Context context = getActivity(); final Context context = getActivity();
final Resources res = context.getResources(); final Resources res = context.getResources();
final String message = res.getString(R.string.custom_input_style_already_exists, final String message = res.getString(R.string.custom_input_style_already_exists,
SubtypeLocale.getSubtypeDisplayNameInSystemLocale(subtype)); SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(subtype));
Toast.makeText(context, message, Toast.LENGTH_SHORT).show(); Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
} }
private InputMethodSubtype findDuplicatedSubtype(final InputMethodSubtype subtype) { private InputMethodSubtype findDuplicatedSubtype(final InputMethodSubtype subtype) {
final String localeString = subtype.getLocale(); final String localeString = subtype.getLocale();
final String keyboardLayoutSetName = SubtypeLocale.getKeyboardLayoutSetName(subtype); final String keyboardLayoutSetName = SubtypeLocaleUtils.getKeyboardLayoutSetName(subtype);
return mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( return mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
localeString, keyboardLayoutSetName); localeString, keyboardLayoutSetName);
} }
@ -543,7 +543,7 @@ public final class AdditionalSubtypeSettings extends PreferenceFragment {
final PreferenceGroup group = getPreferenceScreen(); final PreferenceGroup group = getPreferenceScreen();
group.removeAll(); group.removeAll();
final InputMethodSubtype[] subtypesArray = final InputMethodSubtype[] subtypesArray =
AdditionalSubtype.createAdditionalSubtypesArray(prefSubtypes); AdditionalSubtypeUtils.createAdditionalSubtypesArray(prefSubtypes);
for (final InputMethodSubtype subtype : subtypesArray) { for (final InputMethodSubtype subtype : subtypesArray) {
final SubtypePreference pref = new SubtypePreference( final SubtypePreference pref = new SubtypePreference(
context, subtype, mSubtypeProxy); context, subtype, mSubtypeProxy);
@ -572,7 +572,7 @@ public final class AdditionalSubtypeSettings extends PreferenceFragment {
super.onPause(); super.onPause();
final String oldSubtypes = Settings.readPrefAdditionalSubtypes(mPrefs, getResources()); final String oldSubtypes = Settings.readPrefAdditionalSubtypes(mPrefs, getResources());
final InputMethodSubtype[] subtypes = getSubtypes(); final InputMethodSubtype[] subtypes = getSubtypes();
final String prefSubtypes = AdditionalSubtype.createPrefSubtypes(subtypes); final String prefSubtypes = AdditionalSubtypeUtils.createPrefSubtypes(subtypes);
if (prefSubtypes.equals(oldSubtypes)) { if (prefSubtypes.equals(oldSubtypes)) {
return; return;
} }

View File

@ -24,9 +24,9 @@ import android.preference.PreferenceManager;
import android.util.Log; import android.util.Log;
import com.android.inputmethod.latin.AudioAndHapticFeedbackManager; import com.android.inputmethod.latin.AudioAndHapticFeedbackManager;
import com.android.inputmethod.latin.AdditionalSubtype;
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.utils.AdditionalSubtypeUtils;
import com.android.inputmethod.latin.utils.LocaleUtils; import com.android.inputmethod.latin.utils.LocaleUtils;
import com.android.inputmethod.latin.utils.LocaleUtils.RunInLocale; import com.android.inputmethod.latin.utils.LocaleUtils.RunInLocale;
import com.android.inputmethod.latin.utils.ResourceUtils; import com.android.inputmethod.latin.utils.ResourceUtils;
@ -241,7 +241,7 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
public static String readPrefAdditionalSubtypes(final SharedPreferences prefs, public static String readPrefAdditionalSubtypes(final SharedPreferences prefs,
final Resources res) { final Resources res) {
final String predefinedPrefSubtypes = AdditionalSubtype.createPrefSubtypes( final String predefinedPrefSubtypes = AdditionalSubtypeUtils.createPrefSubtypes(
res.getStringArray(R.array.predefined_subtypes)); res.getStringArray(R.array.predefined_subtypes));
return prefs.getString(PREF_CUSTOM_INPUT_STYLES, predefinedPrefSubtypes); return prefs.getString(PREF_CUSTOM_INPUT_STYLES, predefinedPrefSubtypes);
} }

View File

@ -37,17 +37,17 @@ import android.util.Log;
import android.view.inputmethod.InputMethodSubtype; import android.view.inputmethod.InputMethodSubtype;
import com.android.inputmethod.dictionarypack.DictionarySettingsActivity; import com.android.inputmethod.dictionarypack.DictionarySettingsActivity;
import com.android.inputmethod.latin.AdditionalSubtype;
import com.android.inputmethod.latin.AudioAndHapticFeedbackManager; import com.android.inputmethod.latin.AudioAndHapticFeedbackManager;
import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.SubtypeLocale;
import com.android.inputmethod.latin.SubtypeSwitcher; import com.android.inputmethod.latin.SubtypeSwitcher;
import com.android.inputmethod.latin.define.ProductionFlag; import com.android.inputmethod.latin.define.ProductionFlag;
import com.android.inputmethod.latin.setup.LauncherIconVisibilityManager; import com.android.inputmethod.latin.setup.LauncherIconVisibilityManager;
import com.android.inputmethod.latin.userdictionary.UserDictionaryList; import com.android.inputmethod.latin.userdictionary.UserDictionaryList;
import com.android.inputmethod.latin.userdictionary.UserDictionarySettings; import com.android.inputmethod.latin.userdictionary.UserDictionarySettings;
import com.android.inputmethod.latin.utils.AdditionalSubtypeUtils;
import com.android.inputmethod.latin.utils.ApplicationUtils; import com.android.inputmethod.latin.utils.ApplicationUtils;
import com.android.inputmethod.latin.utils.FeedbackUtils; import com.android.inputmethod.latin.utils.FeedbackUtils;
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
import com.android.inputmethod.research.ResearchLogger; import com.android.inputmethod.research.ResearchLogger;
import com.android.inputmethodcommon.InputMethodSettingsFragment; import com.android.inputmethodcommon.InputMethodSettingsFragment;
@ -104,7 +104,7 @@ public final class SettingsFragment extends InputMethodSettingsFragment
// singleton and utility classes may not have been initialized. We have to call // singleton and utility classes may not have been initialized. We have to call
// initialization method of these classes here. See {@link LatinIME#onCreate()}. // initialization method of these classes here. See {@link LatinIME#onCreate()}.
SubtypeSwitcher.init(context); SubtypeSwitcher.init(context);
SubtypeLocale.init(context); SubtypeLocaleUtils.init(context);
AudioAndHapticFeedbackManager.init(context); AudioAndHapticFeedbackManager.init(context);
mVoicePreference = (ListPreference) findPreference(Settings.PREF_VOICE_MODE); mVoicePreference = (ListPreference) findPreference(Settings.PREF_VOICE_MODE);
@ -314,11 +314,11 @@ public final class SettingsFragment extends InputMethodSettingsFragment
final Resources res = getResources(); final Resources res = getResources();
final String prefSubtype = Settings.readPrefAdditionalSubtypes(prefs, res); final String prefSubtype = Settings.readPrefAdditionalSubtypes(prefs, res);
final InputMethodSubtype[] subtypes = final InputMethodSubtype[] subtypes =
AdditionalSubtype.createAdditionalSubtypesArray(prefSubtype); AdditionalSubtypeUtils.createAdditionalSubtypesArray(prefSubtype);
final StringBuilder styles = new StringBuilder(); final StringBuilder styles = new StringBuilder();
for (final InputMethodSubtype subtype : subtypes) { for (final InputMethodSubtype subtype : subtypes) {
if (styles.length() > 0) styles.append(", "); if (styles.length() > 0) styles.append(", ");
styles.append(SubtypeLocale.getSubtypeDisplayNameInSystemLocale(subtype)); styles.append(SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(subtype));
} }
customInputStyles.setSummary(styles); customInputStyles.setSummary(styles);
} }

View File

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package com.android.inputmethod.latin; package com.android.inputmethod.latin.utils;
import static com.android.inputmethod.latin.Constants.Subtype.KEYBOARD_MODE; import static com.android.inputmethod.latin.Constants.Subtype.KEYBOARD_MODE;
import static com.android.inputmethod.latin.Constants.Subtype.ExtraValue.IS_ADDITIONAL_SUBTYPE; import static com.android.inputmethod.latin.Constants.Subtype.ExtraValue.IS_ADDITIONAL_SUBTYPE;
@ -25,15 +25,14 @@ import android.os.Build;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.inputmethod.InputMethodSubtype; import android.view.inputmethod.InputMethodSubtype;
import com.android.inputmethod.latin.utils.CollectionUtils; import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.utils.StringUtils;
import java.util.ArrayList; import java.util.ArrayList;
public final class AdditionalSubtype { public final class AdditionalSubtypeUtils {
private static final InputMethodSubtype[] EMPTY_SUBTYPE_ARRAY = new InputMethodSubtype[0]; private static final InputMethodSubtype[] EMPTY_SUBTYPE_ARRAY = new InputMethodSubtype[0];
private AdditionalSubtype() { private AdditionalSubtypeUtils() {
// This utility class is not publicly instantiable. // This utility class is not publicly instantiable.
} }
@ -49,8 +48,8 @@ public final class AdditionalSubtype {
final String layoutExtraValue = KEYBOARD_LAYOUT_SET + "=" + keyboardLayoutSetName; final String layoutExtraValue = KEYBOARD_LAYOUT_SET + "=" + keyboardLayoutSetName;
final String layoutDisplayNameExtraValue; final String layoutDisplayNameExtraValue;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN
&& SubtypeLocale.isExceptionalLocale(localeString)) { && SubtypeLocaleUtils.isExceptionalLocale(localeString)) {
final String layoutDisplayName = SubtypeLocale.getKeyboardLayoutSetDisplayName( final String layoutDisplayName = SubtypeLocaleUtils.getKeyboardLayoutSetDisplayName(
keyboardLayoutSetName); keyboardLayoutSetName);
layoutDisplayNameExtraValue = StringUtils.appendToCommaSplittableTextIfNotExists( layoutDisplayNameExtraValue = StringUtils.appendToCommaSplittableTextIfNotExists(
UNTRANSLATABLE_STRING_IN_SUBTYPE_NAME + "=" + layoutDisplayName, extraValue); UNTRANSLATABLE_STRING_IN_SUBTYPE_NAME + "=" + layoutDisplayName, extraValue);
@ -60,7 +59,7 @@ public final class AdditionalSubtype {
final String additionalSubtypeExtraValue = final String additionalSubtypeExtraValue =
StringUtils.appendToCommaSplittableTextIfNotExists( StringUtils.appendToCommaSplittableTextIfNotExists(
IS_ADDITIONAL_SUBTYPE, layoutDisplayNameExtraValue); IS_ADDITIONAL_SUBTYPE, layoutDisplayNameExtraValue);
final int nameId = SubtypeLocale.getSubtypeNameId(localeString, keyboardLayoutSetName); final int nameId = SubtypeLocaleUtils.getSubtypeNameId(localeString, keyboardLayoutSetName);
return new InputMethodSubtype(nameId, R.drawable.ic_subtype_keyboard, return new InputMethodSubtype(nameId, R.drawable.ic_subtype_keyboard,
localeString, KEYBOARD_MODE, localeString, KEYBOARD_MODE,
layoutExtraValue + "," + additionalSubtypeExtraValue, false, false); layoutExtraValue + "," + additionalSubtypeExtraValue, false, false);
@ -68,7 +67,7 @@ public final class AdditionalSubtype {
public static String getPrefSubtype(final InputMethodSubtype subtype) { public static String getPrefSubtype(final InputMethodSubtype subtype) {
final String localeString = subtype.getLocale(); final String localeString = subtype.getLocale();
final String keyboardLayoutSetName = SubtypeLocale.getKeyboardLayoutSetName(subtype); final String keyboardLayoutSetName = SubtypeLocaleUtils.getKeyboardLayoutSetName(subtype);
final String layoutExtraValue = KEYBOARD_LAYOUT_SET + "=" + keyboardLayoutSetName; final String layoutExtraValue = KEYBOARD_LAYOUT_SET + "=" + keyboardLayoutSetName;
final String extraValue = StringUtils.removeFromCommaSplittableTextIfExists( final String extraValue = StringUtils.removeFromCommaSplittableTextIfExists(
layoutExtraValue, StringUtils.removeFromCommaSplittableTextIfExists( layoutExtraValue, StringUtils.removeFromCommaSplittableTextIfExists(
@ -99,7 +98,7 @@ public final class AdditionalSubtype {
CollectionUtils.newArrayList(prefSubtypeArray.length); CollectionUtils.newArrayList(prefSubtypeArray.length);
for (final String prefSubtype : prefSubtypeArray) { for (final String prefSubtype : prefSubtypeArray) {
final InputMethodSubtype subtype = createAdditionalSubtype(prefSubtype); final InputMethodSubtype subtype = createAdditionalSubtype(prefSubtype);
if (subtype.getNameResId() == SubtypeLocale.UNKNOWN_KEYBOARD_LAYOUT) { if (subtype.getNameResId() == SubtypeLocaleUtils.UNKNOWN_KEYBOARD_LAYOUT) {
// Skip unknown keyboard layout subtype. This may happen when predefined keyboard // Skip unknown keyboard layout subtype. This may happen when predefined keyboard
// layout has been removed. // layout has been removed.
continue; continue;

View File

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package com.android.inputmethod.latin; package com.android.inputmethod.latin.utils;
import static com.android.inputmethod.latin.Constants.Subtype.ExtraValue.KEYBOARD_LAYOUT_SET; import static com.android.inputmethod.latin.Constants.Subtype.ExtraValue.KEYBOARD_LAYOUT_SET;
import static com.android.inputmethod.latin.Constants.Subtype.ExtraValue.UNTRANSLATABLE_STRING_IN_SUBTYPE_NAME; import static com.android.inputmethod.latin.Constants.Subtype.ExtraValue.UNTRANSLATABLE_STRING_IN_SUBTYPE_NAME;
@ -25,17 +25,15 @@ import android.os.Build;
import android.util.Log; import android.util.Log;
import android.view.inputmethod.InputMethodSubtype; import android.view.inputmethod.InputMethodSubtype;
import com.android.inputmethod.latin.utils.CollectionUtils; import com.android.inputmethod.latin.DictionaryFactory;
import com.android.inputmethod.latin.utils.DebugLogUtils; import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.utils.LocaleUtils;
import com.android.inputmethod.latin.utils.LocaleUtils.RunInLocale; import com.android.inputmethod.latin.utils.LocaleUtils.RunInLocale;
import com.android.inputmethod.latin.utils.StringUtils;
import java.util.HashMap; import java.util.HashMap;
import java.util.Locale; import java.util.Locale;
public final class SubtypeLocale { public final class SubtypeLocaleUtils {
static final String TAG = SubtypeLocale.class.getSimpleName(); static final String TAG = SubtypeLocaleUtils.class.getSimpleName();
// This class must be located in the same package as LatinIME.java. // This class must be located in the same package as LatinIME.java.
private static final String RESOURCE_PACKAGE_NAME = private static final String RESOURCE_PACKAGE_NAME =
DictionaryFactory.class.getPackage().getName(); DictionaryFactory.class.getPackage().getName();
@ -73,7 +71,7 @@ public final class SubtypeLocale {
private static final HashMap<String, String> sLocaleAndExtraValueToKeyboardLayoutSetMap = private static final HashMap<String, String> sLocaleAndExtraValueToKeyboardLayoutSetMap =
CollectionUtils.newHashMap(); CollectionUtils.newHashMap();
private SubtypeLocale() { private SubtypeLocaleUtils() {
// Intentional empty constructor for utility class. // Intentional empty constructor for utility class.
} }

View File

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package com.android.inputmethod.latin; package com.android.inputmethod.latin.utils;
import android.content.Context; import android.content.Context;
import android.content.res.Resources; import android.content.res.Resources;
@ -22,15 +22,15 @@ import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.SmallTest; import android.test.suitebuilder.annotation.SmallTest;
import android.view.inputmethod.InputMethodSubtype; import android.view.inputmethod.InputMethodSubtype;
import com.android.inputmethod.latin.utils.CollectionUtils; import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.RichInputMethodManager;
import com.android.inputmethod.latin.utils.LocaleUtils.RunInLocale; import com.android.inputmethod.latin.utils.LocaleUtils.RunInLocale;
import com.android.inputmethod.latin.utils.StringUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Locale; import java.util.Locale;
@SmallTest @SmallTest
public class SubtypeLocaleTests extends AndroidTestCase { public class SubtypeLocaleUtilsTests extends AndroidTestCase {
// Locale to subtypes list. // Locale to subtypes list.
private final ArrayList<InputMethodSubtype> mSubtypesList = CollectionUtils.newArrayList(); private final ArrayList<InputMethodSubtype> mSubtypesList = CollectionUtils.newArrayList();
@ -59,7 +59,7 @@ public class SubtypeLocaleTests extends AndroidTestCase {
RichInputMethodManager.init(context); RichInputMethodManager.init(context);
mRichImm = RichInputMethodManager.getInstance(); mRichImm = RichInputMethodManager.getInstance();
mRes = context.getResources(); mRes = context.getResources();
SubtypeLocale.init(context); SubtypeLocaleUtils.init(context);
EN_US = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( EN_US = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
Locale.US.toString(), "qwerty"); Locale.US.toString(), "qwerty");
@ -74,46 +74,47 @@ public class SubtypeLocaleTests extends AndroidTestCase {
DE = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( DE = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
Locale.GERMAN.toString(), "qwertz"); Locale.GERMAN.toString(), "qwertz");
ZZ = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( ZZ = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
SubtypeLocale.NO_LANGUAGE, "qwerty"); SubtypeLocaleUtils.NO_LANGUAGE, "qwerty");
DE_QWERTY = AdditionalSubtype.createAdditionalSubtype( DE_QWERTY = AdditionalSubtypeUtils.createAdditionalSubtype(
Locale.GERMAN.toString(), "qwerty", null); Locale.GERMAN.toString(), "qwerty", null);
FR_QWERTZ = AdditionalSubtype.createAdditionalSubtype( FR_QWERTZ = AdditionalSubtypeUtils.createAdditionalSubtype(
Locale.FRENCH.toString(), "qwertz", null); Locale.FRENCH.toString(), "qwertz", null);
EN_US_AZERTY = AdditionalSubtype.createAdditionalSubtype( EN_US_AZERTY = AdditionalSubtypeUtils.createAdditionalSubtype(
Locale.US.toString(), "azerty", null); Locale.US.toString(), "azerty", null);
EN_UK_DVORAK = AdditionalSubtype.createAdditionalSubtype( EN_UK_DVORAK = AdditionalSubtypeUtils.createAdditionalSubtype(
Locale.UK.toString(), "dvorak", null); Locale.UK.toString(), "dvorak", null);
ES_US_COLEMAK = AdditionalSubtype.createAdditionalSubtype( ES_US_COLEMAK = AdditionalSubtypeUtils.createAdditionalSubtype(
"es_US", "colemak", null); "es_US", "colemak", null);
ZZ_AZERTY = AdditionalSubtype.createAdditionalSubtype( ZZ_AZERTY = AdditionalSubtypeUtils.createAdditionalSubtype(
SubtypeLocale.NO_LANGUAGE, "azerty", null); SubtypeLocaleUtils.NO_LANGUAGE, "azerty", null);
ZZ_PC = AdditionalSubtype.createAdditionalSubtype( ZZ_PC = AdditionalSubtypeUtils.createAdditionalSubtype(
SubtypeLocale.NO_LANGUAGE, "pcqwerty", null); SubtypeLocaleUtils.NO_LANGUAGE, "pcqwerty", null);
} }
public void testAllFullDisplayName() { public void testAllFullDisplayName() {
for (final InputMethodSubtype subtype : mSubtypesList) { for (final InputMethodSubtype subtype : mSubtypesList) {
final String subtypeName = SubtypeLocale.getSubtypeDisplayNameInSystemLocale(subtype); final String subtypeName =
if (SubtypeLocale.isNoLanguage(subtype)) { SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(subtype);
if (SubtypeLocaleUtils.isNoLanguage(subtype)) {
final String noLanguage = mRes.getString(R.string.subtype_no_language); final String noLanguage = mRes.getString(R.string.subtype_no_language);
assertTrue(subtypeName, subtypeName.contains(noLanguage)); assertTrue(subtypeName, subtypeName.contains(noLanguage));
} else { } else {
final String languageName = final String languageName =
SubtypeLocale.getSubtypeLocaleDisplayName(subtype.getLocale()); SubtypeLocaleUtils.getSubtypeLocaleDisplayName(subtype.getLocale());
assertTrue(subtypeName, subtypeName.contains(languageName)); assertTrue(subtypeName, subtypeName.contains(languageName));
} }
} }
} }
public void testKeyboardLayoutSetName() { public void testKeyboardLayoutSetName() {
assertEquals("en_US", "qwerty", SubtypeLocale.getKeyboardLayoutSetName(EN_US)); assertEquals("en_US", "qwerty", SubtypeLocaleUtils.getKeyboardLayoutSetName(EN_US));
assertEquals("en_GB", "qwerty", SubtypeLocale.getKeyboardLayoutSetName(EN_GB)); assertEquals("en_GB", "qwerty", SubtypeLocaleUtils.getKeyboardLayoutSetName(EN_GB));
assertEquals("es_US", "spanish", SubtypeLocale.getKeyboardLayoutSetName(ES_US)); assertEquals("es_US", "spanish", SubtypeLocaleUtils.getKeyboardLayoutSetName(ES_US));
assertEquals("fr ", "azerty", SubtypeLocale.getKeyboardLayoutSetName(FR)); assertEquals("fr ", "azerty", SubtypeLocaleUtils.getKeyboardLayoutSetName(FR));
assertEquals("fr_CA", "qwerty", SubtypeLocale.getKeyboardLayoutSetName(FR_CA)); assertEquals("fr_CA", "qwerty", SubtypeLocaleUtils.getKeyboardLayoutSetName(FR_CA));
assertEquals("de ", "qwertz", SubtypeLocale.getKeyboardLayoutSetName(DE)); assertEquals("de ", "qwertz", SubtypeLocaleUtils.getKeyboardLayoutSetName(DE));
assertEquals("zz ", "qwerty", SubtypeLocale.getKeyboardLayoutSetName(ZZ)); assertEquals("zz ", "qwerty", SubtypeLocaleUtils.getKeyboardLayoutSetName(ZZ));
} }
// InputMethodSubtype's display name in system locale (en_US). // InputMethodSubtype's display name in system locale (en_US).
@ -139,19 +140,19 @@ public class SubtypeLocaleTests extends AndroidTestCase {
@Override @Override
protected Void job(Resources res) { protected Void job(Resources res) {
assertEquals("en_US", "English (US)", assertEquals("en_US", "English (US)",
SubtypeLocale.getSubtypeDisplayNameInSystemLocale(EN_US)); SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(EN_US));
assertEquals("en_GB", "English (UK)", assertEquals("en_GB", "English (UK)",
SubtypeLocale.getSubtypeDisplayNameInSystemLocale(EN_GB)); SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(EN_GB));
assertEquals("es_US", "Spanish (US)", assertEquals("es_US", "Spanish (US)",
SubtypeLocale.getSubtypeDisplayNameInSystemLocale(ES_US)); SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(ES_US));
assertEquals("fr ", "French", assertEquals("fr ", "French",
SubtypeLocale.getSubtypeDisplayNameInSystemLocale(FR)); SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(FR));
assertEquals("fr_CA", "French (Canada)", assertEquals("fr_CA", "French (Canada)",
SubtypeLocale.getSubtypeDisplayNameInSystemLocale(FR_CA)); SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(FR_CA));
assertEquals("de ", "German", assertEquals("de ", "German",
SubtypeLocale.getSubtypeDisplayNameInSystemLocale(DE)); SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(DE));
assertEquals("zz ", "No language (QWERTY)", assertEquals("zz ", "No language (QWERTY)",
SubtypeLocale.getSubtypeDisplayNameInSystemLocale(ZZ)); SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(ZZ));
return null; return null;
} }
}; };
@ -163,17 +164,17 @@ public class SubtypeLocaleTests extends AndroidTestCase {
@Override @Override
protected Void job(Resources res) { protected Void job(Resources res) {
assertEquals("fr qwertz", "French (QWERTZ)", assertEquals("fr qwertz", "French (QWERTZ)",
SubtypeLocale.getSubtypeDisplayNameInSystemLocale(FR_QWERTZ)); SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(FR_QWERTZ));
assertEquals("de qwerty", "German (QWERTY)", assertEquals("de qwerty", "German (QWERTY)",
SubtypeLocale.getSubtypeDisplayNameInSystemLocale(DE_QWERTY)); SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(DE_QWERTY));
assertEquals("en_US azerty", "English (US) (AZERTY)", assertEquals("en_US azerty", "English (US) (AZERTY)",
SubtypeLocale.getSubtypeDisplayNameInSystemLocale(EN_US_AZERTY)); SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(EN_US_AZERTY));
assertEquals("en_UK dvorak", "English (UK) (Dvorak)", assertEquals("en_UK dvorak", "English (UK) (Dvorak)",
SubtypeLocale.getSubtypeDisplayNameInSystemLocale(EN_UK_DVORAK)); SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(EN_UK_DVORAK));
assertEquals("es_US colemak","Spanish (US) (Colemak)", assertEquals("es_US colemak","Spanish (US) (Colemak)",
SubtypeLocale.getSubtypeDisplayNameInSystemLocale(ES_US_COLEMAK)); SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(ES_US_COLEMAK));
assertEquals("zz azerty", "No language (PC)", assertEquals("zz azerty", "No language (PC)",
SubtypeLocale.getSubtypeDisplayNameInSystemLocale(ZZ_PC)); SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(ZZ_PC));
return null; return null;
} }
}; };
@ -203,19 +204,19 @@ public class SubtypeLocaleTests extends AndroidTestCase {
@Override @Override
protected Void job(Resources res) { protected Void job(Resources res) {
assertEquals("en_US", "Anglais (États-Unis)", assertEquals("en_US", "Anglais (États-Unis)",
SubtypeLocale.getSubtypeDisplayNameInSystemLocale(EN_US)); SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(EN_US));
assertEquals("en_GB", "Anglais (Royaume-Uni)", assertEquals("en_GB", "Anglais (Royaume-Uni)",
SubtypeLocale.getSubtypeDisplayNameInSystemLocale(EN_GB)); SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(EN_GB));
assertEquals("es_US", "Espagnol (États-Unis)", assertEquals("es_US", "Espagnol (États-Unis)",
SubtypeLocale.getSubtypeDisplayNameInSystemLocale(ES_US)); SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(ES_US));
assertEquals("fr ", "Français", assertEquals("fr ", "Français",
SubtypeLocale.getSubtypeDisplayNameInSystemLocale(FR)); SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(FR));
assertEquals("fr_CA", "Français (Canada)", assertEquals("fr_CA", "Français (Canada)",
SubtypeLocale.getSubtypeDisplayNameInSystemLocale(FR_CA)); SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(FR_CA));
assertEquals("de ", "Allemand", assertEquals("de ", "Allemand",
SubtypeLocale.getSubtypeDisplayNameInSystemLocale(DE)); SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(DE));
assertEquals("zz ", "Aucune langue (QWERTY)", assertEquals("zz ", "Aucune langue (QWERTY)",
SubtypeLocale.getSubtypeDisplayNameInSystemLocale(ZZ)); SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(ZZ));
return null; return null;
} }
}; };
@ -227,17 +228,17 @@ public class SubtypeLocaleTests extends AndroidTestCase {
@Override @Override
protected Void job(Resources res) { protected Void job(Resources res) {
assertEquals("fr qwertz", "Français (QWERTZ)", assertEquals("fr qwertz", "Français (QWERTZ)",
SubtypeLocale.getSubtypeDisplayNameInSystemLocale(FR_QWERTZ)); SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(FR_QWERTZ));
assertEquals("de qwerty", "Allemand (QWERTY)", assertEquals("de qwerty", "Allemand (QWERTY)",
SubtypeLocale.getSubtypeDisplayNameInSystemLocale(DE_QWERTY)); SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(DE_QWERTY));
assertEquals("en_US azerty", "Anglais (États-Unis) (AZERTY)", assertEquals("en_US azerty", "Anglais (États-Unis) (AZERTY)",
SubtypeLocale.getSubtypeDisplayNameInSystemLocale(EN_US_AZERTY)); SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(EN_US_AZERTY));
assertEquals("en_UK dvorak", "Anglais (Royaume-Uni) (Dvorak)", assertEquals("en_UK dvorak", "Anglais (Royaume-Uni) (Dvorak)",
SubtypeLocale.getSubtypeDisplayNameInSystemLocale(EN_UK_DVORAK)); SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(EN_UK_DVORAK));
assertEquals("es_US colemak","Espagnol (États-Unis) (Colemak)", assertEquals("es_US colemak","Espagnol (États-Unis) (Colemak)",
SubtypeLocale.getSubtypeDisplayNameInSystemLocale(ES_US_COLEMAK)); SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(ES_US_COLEMAK));
assertEquals("zz azerty", "Aucune langue (PC)", assertEquals("zz azerty", "Aucune langue (PC)",
SubtypeLocale.getSubtypeDisplayNameInSystemLocale(ZZ_PC)); SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(ZZ_PC));
return null; return null;
} }
}; };
@ -246,11 +247,12 @@ public class SubtypeLocaleTests extends AndroidTestCase {
public void testAllFullDisplayNameForSpacebar() { public void testAllFullDisplayNameForSpacebar() {
for (final InputMethodSubtype subtype : mSubtypesList) { for (final InputMethodSubtype subtype : mSubtypesList) {
final String subtypeName = SubtypeLocale.getSubtypeDisplayNameInSystemLocale(subtype); final String subtypeName =
final String spacebarText = SubtypeLocale.getFullDisplayName(subtype); SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(subtype);
final String spacebarText = SubtypeLocaleUtils.getFullDisplayName(subtype);
final String languageName = final String languageName =
SubtypeLocale.getSubtypeLocaleDisplayName(subtype.getLocale()); SubtypeLocaleUtils.getSubtypeLocaleDisplayName(subtype.getLocale());
if (SubtypeLocale.isNoLanguage(subtype)) { 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));
@ -260,14 +262,15 @@ public class SubtypeLocaleTests extends AndroidTestCase {
public void testAllMiddleDisplayNameForSpacebar() { public void testAllMiddleDisplayNameForSpacebar() {
for (final InputMethodSubtype subtype : mSubtypesList) { for (final InputMethodSubtype subtype : mSubtypesList) {
final String subtypeName = SubtypeLocale.getSubtypeDisplayNameInSystemLocale(subtype); final String subtypeName =
final String spacebarText = SubtypeLocale.getMiddleDisplayName(subtype); SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(subtype);
if (SubtypeLocale.isNoLanguage(subtype)) { final String spacebarText = SubtypeLocaleUtils.getMiddleDisplayName(subtype);
if (SubtypeLocaleUtils.isNoLanguage(subtype)) {
assertEquals(subtypeName, assertEquals(subtypeName,
SubtypeLocale.getKeyboardLayoutSetName(subtype), spacebarText); SubtypeLocaleUtils.getKeyboardLayoutSetName(subtype), spacebarText);
} else { } else {
assertEquals(subtypeName, assertEquals(subtypeName,
SubtypeLocale.getSubtypeLocaleDisplayName(subtype.getLocale()), SubtypeLocaleUtils.getSubtypeLocaleDisplayName(subtype.getLocale()),
spacebarText); spacebarText);
} }
} }
@ -275,12 +278,13 @@ public class SubtypeLocaleTests extends AndroidTestCase {
public void testAllShortDisplayNameForSpacebar() { public void testAllShortDisplayNameForSpacebar() {
for (final InputMethodSubtype subtype : mSubtypesList) { for (final InputMethodSubtype subtype : mSubtypesList) {
final String subtypeName = SubtypeLocale.getSubtypeDisplayNameInSystemLocale(subtype); final String subtypeName =
final Locale locale = SubtypeLocale.getSubtypeLocale(subtype); SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(subtype);
final String spacebarText = SubtypeLocale.getShortDisplayName(subtype); final Locale locale = SubtypeLocaleUtils.getSubtypeLocale(subtype);
final String spacebarText = SubtypeLocaleUtils.getShortDisplayName(subtype);
final String languageCode = StringUtils.capitalizeFirstCodePoint( final String languageCode = StringUtils.capitalizeFirstCodePoint(
locale.getLanguage(), locale); locale.getLanguage(), locale);
if (SubtypeLocale.isNoLanguage(subtype)) { if (SubtypeLocaleUtils.isNoLanguage(subtype)) {
assertEquals(subtypeName, "", spacebarText); assertEquals(subtypeName, "", spacebarText);
} else { } else {
assertEquals(subtypeName, languageCode, spacebarText); assertEquals(subtypeName, languageCode, spacebarText);
@ -307,29 +311,31 @@ public class SubtypeLocaleTests extends AndroidTestCase {
private final RunInLocale<Void> testsPredefinedSubtypesForSpacebar = new RunInLocale<Void>() { private final RunInLocale<Void> testsPredefinedSubtypesForSpacebar = new RunInLocale<Void>() {
@Override @Override
protected Void job(Resources res) { protected Void job(Resources res) {
assertEquals("en_US", "English (US)", SubtypeLocale.getFullDisplayName(EN_US)); assertEquals("en_US", "English (US)", SubtypeLocaleUtils.getFullDisplayName(EN_US));
assertEquals("en_GB", "English (UK)", SubtypeLocale.getFullDisplayName(EN_GB)); assertEquals("en_GB", "English (UK)", SubtypeLocaleUtils.getFullDisplayName(EN_GB));
assertEquals("es_US", "Español (EE.UU.)", SubtypeLocale.getFullDisplayName(ES_US)); assertEquals("es_US", "Español (EE.UU.)",
assertEquals("fr ", "Français", SubtypeLocale.getFullDisplayName(FR)); SubtypeLocaleUtils.getFullDisplayName(ES_US));
assertEquals("fr_CA", "Français (Canada)", SubtypeLocale.getFullDisplayName(FR_CA)); assertEquals("fr ", "Français", SubtypeLocaleUtils.getFullDisplayName(FR));
assertEquals("de ", "Deutsch", SubtypeLocale.getFullDisplayName(DE)); assertEquals("fr_CA", "Français (Canada)",
assertEquals("zz ", "QWERTY", SubtypeLocale.getFullDisplayName(ZZ)); SubtypeLocaleUtils.getFullDisplayName(FR_CA));
assertEquals("de ", "Deutsch", SubtypeLocaleUtils.getFullDisplayName(DE));
assertEquals("zz ", "QWERTY", SubtypeLocaleUtils.getFullDisplayName(ZZ));
assertEquals("en_US", "English", SubtypeLocale.getMiddleDisplayName(EN_US)); assertEquals("en_US", "English", SubtypeLocaleUtils.getMiddleDisplayName(EN_US));
assertEquals("en_GB", "English", SubtypeLocale.getMiddleDisplayName(EN_GB)); assertEquals("en_GB", "English", SubtypeLocaleUtils.getMiddleDisplayName(EN_GB));
assertEquals("es_US", "Español", SubtypeLocale.getMiddleDisplayName(ES_US)); assertEquals("es_US", "Español", SubtypeLocaleUtils.getMiddleDisplayName(ES_US));
assertEquals("fr ", "Français", SubtypeLocale.getMiddleDisplayName(FR)); assertEquals("fr ", "Français", SubtypeLocaleUtils.getMiddleDisplayName(FR));
assertEquals("fr_CA", "Français", SubtypeLocale.getMiddleDisplayName(FR_CA)); assertEquals("fr_CA", "Français", SubtypeLocaleUtils.getMiddleDisplayName(FR_CA));
assertEquals("de ", "Deutsch", SubtypeLocale.getMiddleDisplayName(DE)); assertEquals("de ", "Deutsch", SubtypeLocaleUtils.getMiddleDisplayName(DE));
assertEquals("zz ", "QWERTY", SubtypeLocale.getMiddleDisplayName(ZZ)); assertEquals("zz ", "QWERTY", SubtypeLocaleUtils.getMiddleDisplayName(ZZ));
assertEquals("en_US", "En", SubtypeLocale.getShortDisplayName(EN_US)); assertEquals("en_US", "En", SubtypeLocaleUtils.getShortDisplayName(EN_US));
assertEquals("en_GB", "En", SubtypeLocale.getShortDisplayName(EN_GB)); assertEquals("en_GB", "En", SubtypeLocaleUtils.getShortDisplayName(EN_GB));
assertEquals("es_US", "Es", SubtypeLocale.getShortDisplayName(ES_US)); assertEquals("es_US", "Es", SubtypeLocaleUtils.getShortDisplayName(ES_US));
assertEquals("fr ", "Fr", SubtypeLocale.getShortDisplayName(FR)); assertEquals("fr ", "Fr", SubtypeLocaleUtils.getShortDisplayName(FR));
assertEquals("fr_CA", "Fr", SubtypeLocale.getShortDisplayName(FR_CA)); assertEquals("fr_CA", "Fr", SubtypeLocaleUtils.getShortDisplayName(FR_CA));
assertEquals("de ", "De", SubtypeLocale.getShortDisplayName(DE)); assertEquals("de ", "De", SubtypeLocaleUtils.getShortDisplayName(DE));
assertEquals("zz ", "", SubtypeLocale.getShortDisplayName(ZZ)); assertEquals("zz ", "", SubtypeLocaleUtils.getShortDisplayName(ZZ));
return null; return null;
} }
}; };
@ -338,27 +344,28 @@ public class SubtypeLocaleTests extends AndroidTestCase {
@Override @Override
protected Void job(Resources res) { protected Void job(Resources res) {
assertEquals("fr qwertz", "Français", assertEquals("fr qwertz", "Français",
SubtypeLocale.getFullDisplayName(FR_QWERTZ)); SubtypeLocaleUtils.getFullDisplayName(FR_QWERTZ));
assertEquals("de qwerty", "Deutsch", assertEquals("de qwerty", "Deutsch",
SubtypeLocale.getFullDisplayName(DE_QWERTY)); SubtypeLocaleUtils.getFullDisplayName(DE_QWERTY));
assertEquals("en_US azerty", "English (US)", assertEquals("en_US azerty", "English (US)",
SubtypeLocale.getFullDisplayName(EN_US_AZERTY)); SubtypeLocaleUtils.getFullDisplayName(EN_US_AZERTY));
assertEquals("zz azerty", "AZERTY", assertEquals("zz azerty", "AZERTY",
SubtypeLocale.getFullDisplayName(ZZ_AZERTY)); SubtypeLocaleUtils.getFullDisplayName(ZZ_AZERTY));
assertEquals("fr qwertz", "Français", assertEquals("fr qwertz", "Français",
SubtypeLocale.getMiddleDisplayName(FR_QWERTZ)); SubtypeLocaleUtils.getMiddleDisplayName(FR_QWERTZ));
assertEquals("de qwerty", "Deutsch", assertEquals("de qwerty", "Deutsch",
SubtypeLocale.getMiddleDisplayName(DE_QWERTY)); SubtypeLocaleUtils.getMiddleDisplayName(DE_QWERTY));
assertEquals("en_US azerty", "English", assertEquals("en_US azerty", "English",
SubtypeLocale.getMiddleDisplayName(EN_US_AZERTY)); SubtypeLocaleUtils.getMiddleDisplayName(EN_US_AZERTY));
assertEquals("zz azerty", "AZERTY", assertEquals("zz azerty", "AZERTY",
SubtypeLocale.getMiddleDisplayName(ZZ_AZERTY)); SubtypeLocaleUtils.getMiddleDisplayName(ZZ_AZERTY));
assertEquals("fr qwertz", "Fr", SubtypeLocale.getShortDisplayName(FR_QWERTZ)); assertEquals("fr qwertz", "Fr", SubtypeLocaleUtils.getShortDisplayName(FR_QWERTZ));
assertEquals("de qwerty", "De", SubtypeLocale.getShortDisplayName(DE_QWERTY)); assertEquals("de qwerty", "De", SubtypeLocaleUtils.getShortDisplayName(DE_QWERTY));
assertEquals("en_US azerty", "En", SubtypeLocale.getShortDisplayName(EN_US_AZERTY)); assertEquals("en_US azerty", "En",
assertEquals("zz azerty", "", SubtypeLocale.getShortDisplayName(ZZ_AZERTY)); SubtypeLocaleUtils.getShortDisplayName(EN_US_AZERTY));
assertEquals("zz azerty", "", SubtypeLocaleUtils.getShortDisplayName(ZZ_AZERTY));
return null; return null;
} }
}; };