Java Code Examples for android.view.inputmethod.InputMethodManager#getEnabledInputMethodList()
The following examples show how to use
android.view.inputmethod.InputMethodManager#getEnabledInputMethodList() .
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: RichInputMethodManager.java From openboard with GNU General Public License v3.0 | 6 votes |
private boolean switchToNextInputMethodAndSubtype(final IBinder token) { final InputMethodManager imm = mImmWrapper.mImm; final List<InputMethodInfo> enabledImis = imm.getEnabledInputMethodList(); final int currentIndex = getImiIndexInList(getInputMethodInfoOfThisIme(), enabledImis); if (currentIndex == INDEX_NOT_FOUND) { Log.w(TAG, "Can't find current IME in enabled IMEs: IME package=" + getInputMethodInfoOfThisIme().getPackageName()); return false; } final InputMethodInfo nextImi = getNextNonAuxiliaryIme(currentIndex, enabledImis); final List<InputMethodSubtype> enabledSubtypes = getEnabledInputMethodSubtypeList(nextImi, true /* allowsImplicitlySelectedSubtypes */); if (enabledSubtypes.isEmpty()) { // The next IME has no subtype. imm.setInputMethod(token, nextImi.getId()); return true; } final InputMethodSubtype firstSubtype = enabledSubtypes.get(0); imm.setInputMethodAndSubtype(token, nextImi.getId(), firstSubtype); return true; }
Example 3
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 4
Source File: RichInputMethodManager.java From Indic-Keyboard with Apache License 2.0 | 6 votes |
private boolean switchToNextInputMethodAndSubtype(final IBinder token) { final InputMethodManager imm = mImmWrapper.mImm; final List<InputMethodInfo> enabledImis = imm.getEnabledInputMethodList(); final int currentIndex = getImiIndexInList(getInputMethodInfoOfThisIme(), enabledImis); if (currentIndex == INDEX_NOT_FOUND) { Log.w(TAG, "Can't find current IME in enabled IMEs: IME package=" + getInputMethodInfoOfThisIme().getPackageName()); return false; } final InputMethodInfo nextImi = getNextNonAuxiliaryIme(currentIndex, enabledImis); final List<InputMethodSubtype> enabledSubtypes = getEnabledInputMethodSubtypeList(nextImi, true /* allowsImplicitlySelectedSubtypes */); if (enabledSubtypes.isEmpty()) { // The next IME has no subtype. imm.setInputMethod(token, nextImi.getId()); return true; } final InputMethodSubtype firstSubtype = enabledSubtypes.get(0); imm.setInputMethodAndSubtype(token, nextImi.getId(), firstSubtype); return true; }
Example 5
Source File: RichInputMethodManager.java From AOSP-Kayboard-7.1.2 with Apache License 2.0 | 6 votes |
private boolean switchToNextInputMethodAndSubtype(final IBinder token) { final InputMethodManager imm = mImmWrapper.mImm; final List<InputMethodInfo> enabledImis = imm.getEnabledInputMethodList(); final int currentIndex = getImiIndexInList(getInputMethodInfoOfThisIme(), enabledImis); if (currentIndex == INDEX_NOT_FOUND) { Log.w(TAG, "Can't find current IME in enabled IMEs: IME package=" + getInputMethodInfoOfThisIme().getPackageName()); return false; } final InputMethodInfo nextImi = getNextNonAuxiliaryIme(currentIndex, enabledImis); final List<InputMethodSubtype> enabledSubtypes = getEnabledInputMethodSubtypeList(nextImi, true /* allowsImplicitlySelectedSubtypes */); if (enabledSubtypes.isEmpty()) { // The next IME has no subtype. imm.setInputMethod(token, nextImi.getId()); return true; } final InputMethodSubtype firstSubtype = enabledSubtypes.get(0); imm.setInputMethodAndSubtype(token, nextImi.getId(), firstSubtype); return true; }
Example 6
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 7
Source File: SettingsActivity.java From Chimee with MIT License | 6 votes |
private boolean isKeyboardActivated() { String packageLocal = getPackageName(); InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); if (inputMethodManager == null) return false; List<InputMethodInfo> list = inputMethodManager.getEnabledInputMethodList(); // check if our keyboard is enabled as input method for (InputMethodInfo inputMethod : list) { String packageName = inputMethod.getPackageName(); if (packageName.equals(packageLocal)) { return true; } } return false; }
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: UncachedInputMethodManagerUtils.java From Indic-Keyboard with Apache License 2.0 | 5 votes |
/** * Check if the IME specified by the context is enabled. * CAVEAT: This may cause a round trip IPC. * * @param context package context of the IME to be checked. * @param imm the {@link InputMethodManager}. * @return true if this IME is enabled. */ public static boolean isThisImeEnabled(final Context context, final InputMethodManager imm) { final String packageName = context.getPackageName(); for (final InputMethodInfo imi : imm.getEnabledInputMethodList()) { if (packageName.equals(imi.getPackageName())) { return true; } } return false; }
Example 10
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); } }
Example 11
Source File: LockScreenActivity.java From Zom-Android-XMPP with GNU General Public License v3.0 | 5 votes |
private void checkCustomFont () { if (Preferences.getLanguage() != null && Preferences.getLanguage().equalsIgnoreCase("bo")) { CustomTypefaceManager.loadFromAssets(this,true); } else { InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); List<InputMethodInfo> mInputMethodProperties = imm.getEnabledInputMethodList(); final int N = mInputMethodProperties.size(); boolean loadTibetan = false; for (int i = 0; i < N; i++) { InputMethodInfo imi = mInputMethodProperties.get(i); //imi contains the information about the keyboard you are using if (imi.getPackageName().equals("org.ironrabbit.bhoboard")) { // CustomTypefaceManager.loadFromKeyboard(this); loadTibetan = true; break; } } CustomTypefaceManager.loadFromAssets(this,loadTibetan); } }
Example 12
Source File: MainActivity.java From Zom-Android-XMPP with GNU General Public License v3.0 | 5 votes |
private void checkCustomFont () { if (Preferences.isLanguageTibetan()) { CustomTypefaceManager.loadFromAssets(this,true); } else { InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); List<InputMethodInfo> mInputMethodProperties = imm.getEnabledInputMethodList(); final int N = mInputMethodProperties.size(); boolean loadTibetan = false; for (int i = 0; i < N; i++) { InputMethodInfo imi = mInputMethodProperties.get(i); //imi contains the information about the keyboard you are using if (imi.getPackageName().equals("org.ironrabbit.bhoboard")) { // CustomTypefaceManager.loadFromKeyboard(this); loadTibetan = true; break; } } CustomTypefaceManager.loadFromAssets(this, loadTibetan); } }
Example 13
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 14
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 15
Source File: PackageUtils.java From prevent with Do What The F*ck You Want To Public License | 5 votes |
private static void initInputMethods(Context context) { InputMethodManager inputMethodManager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); List<InputMethodInfo> inputMethods = inputMethodManager.getEnabledInputMethodList(); final int count = inputMethods == null ? 0 : inputMethods.size(); for (int i = 0; i < count; ++i) { inputMethodPackages.add(inputMethods.get(i).getPackageName()); } }
Example 16
Source File: UncachedInputMethodManagerUtils.java From AOSP-Kayboard-7.1.2 with Apache License 2.0 | 5 votes |
/** * Check if the IME specified by the context is enabled. * CAVEAT: This may cause a round trip IPC. * * @param context package context of the IME to be checked. * @param imm the {@link InputMethodManager}. * @return true if this IME is enabled. */ public static boolean isThisImeEnabled(final Context context, final InputMethodManager imm) { final String packageName = context.getPackageName(); for (final InputMethodInfo imi : imm.getEnabledInputMethodList()) { if (packageName.equals(imi.getPackageName())) { return true; } } return false; }
Example 17
Source File: Environment.java From TVRemoteIME with GNU General Public License v2.0 | 5 votes |
public static boolean isEnableIME(Context context){ try { InputMethodManager imm = (InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE); List<InputMethodInfo> inputs = imm.getEnabledInputMethodList(); boolean flag = false; for(InputMethodInfo input : inputs){ if(input.getPackageName().equals(IMEService.class.getPackage().getName())){ return true; } } }catch (Exception ignored){ } return false; }
Example 18
Source File: TutorialFragment3.java From BaldPhone with Apache License 2.0 | 5 votes |
public void setupBtn() { final InputMethodManager im = (InputMethodManager) getContext().getSystemService(INPUT_METHOD_SERVICE); final List<InputMethodInfo> inputMethodInfoList = im.getEnabledInputMethodList(); boolean turnedOn = false; for (InputMethodInfo inputMethodInfo : inputMethodInfoList) { if (inputMethodInfo.getId().equals("com.bald.uriah.baldphone/.keyboard.BaldInputMethodService")) { turnedOn = true; break; } } if (!turnedOn) bt_set_keyboard.setOnClickListener((v) -> { v.getContext().startActivity(new Intent("android.settings.INPUT_METHOD_SETTINGS")); }); else { bt_set_keyboard.setText(R.string.already_setted); bt_set_keyboard.setOnClickListener(v -> { try { ((InputMethodManager) getContext().getApplicationContext().getSystemService(Context.INPUT_METHOD_SERVICE)).showInputMethodPicker(); } catch (Exception e) { Log.e(TAG, e.getMessage()); e.printStackTrace(); BaldToast.error(getContext()); } }); } }
Example 19
Source File: UncachedInputMethodManagerUtils.java From openboard with GNU General Public License v3.0 | 5 votes |
/** * Check if the IME specified by the context is enabled. * CAVEAT: This may cause a round trip IPC. * * @param context package context of the IME to be checked. * @param imm the {@link InputMethodManager}. * @return true if this IME is enabled. */ public static boolean isThisImeEnabled(final Context context, final InputMethodManager imm) { final String packageName = context.getPackageName(); for (final InputMethodInfo imi : imm.getEnabledInputMethodList()) { if (packageName.equals(imi.getPackageName())) { return true; } } return false; }