android.view.inputmethod.InputMethodSubtype#getLocale ( )源码实例Demo

下面列出了android.view.inputmethod.InputMethodSubtype#getLocale ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: openboard   文件: SubtypeLocaleUtils.java
@Nonnull
public static String getKeyboardLayoutSetName(final InputMethodSubtype subtype) {
    String keyboardLayoutSet = subtype.getExtraValueOf(KEYBOARD_LAYOUT_SET);
    if (keyboardLayoutSet == null) {
        // This subtype doesn't have a keyboardLayoutSet extra value, so lookup its keyboard
        // layout set in sLocaleAndExtraValueToKeyboardLayoutSetMap to keep it compatible with
        // pre-JellyBean.
        final String key = subtype.getLocale() + ":" + subtype.getExtraValue();
        keyboardLayoutSet = sLocaleAndExtraValueToKeyboardLayoutSetMap.get(key);
    }
    // TODO: Remove this null check when InputMethodManager.getCurrentInputMethodSubtype is
    // fixed.
    if (keyboardLayoutSet == null) {
        android.util.Log.w(TAG, "KeyboardLayoutSet not found, use QWERTY: " +
                "locale=" + subtype.getLocale() + " extraValue=" + subtype.getExtraValue());
        return QWERTY;
    }
    return keyboardLayoutSet;
}
 
源代码2 项目: AndroidKeyboard   文件: SoftKeyboard.java
/**
 * Use the right subtype based on language selected.
 *
 * @return mCurKeyboard
 */
private LatinKeyboard getSelectedSubtype() {
    final InputMethodSubtype subtype = mInputMethodManager.getCurrentInputMethodSubtype();
    String s = subtype.getLocale();
    switch (s) {
        case "ps_AF":
            mActiveKeyboard = "ps_AF";
            mCurKeyboard = mPashtoKeyboard;
            break;
        case "ps_latin_AF":
            mActiveKeyboard = "ps_latin_AF";
            mCurKeyboard = mPashtoLatinKeyboard;
            break;
        case "fa_AF":
            mActiveKeyboard = "fa_AF";
            mCurKeyboard = mFarsiKeyboard;
            break;
        default:
            mActiveKeyboard = "en_US";
            mCurKeyboard = mQwertyKeyboard;
    }

    return mCurKeyboard;
}
 
源代码3 项目: Indic-Keyboard   文件: SubtypeLocaleUtils.java
@Nonnull
public static String getKeyboardLayoutSetName(final InputMethodSubtype subtype) {
    String keyboardLayoutSet = subtype.getExtraValueOf(KEYBOARD_LAYOUT_SET);
    if (keyboardLayoutSet == null) {
        // This subtype doesn't have a keyboardLayoutSet extra value, so lookup its keyboard
        // layout set in sLocaleAndExtraValueToKeyboardLayoutSetMap to keep it compatible with
        // pre-JellyBean.
        final String key = subtype.getLocale() + ":" + subtype.getExtraValue();
        keyboardLayoutSet = sLocaleAndExtraValueToKeyboardLayoutSetMap.get(key);
    }
    // TODO: Remove this null check when InputMethodManager.getCurrentInputMethodSubtype is
    // fixed.
    if (keyboardLayoutSet == null) {
        android.util.Log.w(TAG, "KeyboardLayoutSet not found, use QWERTY: " +
                "locale=" + subtype.getLocale() + " extraValue=" + subtype.getExtraValue());
        return QWERTY;
    }
    return keyboardLayoutSet;
}
 
源代码4 项目: AOSP-Kayboard-7.1.2   文件: SubtypeLocaleUtils.java
@Nonnull
public static String getKeyboardLayoutSetName(final InputMethodSubtype subtype) {
    String keyboardLayoutSet = subtype.getExtraValueOf(KEYBOARD_LAYOUT_SET);
    if (keyboardLayoutSet == null) {
        // This subtype doesn't have a keyboardLayoutSet extra value, so lookup its keyboard
        // layout set in sLocaleAndExtraValueToKeyboardLayoutSetMap to keep it compatible with
        // pre-JellyBean.
        final String key = subtype.getLocale() + ":" + subtype.getExtraValue();
        keyboardLayoutSet = sLocaleAndExtraValueToKeyboardLayoutSetMap.get(key);
    }
    // TODO: Remove this null check when InputMethodManager.getCurrentInputMethodSubtype is
    // fixed.
    if (keyboardLayoutSet == null) {
        Log.w(TAG, "KeyboardLayoutSet not found, use QWERTY: " +
                "locale=" + subtype.getLocale() + " extraValue=" + subtype.getExtraValue());
        return QWERTY;
    }
    return keyboardLayoutSet;
}
 
