use of android.view.inputmethod.InputMethodSubtype in project android_packages_inputmethods_LatinIME by CyanogenMod.
the class LatinIME method onCurrentInputMethodSubtypeChanged.
@Override
public void onCurrentInputMethodSubtypeChanged(final InputMethodSubtype subtype) {
// 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.
InputMethodSubtype oldSubtype = mRichImm.getCurrentSubtype().getRawSubtype();
StatsUtils.onSubtypeChanged(oldSubtype, subtype);
mRichImm.onSubtypeChanged(subtype);
mInputLogic.onSubtypeChanged(SubtypeLocaleUtils.getCombiningRulesExtraValue(subtype), mSettings.getCurrent());
loadKeyboard();
}
use of android.view.inputmethod.InputMethodSubtype in project android_packages_inputmethods_LatinIME by CyanogenMod.
the class RichInputMethodSubtype method getNoLanguageSubtype.
@Nonnull
public static RichInputMethodSubtype getNoLanguageSubtype() {
RichInputMethodSubtype noLanguageSubtype = sNoLanguageSubtype;
if (noLanguageSubtype == null) {
final InputMethodSubtype rawNoLanguageSubtype = RichInputMethodManager.getInstance().findSubtypeByLocaleAndKeyboardLayoutSet(SubtypeLocaleUtils.NO_LANGUAGE, SubtypeLocaleUtils.QWERTY);
if (rawNoLanguageSubtype != null) {
noLanguageSubtype = new RichInputMethodSubtype(rawNoLanguageSubtype);
}
}
if (noLanguageSubtype != null) {
sNoLanguageSubtype = noLanguageSubtype;
return noLanguageSubtype;
}
Log.w(TAG, "Can't find any language with QWERTY subtype");
Log.w(TAG, "No input method subtype found; returning dummy subtype: " + DUMMY_NO_LANGUAGE_SUBTYPE);
return DUMMY_NO_LANGUAGE_SUBTYPE;
}
use of android.view.inputmethod.InputMethodSubtype in project android_packages_inputmethods_LatinIME by CyanogenMod.
the class LatinIME method onStartInputInternal.
void onStartInputInternal(final EditorInfo editorInfo, final boolean restarting) {
super.onStartInput(editorInfo, restarting);
// If the primary hint language does not match the current subtype language, then try
// to switch to the primary hint language.
// TODO: Support all the locales in EditorInfo#hintLocales.
final Locale primaryHintLocale = EditorInfoCompatUtils.getPrimaryHintLocale(editorInfo);
if (primaryHintLocale == null) {
return;
}
final InputMethodSubtype newSubtype = mRichImm.findSubtypeByLocale(primaryHintLocale);
if (newSubtype == null || newSubtype.equals(mRichImm.getCurrentSubtype().getRawSubtype())) {
return;
}
mHandler.postSwitchLanguage(newSubtype);
}
use of android.view.inputmethod.InputMethodSubtype in project android_packages_inputmethods_LatinIME by CyanogenMod.
the class InputTestsBase method changeLanguageWithoutWait.
protected void changeLanguageWithoutWait(final String locale, final String combiningSpec) {
mEditText.mCurrentLocale = LocaleUtils.constructLocaleFromString(locale);
// TODO: this is forcing a QWERTY keyboard for all locales, which is wrong.
// It's still better than using whatever keyboard is the current one, but we
// should actually use the default keyboard for this locale.
// TODO: Use {@link InputMethodSubtype.InputMethodSubtypeBuilder} directly or indirectly so
// that {@link InputMethodSubtype#isAsciiCapable} can return the correct value.
final String EXTRA_VALUE_FOR_TEST = "KeyboardLayoutSet=" + SubtypeLocaleUtils.QWERTY + "," + Constants.Subtype.ExtraValue.ASCII_CAPABLE + "," + Constants.Subtype.ExtraValue.ENABLED_WHEN_DEFAULT_IS_NOT_ASCII_CAPABLE + "," + Constants.Subtype.ExtraValue.EMOJI_CAPABLE + null == combiningSpec ? "" : ("," + combiningSpec);
final InputMethodSubtype subtype = InputMethodSubtypeCompatUtils.newInputMethodSubtype(R.string.subtype_no_language_qwerty, R.drawable.ic_ime_switcher_dark, locale, Constants.Subtype.KEYBOARD_MODE, EXTRA_VALUE_FOR_TEST, false, /* isAuxiliary */
false, /* overridesImplicitlyEnabledSubtype */
0);
RichInputMethodManager.forceSubtype(subtype);
mLatinIME.onCurrentInputMethodSubtypeChanged(subtype);
runMessages();
mKeyboard = mLatinIME.mKeyboardSwitcher.getKeyboard();
mLatinIME.clearPersonalizedDictionariesForTest();
}
use of android.view.inputmethod.InputMethodSubtype in project android_packages_inputmethods_LatinIME by CyanogenMod.
the class RichInputMethodSubtypeTests method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
final Context context = getContext();
mRes = context.getResources();
RichInputMethodManager.init(context);
mRichImm = RichInputMethodManager.getInstance();
// Save and reset additional subtypes
mSavedAddtionalSubtypes = mRichImm.getAdditionalSubtypes();
final InputMethodSubtype[] predefinedAddtionalSubtypes = AdditionalSubtypeUtils.createAdditionalSubtypesArray(AdditionalSubtypeUtils.createPrefSubtypes(mRes.getStringArray(R.array.predefined_subtypes)));
mRichImm.setAdditionalInputMethodSubtypes(predefinedAddtionalSubtypes);
final InputMethodInfo imi = mRichImm.getInputMethodInfoOfThisIme();
final int subtypeCount = imi.getSubtypeCount();
for (int index = 0; index < subtypeCount; index++) {
final InputMethodSubtype subtype = imi.getSubtypeAt(index);
mSubtypesList.add(new RichInputMethodSubtype(subtype));
}
EN_US = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(Locale.US.toString(), "qwerty"));
EN_GB = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(Locale.UK.toString(), "qwerty"));
ES_US = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet("es_US", "spanish"));
FR = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(Locale.FRENCH.toString(), "azerty"));
FR_CA = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(Locale.CANADA_FRENCH.toString(), "qwerty"));
FR_CH = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet("fr_CH", "swiss"));
DE = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(Locale.GERMAN.toString(), "qwertz"));
DE_CH = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet("de_CH", "swiss"));
HI = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet("hi", "hindi"));
SR = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet("sr", "south_slavic"));
ZZ = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(SubtypeLocaleUtils.NO_LANGUAGE, "qwerty"));
DE_QWERTY = new RichInputMethodSubtype(AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(Locale.GERMAN.toString(), "qwerty"));
FR_QWERTZ = new RichInputMethodSubtype(AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(Locale.FRENCH.toString(), "qwertz"));
EN_US_AZERTY = new RichInputMethodSubtype(AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(Locale.US.toString(), "azerty"));
EN_UK_DVORAK = new RichInputMethodSubtype(AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(Locale.UK.toString(), "dvorak"));
ES_US_COLEMAK = new RichInputMethodSubtype(AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype("es_US", "colemak"));
ZZ_AZERTY = new RichInputMethodSubtype(AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(SubtypeLocaleUtils.NO_LANGUAGE, "azerty"));
ZZ_PC = new RichInputMethodSubtype(AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(SubtypeLocaleUtils.NO_LANGUAGE, "pcqwerty"));
final InputMethodSubtype hiLatn = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet("hi_ZZ", "qwerty");
if (hiLatn != null) {
HI_LATN = new RichInputMethodSubtype(hiLatn);
HI_LATN_DVORAK = new RichInputMethodSubtype(AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype("hi_ZZ", "dvorak"));
}
final InputMethodSubtype srLatn = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet("sr_ZZ", "serbian_qwertz");
if (srLatn != null) {
SR_LATN = new RichInputMethodSubtype(srLatn);
SR_LATN_QWERTY = new RichInputMethodSubtype(AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype("sr_ZZ", "qwerty"));
}
}
Aggregations