use of com.android.inputmethod.latin.RichInputMethodSubtype in project android_packages_inputmethods_LatinIME by CyanogenMod.
the class LanguageOnSpacebarUtils method getLanguageOnSpacebarFormatType.
public static int getLanguageOnSpacebarFormatType(@Nonnull final RichInputMethodSubtype subtype) {
if (subtype.isNoLanguage()) {
return FORMAT_TYPE_FULL_LOCALE;
}
// Only this subtype is enabled and equals to the system locale.
if (sEnabledSubtypes.size() < 2 && sIsSystemLanguageSameAsInputLanguage) {
return FORMAT_TYPE_NONE;
}
final Locale locale = subtype.getLocale();
if (locale == null) {
return FORMAT_TYPE_NONE;
}
final String keyboardLanguage = locale.getLanguage();
final String keyboardLayout = subtype.getKeyboardLayoutSetName();
int sameLanguageAndLayoutCount = 0;
for (final InputMethodSubtype ims : sEnabledSubtypes) {
final String language = SubtypeLocaleUtils.getSubtypeLocale(ims).getLanguage();
if (keyboardLanguage.equals(language) && keyboardLayout.equals(SubtypeLocaleUtils.getKeyboardLayoutSetName(ims))) {
sameLanguageAndLayoutCount++;
}
}
// locale and keyboard layout. Otherwise displaying language name is enough.
return sameLanguageAndLayoutCount > 1 ? FORMAT_TYPE_FULL_LOCALE : FORMAT_TYPE_LANGUAGE_ONLY;
}
use of com.android.inputmethod.latin.RichInputMethodSubtype in project android_packages_inputmethods_LatinIME by CyanogenMod.
the class RichInputMethodSubtypeTests method testAllMiddleDisplayNameForSpacebar.
public void testAllMiddleDisplayNameForSpacebar() {
for (final RichInputMethodSubtype subtype : mSubtypesList) {
final String subtypeName = SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(subtype.getRawSubtype());
final Locale locale = subtype.getLocale();
final Locale displayLocale = SubtypeLocaleUtils.getDisplayLocaleOfSubtypeLocale(locale.toString());
if (Locale.ROOT.equals(displayLocale)) {
// the locale to be displayed on the spacebar (for example Hinglish).
continue;
}
final String spacebarText = subtype.getMiddleDisplayName();
if (subtype.isNoLanguage()) {
assertEquals(subtypeName, SubtypeLocaleUtils.getKeyboardLayoutSetDisplayName(subtype.getRawSubtype()), spacebarText);
} else {
assertEquals(subtypeName, SubtypeLocaleUtils.getSubtypeLanguageDisplayName(locale.toString()), spacebarText);
}
}
}
use of com.android.inputmethod.latin.RichInputMethodSubtype in project android_packages_inputmethods_LatinIME by CyanogenMod.
the class SubtypeLocaleUtilsTests method testAllFullDisplayName.
public void testAllFullDisplayName() {
for (final RichInputMethodSubtype subtype : mSubtypesList) {
final String subtypeName = SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(subtype.getRawSubtype());
if (subtype.isNoLanguage()) {
final String layoutName = SubtypeLocaleUtils.getKeyboardLayoutSetDisplayName(subtype.getRawSubtype());
assertTrue(subtypeName, subtypeName.contains(layoutName));
} else {
final String languageName = SubtypeLocaleUtils.getSubtypeLocaleDisplayNameInSystemLocale(subtype.getLocale().toString());
assertTrue(subtypeName, subtypeName.contains(languageName));
}
}
}
use of com.android.inputmethod.latin.RichInputMethodSubtype in project android_packages_inputmethods_LatinIME by CyanogenMod.
the class SubtypeLocaleUtilsTests method testIsRtlLanguage.
public void testIsRtlLanguage() {
// Known Right-to-Left language subtypes.
final InputMethodSubtype ARABIC = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet("ar", "arabic");
assertNotNull("Arabic", ARABIC);
final InputMethodSubtype FARSI = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet("fa", "farsi");
assertNotNull("Farsi", FARSI);
final InputMethodSubtype HEBREW = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet("iw", "hebrew");
assertNotNull("Hebrew", HEBREW);
for (final RichInputMethodSubtype subtype : mSubtypesList) {
final InputMethodSubtype rawSubtype = subtype.getRawSubtype();
final String subtypeName = SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(rawSubtype);
if (rawSubtype.equals(ARABIC) || rawSubtype.equals(FARSI) || rawSubtype.equals(HEBREW)) {
assertTrue(subtypeName, subtype.isRtlSubtype());
} else {
assertFalse(subtypeName, subtype.isRtlSubtype());
}
}
}
use of com.android.inputmethod.latin.RichInputMethodSubtype in project android_packages_inputmethods_LatinIME by CyanogenMod.
the class RichInputMethodSubtypeTests method testRichInputMethodSubtypeForNullInputMethodSubtype.
public void testRichInputMethodSubtypeForNullInputMethodSubtype() {
RichInputMethodSubtype subtype = RichInputMethodSubtype.getRichInputMethodSubtype(null);
assertNotNull(subtype);
assertEquals("zz", subtype.getRawSubtype().getLocale());
assertEquals("keyboard", subtype.getRawSubtype().getMode());
}
Aggregations