源代码5 项目: 365browser   文件: ApiCompatibilityUtils.java
/**
 * @see android.view.inputmethod.InputMethodSubType#getLocate()
 */
@SuppressWarnings("deprecation")
public static String getLocale(InputMethodSubtype inputMethodSubType) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        return inputMethodSubType.getLanguageTag();
    } else {
        return inputMethodSubType.getLocale();
    }
}
 
源代码6 项目: android_9.0.0_r45   文件: InputMethodService.java
/**
 * Called when the subtype was changed.
 * @param newSubtype the subtype which is being changed to.
 */
protected void onCurrentInputMethodSubtypeChanged(InputMethodSubtype newSubtype) {
    if (DEBUG) {
        int nameResId = newSubtype.getNameResId();
        String mode = newSubtype.getMode();
        String output = "changeInputMethodSubtype:"
            + (nameResId == 0 ? "<none>" : getString(nameResId)) + ","
            + mode + ","
            + newSubtype.getLocale() + "," + newSubtype.getExtraValue();
        Log.v(TAG, "--- " + output);
    }
}
 
源代码7 项目: Indic-Keyboard   文件: AdditionalSubtypeUtils.java
public static String getPrefSubtype(final InputMethodSubtype subtype) {
    final String localeString = subtype.getLocale();
    final String keyboardLayoutSetName = SubtypeLocaleUtils.getKeyboardLayoutSetName(subtype);
    final String layoutExtraValue = KEYBOARD_LAYOUT_SET + "=" + keyboardLayoutSetName;
    final String extraValue = StringUtils.removeFromCommaSplittableTextIfExists(
            layoutExtraValue, StringUtils.removeFromCommaSplittableTextIfExists(
                    IS_ADDITIONAL_SUBTYPE, subtype.getExtraValue()));
    final String basePrefSubtype = localeString + LOCALE_AND_LAYOUT_SEPARATOR
            + keyboardLayoutSetName;
    return extraValue.isEmpty() ? basePrefSubtype
            : basePrefSubtype + LOCALE_AND_LAYOUT_SEPARATOR + extraValue;
}
 
源代码8 项目: delion   文件: DeferredStartupHandler.java
private void recordKeyboardLocaleUma() {
    InputMethodManager imm =
            (InputMethodManager) mAppContext.getSystemService(Context.INPUT_METHOD_SERVICE);
    List<InputMethodInfo> ims = imm.getEnabledInputMethodList();
    ArrayList<String> uniqueLanguages = new ArrayList<String>();
    for (InputMethodInfo method : ims) {
        List<InputMethodSubtype> submethods =
                imm.getEnabledInputMethodSubtypeList(method, true);
        for (InputMethodSubtype submethod : submethods) {
            if (submethod.getMode().equals("keyboard")) {
                String language = submethod.getLocale().split("_")[0];
                if (!uniqueLanguages.contains(language)) {
                    uniqueLanguages.add(language);
                }
            }
        }
    }
    RecordHistogram.recordCountHistogram("InputMethod.ActiveCount", uniqueLanguages.size());

    InputMethodSubtype currentSubtype = imm.getCurrentInputMethodSubtype();
    Locale systemLocale = Locale.getDefault();
    if (currentSubtype != null && currentSubtype.getLocale() != null && systemLocale != null) {
        String keyboardLanguage = currentSubtype.getLocale().split("_")[0];
        boolean match = systemLocale.getLanguage().equalsIgnoreCase(keyboardLanguage);
        RecordHistogram.recordBooleanHistogram("InputMethod.MatchesSystemLanguage", match);
    }
}
 
public static String getPrefSubtype(final InputMethodSubtype subtype) {
    final String localeString = subtype.getLocale();
    final String keyboardLayoutSetName = SubtypeLocaleUtils.getKeyboardLayoutSetName(subtype);
    final String layoutExtraValue = KEYBOARD_LAYOUT_SET + "=" + keyboardLayoutSetName;
    final String extraValue = StringUtils.removeFromCommaSplittableTextIfExists(
            layoutExtraValue, StringUtils.removeFromCommaSplittableTextIfExists(
                    IS_ADDITIONAL_SUBTYPE, subtype.getExtraValue()));
    final String basePrefSubtype = localeString + LOCALE_AND_LAYOUT_SEPARATOR
            + keyboardLayoutSetName;
    return extraValue.isEmpty() ? basePrefSubtype
            : basePrefSubtype + LOCALE_AND_LAYOUT_SEPARATOR + extraValue;
}
 
