Java Code Examples for android.view.inputmethod.InputMethodSubtype#getLocale()
The following examples show how to use
android.view.inputmethod.InputMethodSubtype#getLocale() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SubtypeLocaleUtils.java From AOSP-Kayboard-7.1.2 with Apache License 2.0 | 6 votes |
@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; }
Example 2
Source File: SubtypeLocaleUtils.java From Indic-Keyboard with Apache License 2.0 | 6 votes |
@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; }
Example 3
Source File: SoftKeyboard.java From AndroidKeyboard with GNU General Public License v3.0 | 6 votes |
/** * 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; }
Example 4
Source File: SubtypeLocaleUtils.java From openboard with GNU General Public License v3.0 | 6 votes |
@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; }
Example 5
Source File: InputMethodService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * 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); } }
Example 6
Source File: ApiCompatibilityUtils.java From cronet with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * @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(); } }
Example 7
Source File: ActionTestsBase.java From Indic-Keyboard with Apache License 2.0 | 5 votes |
protected static Locale getLabelLocale(final InputMethodSubtype subtype) { final String localeString = subtype.getLocale(); if (localeString.equals(SubtypeLocaleUtils.NO_LANGUAGE)) { return null; } return LocaleUtils.constructLocaleFromString(localeString); }
Example 8
Source File: DeferredStartupHandler.java From AndroidChromium with Apache License 2.0 | 5 votes |
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); } }
Example 9
Source File: AdditionalSubtypeUtils.java From LokiBoard-Android-Keylogger with Apache License 2.0 | 5 votes |
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; }
Example 10
Source File: DeferredStartupHandler.java From delion with Apache License 2.0 | 5 votes |
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); } }
Example 11
Source File: AdditionalSubtypeUtils.java From Indic-Keyboard with Apache License 2.0 | 5 votes |
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; }
Example 12
Source File: ApiCompatibilityUtils.java From 365browser with Apache License 2.0 | 5 votes |
/** * @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(); } }
Example 13
Source File: CustomInputStyleSettingsFragment.java From AOSP-Kayboard-7.1.2 with Apache License 2.0 | 4 votes |
private InputMethodSubtype findDuplicatedSubtype(final InputMethodSubtype subtype) { final String localeString = subtype.getLocale(); final String keyboardLayoutSetName = SubtypeLocaleUtils.getKeyboardLayoutSetName(subtype); return mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( localeString, keyboardLayoutSetName); }
Example 14
Source File: CustomInputStylePreference.java From openboard with GNU General Public License v3.0 | 4 votes |
public SubtypeLocaleItem(final InputMethodSubtype subtype) { mLocaleString = subtype.getLocale(); mDisplayName = SubtypeLocaleUtils.getSubtypeLocaleDisplayNameInSystemLocale( mLocaleString); }
Example 15
Source File: SubtypeLocaleUtils.java From Indic-Keyboard with Apache License 2.0 | 4 votes |
@Nonnull public static Locale getSubtypeLocale(@Nonnull final InputMethodSubtype subtype) { final String localeString = subtype.getLocale(); return LocaleUtils.constructLocaleFromString(localeString); }
Example 16
Source File: CustomInputStylePreference.java From LokiBoard-Android-Keylogger with Apache License 2.0 | 4 votes |
public SubtypeLocaleItem(final InputMethodSubtype subtype) { mLocaleString = subtype.getLocale(); mDisplayName = SubtypeLocaleUtils.getSubtypeLocaleDisplayNameInSystemLocale( mLocaleString); }
Example 17
Source File: CustomInputStyleSettingsFragment.java From openboard with GNU General Public License v3.0 | 4 votes |
private InputMethodSubtype findDuplicatedSubtype(final InputMethodSubtype subtype) { final String localeString = subtype.getLocale(); final String keyboardLayoutSetName = SubtypeLocaleUtils.getKeyboardLayoutSetName(subtype); return mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( localeString, keyboardLayoutSetName); }
Example 18
Source File: CustomInputStylePreference.java From AOSP-Kayboard-7.1.2 with Apache License 2.0 | 4 votes |
public SubtypeLocaleItem(final InputMethodSubtype subtype) { mLocaleString = subtype.getLocale(); mDisplayName = SubtypeLocaleUtils.getSubtypeLocaleDisplayNameInSystemLocale( mLocaleString); }
Example 19
Source File: SubtypeLocaleUtils.java From simple-keyboard with Apache License 2.0 | 4 votes |
public static Locale getSubtypeLocale(final InputMethodSubtype subtype) { final String localeString = subtype.getLocale(); return LocaleUtils.constructLocaleFromString(localeString); }
Example 20
Source File: CustomInputStylePreference.java From Indic-Keyboard with Apache License 2.0 | 4 votes |
public SubtypeLocaleItem(final InputMethodSubtype subtype) { mLocaleString = subtype.getLocale(); mDisplayName = SubtypeLocaleUtils.getSubtypeLocaleDisplayNameInSystemLocale( mLocaleString); }