Java Code Examples for android.view.inputmethod.InputMethodSubtype#getLanguageTag()
The following examples show how to use
android.view.inputmethod.InputMethodSubtype#getLanguageTag() .
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: InputMethodSubtypeCompatUtils.java From LokiBoard-Android-Keylogger with Apache License 2.0 | 5 votes |
public static Locale getLocaleObject(final InputMethodSubtype subtype) { // Locale.forLanguageTag() is available only in Android L and later. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { final String languageTag = subtype.getLanguageTag(); if (!TextUtils.isEmpty(languageTag)) { return Locale.forLanguageTag(languageTag); } } return LocaleUtils.constructLocaleFromString(subtype.getLocale()); }
Example 2
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 3
Source File: InputMethodSubtypeCompatUtils.java From simple-keyboard with Apache License 2.0 | 5 votes |
public static Locale getLocaleObject(final InputMethodSubtype subtype) { // Locale.forLanguageTag() is available only in Android L and later. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { final String languageTag = subtype.getLanguageTag(); if (!TextUtils.isEmpty(languageTag)) { return Locale.forLanguageTag(languageTag); } } return LocaleUtils.constructLocaleFromString(subtype.getLocale()); }
Example 4
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 5
Source File: AndroidUtilities.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
public static String[] getCurrentKeyboardLanguage() { try { InputMethodManager inputManager = (InputMethodManager) ApplicationLoader.applicationContext.getSystemService(Context.INPUT_METHOD_SERVICE); InputMethodSubtype inputMethodSubtype = inputManager.getCurrentInputMethodSubtype(); String locale = null; if (inputMethodSubtype != null) { if (Build.VERSION.SDK_INT >= 24) { locale = inputMethodSubtype.getLanguageTag(); } if (TextUtils.isEmpty(locale)) { locale = inputMethodSubtype.getLocale(); } } else { inputMethodSubtype = inputManager.getLastInputMethodSubtype(); if (inputMethodSubtype != null) { if (Build.VERSION.SDK_INT >= 24) { locale = inputMethodSubtype.getLanguageTag(); } if (TextUtils.isEmpty(locale)) { locale = inputMethodSubtype.getLocale(); } } } if (TextUtils.isEmpty(locale)) { locale = LocaleController.getSystemLocaleStringIso639(); String locale2; LocaleController.LocaleInfo localeInfo = LocaleController.getInstance().getCurrentLocaleInfo(); locale2 = localeInfo.getBaseLangCode(); if (TextUtils.isEmpty(locale2)) { locale2 = localeInfo.getLangCode(); } if (locale.contains(locale2) || locale2.contains(locale)) { if (!locale.contains("en")) { locale2 = "en"; } else { locale2 = null; } } if (!TextUtils.isEmpty(locale2)) { return new String[]{locale.replace('_', '-'), locale2}; } else { return new String[]{locale.replace('_', '-')}; } } else { return new String[]{locale.replace('_', '-')}; } } catch (Exception ignore) { } return new String[]{"en"}; }
Example 6
Source File: AndroidUtilities.java From Telegram with GNU General Public License v2.0 | 4 votes |
public static String[] getCurrentKeyboardLanguage() { try { InputMethodManager inputManager = (InputMethodManager) ApplicationLoader.applicationContext.getSystemService(Context.INPUT_METHOD_SERVICE); InputMethodSubtype inputMethodSubtype = inputManager.getCurrentInputMethodSubtype(); String locale = null; if (inputMethodSubtype != null) { if (Build.VERSION.SDK_INT >= 24) { locale = inputMethodSubtype.getLanguageTag(); } if (TextUtils.isEmpty(locale)) { locale = inputMethodSubtype.getLocale(); } } else { inputMethodSubtype = inputManager.getLastInputMethodSubtype(); if (inputMethodSubtype != null) { if (Build.VERSION.SDK_INT >= 24) { locale = inputMethodSubtype.getLanguageTag(); } if (TextUtils.isEmpty(locale)) { locale = inputMethodSubtype.getLocale(); } } } if (TextUtils.isEmpty(locale)) { locale = LocaleController.getSystemLocaleStringIso639(); String locale2; LocaleController.LocaleInfo localeInfo = LocaleController.getInstance().getCurrentLocaleInfo(); locale2 = localeInfo.getBaseLangCode(); if (TextUtils.isEmpty(locale2)) { locale2 = localeInfo.getLangCode(); } if (locale.contains(locale2) || locale2.contains(locale)) { if (!locale.contains("en")) { locale2 = "en"; } else { locale2 = null; } } if (!TextUtils.isEmpty(locale2)) { return new String[]{locale.replace('_', '-'), locale2}; } else { return new String[]{locale.replace('_', '-')}; } } else { return new String[]{locale.replace('_', '-')}; } } catch (Exception ignore) { } return new String[]{"en"}; }