源代码10 项目: AndroidChromium   文件: DeferredStartupHandler.java
private void recordKeyboardLocaleUma() {
    InputMethodManager imm =
            (InputMethodManager) mAppContext.getSystemService(Context.INPUT_METHOD_SERVICE);
    List<InputMethodInfo> ims = imm.getEnabledInputMethodList();
    ArrayList<String> uniqueLanguages = new ArrayList<>();
    for (InputMethodInfo method : ims) {
        List<InputMethodSubtype> submethods =
                imm.getEnabledInputMethodSubtypeList(method, true);
        for (InputMethodSubtype submethod : submethods) {
            if (submethod.getMode().equals("keyboard")) {
                String language = submethod.getLocale().split("_")[0];
                if (!uniqueLanguages.contains(language)) {
                    uniqueLanguages.add(language);
                }
            }
        }
    }
    RecordHistogram.recordCountHistogram("InputMethod.ActiveCount", uniqueLanguages.size());

    InputMethodSubtype currentSubtype = imm.getCurrentInputMethodSubtype();
    Locale systemLocale = Locale.getDefault();
    if (currentSubtype != null && currentSubtype.getLocale() != null && systemLocale != null) {
        String keyboardLanguage = currentSubtype.getLocale().split("_")[0];
        boolean match = systemLocale.getLanguage().equalsIgnoreCase(keyboardLanguage);
        RecordHistogram.recordBooleanHistogram("InputMethod.MatchesSystemLanguage", match);
    }
}
 
源代码11 项目: Indic-Keyboard   文件: ActionTestsBase.java
protected static Locale getLabelLocale(final InputMethodSubtype subtype) {
    final String localeString = subtype.getLocale();
    if (localeString.equals(SubtypeLocaleUtils.NO_LANGUAGE)) {
        return null;
    }
    return LocaleUtils.constructLocaleFromString(localeString);
}
 
源代码12 项目: cronet   文件: ApiCompatibilityUtils.java
/**
 * @see android.view.inputmethod.InputMethodSubType#getLocate()
 */
@SuppressWarnings("deprecation")
public static String getLocale(InputMethodSubtype inputMethodSubType) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        return inputMethodSubType.getLanguageTag();
    } else {
        return inputMethodSubType.getLocale();
    }
}
 
public SubtypeLocaleItem(final InputMethodSubtype subtype) {
    mLocaleString = subtype.getLocale();
    mDisplayName = SubtypeLocaleUtils.getSubtypeLocaleDisplayNameInSystemLocale(
            mLocaleString);
}
 
private InputMethodSubtype findDuplicatedSubtype(final InputMethodSubtype subtype) {
    final String localeString = subtype.getLocale();
    final String keyboardLayoutSetName = SubtypeLocaleUtils.getKeyboardLayoutSetName(subtype);
    return mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
            localeString, keyboardLayoutSetName);
}
 
源代码15 项目: openboard   文件: CustomInputStylePreference.java
public SubtypeLocaleItem(final InputMethodSubtype subtype) {
    mLocaleString = subtype.getLocale();
    mDisplayName = SubtypeLocaleUtils.getSubtypeLocaleDisplayNameInSystemLocale(
            mLocaleString);
}
 
private InputMethodSubtype findDuplicatedSubtype(final InputMethodSubtype subtype) {
    final String localeString = subtype.getLocale();
    final String keyboardLayoutSetName = SubtypeLocaleUtils.getKeyboardLayoutSetName(subtype);
    return mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
            localeString, keyboardLayoutSetName);
}
 
源代码17 项目: Indic-Keyboard   文件: SubtypeLocaleUtils.java
@Nonnull
public static Locale getSubtypeLocale(@Nonnull final InputMethodSubtype subtype) {
    final String localeString = subtype.getLocale();
    return LocaleUtils.constructLocaleFromString(localeString);
}
 
public SubtypeLocaleItem(final InputMethodSubtype subtype) {
    mLocaleString = subtype.getLocale();
    mDisplayName = SubtypeLocaleUtils.getSubtypeLocaleDisplayNameInSystemLocale(
            mLocaleString);
}
 
源代码19 项目: simple-keyboard   文件: SubtypeLocaleUtils.java
public static Locale getSubtypeLocale(final InputMethodSubtype subtype) {
    final String localeString = subtype.getLocale();
    return LocaleUtils.constructLocaleFromString(localeString);
}
 
public SubtypeLocaleItem(final InputMethodSubtype subtype) {
    mLocaleString = subtype.getLocale();
    mDisplayName = SubtypeLocaleUtils.getSubtypeLocaleDisplayNameInSystemLocale(
            mLocaleString);
}