Java Code Examples for android.view.inputmethod.InputMethodManager#getEnabledInputMethodSubtypeList()
The following examples show how to use
android.view.inputmethod.InputMethodManager#getEnabledInputMethodSubtypeList() .
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: RichInputMethodManager.java From openboard with GNU General Public License v3.0 | 6 votes |
public boolean isSystemLocaleSameAsLocaleOfAllEnabledSubtypesOfEnabledImes() { final Locale systemLocale = mContext.getResources().getConfiguration().locale; final Set<InputMethodSubtype> enabledSubtypesOfEnabledImes = new HashSet<>(); final InputMethodManager inputMethodManager = getInputMethodManager(); final List<InputMethodInfo> enabledInputMethodInfoList = inputMethodManager.getEnabledInputMethodList(); for (final InputMethodInfo info : enabledInputMethodInfoList) { final List<InputMethodSubtype> enabledSubtypes = inputMethodManager.getEnabledInputMethodSubtypeList( info, true /* allowsImplicitlySelectedSubtypes */); if (enabledSubtypes.isEmpty()) { // An IME with no subtypes is found. return false; } enabledSubtypesOfEnabledImes.addAll(enabledSubtypes); } for (final InputMethodSubtype subtype : enabledSubtypesOfEnabledImes) { if (!subtype.isAuxiliary() && !subtype.getLocale().isEmpty() && !systemLocale.equals(SubtypeLocaleUtils.getSubtypeLocale(subtype))) { return false; } } return true; }
Example 2
Source File: InputMethodSettingsImpl.java From Android-Keyboard with Apache License 2.0 | 6 votes |
private static String getEnabledSubtypesLabel( Context context, InputMethodManager imm, InputMethodInfo imi) { if (context == null || imm == null || imi == null) return null; final List<InputMethodSubtype> subtypes = imm.getEnabledInputMethodSubtypeList(imi, true); final StringBuilder sb = new StringBuilder(); final int N = subtypes.size(); for (int i = 0; i < N; ++i) { final InputMethodSubtype subtype = subtypes.get(i); if (sb.length() > 0) { sb.append(", "); } sb.append(subtype.getDisplayName(context, imi.getPackageName(), imi.getServiceInfo().applicationInfo)); } return sb.toString(); }
Example 3
Source File: InputMethodSettingsImpl.java From LokiBoard-Android-Keylogger with Apache License 2.0 | 6 votes |
private static String getEnabledSubtypesLabel( Context context, InputMethodManager imm, InputMethodInfo imi) { if (context == null || imm == null || imi == null) return null; final List<InputMethodSubtype> subtypes = imm.getEnabledInputMethodSubtypeList(imi, true); final StringBuilder sb = new StringBuilder(); final int N = subtypes.size(); for (int i = 0; i < N; ++i) { final InputMethodSubtype subtype = subtypes.get(i); if (sb.length() > 0) { sb.append(", "); } sb.append(subtype.getDisplayName(context, imi.getPackageName(), imi.getServiceInfo().applicationInfo)); } return sb.toString(); }
Example 4
Source File: InputMethodSettingsImpl.java From simple-keyboard with Apache License 2.0 | 6 votes |
private static String getEnabledSubtypesLabel( Context context, InputMethodManager imm, InputMethodInfo imi) { if (context == null || imm == null || imi == null) return null; final List<InputMethodSubtype> subtypes = imm.getEnabledInputMethodSubtypeList(imi, true); final StringBuilder sb = new StringBuilder(); final int N = subtypes.size(); for (int i = 0; i < N; ++i) { final InputMethodSubtype subtype = subtypes.get(i); if (sb.length() > 0) { sb.append(", "); } sb.append(subtype.getDisplayName(context, imi.getPackageName(), imi.getServiceInfo().applicationInfo)); } return sb.toString(); }
Example 5
Source File: RichInputMethodManager.java From AOSP-Kayboard-7.1.2 with Apache License 2.0 | 6 votes |
public boolean isSystemLocaleSameAsLocaleOfAllEnabledSubtypesOfEnabledImes() { final Locale systemLocale = mContext.getResources().getConfiguration().locale; final Set<InputMethodSubtype> enabledSubtypesOfEnabledImes = new HashSet<>(); final InputMethodManager inputMethodManager = getInputMethodManager(); final List<InputMethodInfo> enabledInputMethodInfoList = inputMethodManager.getEnabledInputMethodList(); for (final InputMethodInfo info : enabledInputMethodInfoList) { final List<InputMethodSubtype> enabledSubtypes = inputMethodManager.getEnabledInputMethodSubtypeList( info, true /* allowsImplicitlySelectedSubtypes */); if (enabledSubtypes.isEmpty()) { // An IME with no subtypes is found. return false; } enabledSubtypesOfEnabledImes.addAll(enabledSubtypes); } for (final InputMethodSubtype subtype : enabledSubtypesOfEnabledImes) { if (!subtype.isAuxiliary() && !subtype.getLocale().isEmpty() && !systemLocale.equals(SubtypeLocaleUtils.getSubtypeLocale(subtype))) { return false; } } return true; }
Example 6
Source File: InputMethodSettingsImpl.java From AOSP-Kayboard-7.1.2 with Apache License 2.0 | 6 votes |
private static String getEnabledSubtypesLabel( Context context, InputMethodManager imm, InputMethodInfo imi) { if (context == null || imm == null || imi == null) return null; final List<InputMethodSubtype> subtypes = imm.getEnabledInputMethodSubtypeList(imi, true); final StringBuilder sb = new StringBuilder(); final int N = subtypes.size(); for (int i = 0; i < N; ++i) { final InputMethodSubtype subtype = subtypes.get(i); if (sb.length() > 0) { sb.append(", "); } sb.append(subtype.getDisplayName(context, imi.getPackageName(), imi.getServiceInfo().applicationInfo)); } return sb.toString(); }
Example 7
Source File: InputMethodSettingsImpl.java From AndroidKeyboard with GNU General Public License v3.0 | 6 votes |
private static String getEnabledSubtypesLabel( Context context, InputMethodManager imm, InputMethodInfo imi) { if (context == null || imm == null || imi == null) return null; final List<InputMethodSubtype> subtypes = imm.getEnabledInputMethodSubtypeList(imi, true); final StringBuilder sb = new StringBuilder(); final int N = subtypes.size(); for (int i = 0; i < N; ++i) { final InputMethodSubtype subtype = subtypes.get(i); if (sb.length() > 0) { sb.append(", "); } sb.append(subtype.getDisplayName(context, imi.getPackageName(), imi.getServiceInfo().applicationInfo)); } return sb.toString(); }
Example 8
Source File: UiUtils.java From 365browser with Apache License 2.0 | 6 votes |
/** * Gets the set of locales supported by the current enabled Input Methods. * @param context A {@link Context} instance. * @return A possibly-empty {@link Set} of locale strings. */ public static Set<String> getIMELocales(Context context) { LinkedHashSet<String> locales = new LinkedHashSet<String>(); InputMethodManager imManager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); List<InputMethodInfo> enabledMethods = imManager.getEnabledInputMethodList(); for (int i = 0; i < enabledMethods.size(); i++) { List<InputMethodSubtype> subtypes = imManager.getEnabledInputMethodSubtypeList(enabledMethods.get(i), true); if (subtypes == null) continue; for (int j = 0; j < subtypes.size(); j++) { String locale = ApiCompatibilityUtils.getLocale(subtypes.get(j)); if (!TextUtils.isEmpty(locale)) locales.add(locale); } } return locales; }
Example 9
Source File: RichInputMethodManager.java From Indic-Keyboard with Apache License 2.0 | 6 votes |
public boolean isSystemLocaleSameAsLocaleOfAllEnabledSubtypesOfEnabledImes() { final Locale systemLocale = mContext.getResources().getConfiguration().locale; final Set<InputMethodSubtype> enabledSubtypesOfEnabledImes = new HashSet<>(); final InputMethodManager inputMethodManager = getInputMethodManager(); final List<InputMethodInfo> enabledInputMethodInfoList = inputMethodManager.getEnabledInputMethodList(); for (final InputMethodInfo info : enabledInputMethodInfoList) { final List<InputMethodSubtype> enabledSubtypes = inputMethodManager.getEnabledInputMethodSubtypeList( info, true /* allowsImplicitlySelectedSubtypes */); if (enabledSubtypes.isEmpty()) { // An IME with no subtypes is found. return false; } enabledSubtypesOfEnabledImes.addAll(enabledSubtypes); } for (final InputMethodSubtype subtype : enabledSubtypesOfEnabledImes) { if (!subtype.isAuxiliary() && !subtype.getLocale().isEmpty() && !systemLocale.equals(SubtypeLocaleUtils.getSubtypeLocale(subtype))) { return false; } } return true; }
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: 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 12
Source File: ProcessInitializationHandler.java From 365browser with Apache License 2.0 | 5 votes |
@SuppressWarnings("deprecation") // InputMethodSubtype.getLocale() deprecated in API 24 private void recordKeyboardLocaleUma(Context context) { InputMethodManager imm = (InputMethodManager) context.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); } }