下面列出了android.view.inputmethod.InputMethodSubtype#containsExtraValueKey ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private boolean checkForTransliteration() {
Locale locale = mRichImm.getCurrentSubtypeLocale();
if (!locale.getLanguage().equals("en")) {
mInputLogic.setIndic(true);
} else {
mInputLogic.setIndic(false);
}
InputMethodSubtype currentSubtype = mRichImm.getCurrentSubtype().getRawSubtype();
if(currentSubtype.containsExtraValueKey(TRANSLITERATION_METHOD)) {
try {
String transliterationName = currentSubtype.getExtraValueOf(TRANSLITERATION_METHOD);
mInputLogic.enableTransliteration(transliterationName, getApplicationContext());
Log.d("IndicKeyboard", "-------------transliteration enabled-----------");
return true;
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
mInputLogic.disableTransliteration();
Log.d("IndicKeyboard", "-------------transliteration disabled----------------");
return false;
}
@Nonnull
private static String getReplacementString(@Nonnull final InputMethodSubtype subtype,
@Nonnull final Locale displayLocale) {
if (subtype.containsExtraValueKey(UNTRANSLATABLE_STRING_IN_SUBTYPE_NAME)) {
return subtype.getExtraValueOf(UNTRANSLATABLE_STRING_IN_SUBTYPE_NAME);
}
return getSubtypeLocaleDisplayNameInternal(subtype.getLocale(), displayLocale);
}
private static String getReplacementString(final InputMethodSubtype subtype,
final Locale displayLocale) {
if (subtype.containsExtraValueKey(UNTRANSLATABLE_STRING_IN_SUBTYPE_NAME)) {
return subtype.getExtraValueOf(UNTRANSLATABLE_STRING_IN_SUBTYPE_NAME);
}
return getSubtypeLocaleDisplayNameInternal(subtype.getLocale(), displayLocale);
}
private static String getReplacementString(final InputMethodSubtype subtype,
final Locale displayLocale) {
if (subtype.containsExtraValueKey(UNTRANSLATABLE_STRING_IN_SUBTYPE_NAME)) {
return subtype.getExtraValueOf(UNTRANSLATABLE_STRING_IN_SUBTYPE_NAME);
}
return getSubtypeLocaleDisplayNameInternal(subtype.getLocale(), displayLocale);
}
@Nonnull
private static String getReplacementString(@Nonnull final InputMethodSubtype subtype,
@Nonnull final Locale displayLocale) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN
&& subtype.containsExtraValueKey(UNTRANSLATABLE_STRING_IN_SUBTYPE_NAME)) {
return subtype.getExtraValueOf(UNTRANSLATABLE_STRING_IN_SUBTYPE_NAME);
}
return getSubtypeLocaleDisplayNameInternal(subtype.getLocale(), displayLocale);
}
@Nonnull
private static String getReplacementString(@Nonnull final InputMethodSubtype subtype,
@Nonnull final Locale displayLocale) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN
&& subtype.containsExtraValueKey(UNTRANSLATABLE_STRING_IN_SUBTYPE_NAME)) {
return subtype.getExtraValueOf(UNTRANSLATABLE_STRING_IN_SUBTYPE_NAME);
}
return getSubtypeLocaleDisplayNameInternal(subtype.getLocale(), displayLocale);
}
@UsedForTesting
public static boolean isAdditionalSubtype(final InputMethodSubtype subtype) {
return subtype.containsExtraValueKey(IS_ADDITIONAL_SUBTYPE);
}
@UsedForTesting
public static boolean isAdditionalSubtype(final InputMethodSubtype subtype) {
return subtype.containsExtraValueKey(IS_ADDITIONAL_SUBTYPE);
}
public static boolean isAsciiCapable(final InputMethodSubtype subtype) {
return isAsciiCapableWithAPI(subtype)
|| subtype.containsExtraValueKey(Constants.Subtype.ExtraValue.ASCII_CAPABLE);
}
private boolean needsToShowImeSwitchOngoingNotification() {
if (!mShowOngoingImeSwitcherForPhones) return false;
if (isScreenLocked()) return false;
synchronized (mMethodMap) {
List<InputMethodInfo> imis = mSettings.getEnabledInputMethodListLocked();
final int N = imis.size();
if (N > 2) return true;
if (N < 1) return false;
int nonAuxCount = 0;
int auxCount = 0;
InputMethodSubtype nonAuxSubtype = null;
InputMethodSubtype auxSubtype = null;
for(int i = 0; i < N; ++i) {
final InputMethodInfo imi = imis.get(i);
final List<InputMethodSubtype> subtypes =
mSettings.getEnabledInputMethodSubtypeListLocked(mContext, imi, true);
final int subtypeCount = subtypes.size();
if (subtypeCount == 0) {
++nonAuxCount;
} else {
for (int j = 0; j < subtypeCount; ++j) {
final InputMethodSubtype subtype = subtypes.get(j);
if (!subtype.isAuxiliary()) {
++nonAuxCount;
nonAuxSubtype = subtype;
} else {
++auxCount;
auxSubtype = subtype;
}
}
}
}
if (nonAuxCount > 1 || auxCount > 1) {
return true;
} else if (nonAuxCount == 1 && auxCount == 1) {
if (nonAuxSubtype != null && auxSubtype != null
&& (nonAuxSubtype.getLocale().equals(auxSubtype.getLocale())
|| auxSubtype.overridesImplicitlyEnabledSubtype()
|| nonAuxSubtype.overridesImplicitlyEnabledSubtype())
&& nonAuxSubtype.containsExtraValueKey(TAG_TRY_SUPPRESSING_IME_SWITCHER)) {
return false;
}
return true;
}
return false;
}
}
@UsedForTesting
public static boolean isAdditionalSubtype(final InputMethodSubtype subtype) {
return subtype.containsExtraValueKey(IS_ADDITIONAL_SUBTYPE);
}
public static boolean isAsciiCapable(final InputMethodSubtype subtype) {
return isAsciiCapableWithAPI(subtype)
|| subtype.containsExtraValueKey(Constants.Subtype.ExtraValue.ASCII_CAPABLE);
}