Java 类android.view.inputmethod.InputMethodInfo 实例源码

项目:simple-keyboard    文件:RichInputMethodManager.java   
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;
}
项目:simple-keyboard    文件:CustomInputStylePreference.java   
public SubtypeLocaleAdapter(final Context context) {
    super(context, android.R.layout.simple_spinner_item);
    setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    final TreeSet<SubtypeLocaleItem> items = new TreeSet<>();
    final InputMethodInfo imi = RichInputMethodManager.getInstance()
            .getInputMethodInfoOfThisIme();
    final int count = imi.getSubtypeCount();
    for (int i = 0; i < count; i++) {
        final InputMethodSubtype subtype = imi.getSubtypeAt(i);
        if (DEBUG_SUBTYPE_ID) {
            Log.d(TAG_SUBTYPE, String.format("%-6s 0x%08x %11d %s",
                    subtype.getLocale(), subtype.hashCode(), subtype.hashCode(),
                    SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(subtype)));
        }
        if (InputMethodSubtypeCompatUtils.isAsciiCapable(subtype)) {
            items.add(new SubtypeLocaleItem(subtype));
        }
    }
    // TODO: Should filter out already existing combinations of locale and layout.
    addAll(items);
}
项目:simple-keyboard    文件:InputMethodSettingsImpl.java   
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();
}
项目:Swift-Braille-Soft-keyboard    文件:ImeTrigger.java   
/**
 * Switches to Voice IME.
 */
@Override
public void startVoiceRecognition(String language) {
    InputMethodManager inputMethodManager = getInputMethodManager(mInputMethodService);

    InputMethodInfo inputMethodInfo = getVoiceImeInputMethodInfo(inputMethodManager);

    if (inputMethodInfo == null) {
        return;
    }

    inputMethodManager.setInputMethodAndSubtype(mInputMethodService.getWindow().getWindow()
            .getAttributes().token,
            inputMethodInfo.getId(),
            getVoiceImeSubtype(inputMethodManager, inputMethodInfo));
}
项目:myan    文件:InputMethodSettingsImpl.java   
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();
}
项目:AOSP-Kayboard-7.1.2    文件:RichInputMethodManager.java   
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;
}
项目:AOSP-Kayboard-7.1.2    文件:RichInputMethodManager.java   
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;
}
项目:AOSP-Kayboard-7.1.2    文件:CustomInputStylePreference.java   
public SubtypeLocaleAdapter(final Context context) {
    super(context, android.R.layout.simple_spinner_item);
    setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    final TreeSet<SubtypeLocaleItem> items = new TreeSet<>();
    final InputMethodInfo imi = RichInputMethodManager.getInstance()
            .getInputMethodInfoOfThisIme();
    final int count = imi.getSubtypeCount();
    for (int i = 0; i < count; i++) {
        final InputMethodSubtype subtype = imi.getSubtypeAt(i);
        if (DEBUG_SUBTYPE_ID) {
            Log.d(TAG_SUBTYPE, String.format("%-6s 0x%08x %11d %s",
                    subtype.getLocale(), subtype.hashCode(), subtype.hashCode(),
                    SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(subtype)));
        }
        if (InputMethodSubtypeCompatUtils.isAsciiCapable(subtype)) {
            items.add(new SubtypeLocaleItem(subtype));
        }
    }
    // TODO: Should filter out already existing combinations of locale and layout.
    addAll(items);
}
项目:AOSP-Kayboard-7.1.2    文件:InputMethodSettingsImpl.java   
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();
}
项目:accentype-android    文件:InputMethodSettingsImpl.java   
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();
}
项目:webkeyboard    文件:MainActivity.java   
/**
 *
 * @return
 */
private boolean isWebKeyboardEnabled() {
    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    List<InputMethodInfo> enabledList = imm.getEnabledInputMethodList();
    Iterator<InputMethodInfo> it = enabledList.iterator();

    boolean available = false;
    while (it.hasNext()) {
        available = it.next()
                .getServiceName()
                .equals(RemoteKeyboardService.class.getCanonicalName());
        if (available) {
            break;
        }
    }

    return available;
}
项目:ContentBlocker    文件:RawResources.java   
/**
 * Gets input languages
 *
 * @param context Application context
 * @return List of input languages
 */
private static List<String> getInputLanguages(Context context) {
    List<String> languages = new ArrayList<>();

    try {
        InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
        List<InputMethodInfo> ims = imm.getEnabledInputMethodList();

        for (InputMethodInfo method : ims) {
            List<InputMethodSubtype> subMethods = imm.getEnabledInputMethodSubtypeList(method, true);
            for (InputMethodSubtype subMethod : subMethods) {
                if ("keyboard".equals(subMethod.getMode())) {
                    String currentLocale = subMethod.getLocale();
                    String language = cleanUpLanguageCode(new Locale(currentLocale).getLanguage());
                    if (!languages.contains(language)) {
                        languages.add(language);
                    }
                }
            }
        }
    } catch (Exception ex) {
        LOG.warn("Cannot get user input languages\r\n", ex);
    }

    return languages;
}
项目:Newton_for_Android_AS    文件:UIUtil.java   
/**
 * 获取已激活输入法的详细信息
 * @param context
 * @param packageName 输入法应用的包名
 * @return
 */
public static InputMethodInfo getEnableInputMethodInfor(Context context, String packageName) {
    if (packageName == null) {
        return null;
    }
    final InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    List<InputMethodInfo> imeInfoList = imm.getEnabledInputMethodList();

    if (imeInfoList != null) {
        for (InputMethodInfo imeInfo : imeInfoList) {
            if (packageName.equals(imeInfo.getPackageName())) {
                return imeInfo;
            }
        }
    }
    return null;
}
项目:cryptogram    文件:SimpleInputConnection.java   
@Nullable
public static InputMethodInfo getIme(Context context) {
    final InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    final InputMethodSubtype ims = imm.getCurrentInputMethodSubtype();
    if (ims != null) {
        for (InputMethodInfo imi : imm.getEnabledInputMethodList()) {
            if (imi == null) {
                continue;
            }
            for (int i = 0; i < imi.getSubtypeCount(); i++) {
                if (ims.equals(imi.getSubtypeAt(i))) {
                    return imi;
                }
            }
        }
    }
    return null;
}
项目:kgb    文件:KeyboardSwitcher.java   
public static List<String> getKeyboards(Context context) {
  InputMethodManager imeManager = (InputMethodManager) context
      .getSystemService(Context.INPUT_METHOD_SERVICE);
  if (imeManager == null) {
    return Collections.emptyList();
  }

  List<InputMethodInfo> imesInfo = imeManager.getEnabledInputMethodList();
  List<String> keyboards = new ArrayList<>(imesInfo.size());

  for (InputMethodInfo imi : imesInfo) {
    keyboards.add(imi.getId());
  }

  return keyboards;
}
项目:accentype-android    文件:InputMethodSettingsImpl.java   
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();
}
项目:Noyze    文件:PopupWindowManager.java   
protected ComponentName retrieveActiveInputMethod() {
       if (null == mContext) return null;
    final String id = Settings.Secure.getString(
        mContext.getContentResolver(), 
        Settings.Secure.DEFAULT_INPUT_METHOD
    );

    if (TextUtils.isEmpty(id)) return null;
    List<InputMethodInfo> mInputMethodProperties = mInputMethodManager.getEnabledInputMethodList();
    for (InputMethodInfo mInputMethod : mInputMethodProperties) {
        if (id.equals(mInputMethod.getId())) {
            return mInputMethod.getComponent();
        }
    }

    return null;
}
项目:365browser    文件:UiUtils.java   
/**
 * 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;
}
项目:breadwallet-android    文件:Utils.java   
public static boolean isUsingCustomInputMethod(Activity context) {
    if (context == null) return false;
    InputMethodManager imm = (InputMethodManager) context.getSystemService(
            Context.INPUT_METHOD_SERVICE);
    List<InputMethodInfo> mInputMethodProperties = imm.getEnabledInputMethodList();
    final int N = mInputMethodProperties.size();
    for (int i = 0; i < N; i++) {
        InputMethodInfo imi = mInputMethodProperties.get(i);
        if (imi.getId().equals(
                Settings.Secure.getString(context.getContentResolver(),
                        Settings.Secure.DEFAULT_INPUT_METHOD))) {
            if ((imi.getServiceInfo().applicationInfo.flags &
                    ApplicationInfo.FLAG_SYSTEM) == 0) {
                return true;
            }
        }
    }
    return false;
}
项目:MUA-Keyboard    文件:InputMethodSettingsImpl.java   
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();
}
项目:CtrlVKeyboard    文件:SettingsActivity.java   
private boolean isKeyboardEnabled() {
    InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(
            Context.INPUT_METHOD_SERVICE);
    List<InputMethodInfo> inputMethodList = inputMethodManager.getEnabledInputMethodList();
    ComponentName ctrlV = new ComponentName(this, CtrlVKeyboard.class);
    boolean ctrlVIsEnabled = false;
    int i = 0;

    while (!ctrlVIsEnabled && i < inputMethodList.size()) {
        if (inputMethodList.get(i).getComponent().equals(ctrlV)) {
            ctrlVIsEnabled = true;
        }
        i++;
    }

    return ctrlVIsEnabled;
}
项目:Noyze    文件:PopupWindowManager.java   
protected ComponentName retrieveActiveInputMethod() {
       if (null == mContext) return null;
    final String id = Settings.Secure.getString(
        mContext.getContentResolver(), 
        Settings.Secure.DEFAULT_INPUT_METHOD
    );

    if (TextUtils.isEmpty(id)) return null;
    List<InputMethodInfo> mInputMethodProperties = mInputMethodManager.getEnabledInputMethodList();
    for (InputMethodInfo mInputMethod : mInputMethodProperties) {
        if (id.equals(mInputMethod.getId())) {
            return mInputMethod.getComponent();
        }
    }

    return null;
}
项目:animal    文件:InputMethodSettingsImpl.java   
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();
}
项目:android-kioskime    文件:RichInputMethodManager.java   
private boolean switchToNextInputMethodAndSubtype(final IBinder token) {
    final InputMethodManager imm = mImmWrapper.mImm;
    final List<InputMethodInfo> enabledImis = imm.getEnabledInputMethodList();
    final int currentIndex = getImiIndexInList(mInputMethodInfoOfThisIme, enabledImis);
    if (currentIndex == INDEX_NOT_FOUND) {
        Log.w(TAG, "Can't find current IME in enabled IMEs: IME package="
                + mInputMethodInfoOfThisIme.getPackageName());
        return false;
    }
    final InputMethodInfo nextImi = getNextNonAuxiliaryIme(currentIndex, enabledImis);
    final List<InputMethodSubtype> enabledSubtypes = imm.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;
}
项目:android-kioskime    文件:AdditionalSubtypeSettings.java   
public SubtypeLocaleAdapter(final Context context) {
    super(context, android.R.layout.simple_spinner_item);
    setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    final TreeSet<SubtypeLocaleItem> items = CollectionUtils.newTreeSet();
    final InputMethodInfo imi = RichInputMethodManager.getInstance()
            .getInputMethodInfoOfThisIme();
    final int count = imi.getSubtypeCount();
    for (int i = 0; i < count; i++) {
        final InputMethodSubtype subtype = imi.getSubtypeAt(i);
        if (DEBUG_SUBTYPE_ID) {
            android.util.Log.d(TAG, String.format("%-6s 0x%08x %11d %s",
                    subtype.getLocale(), subtype.hashCode(), subtype.hashCode(),
                    SubtypeLocale.getSubtypeDisplayNameInSystemLocale(subtype)));
        }
        if (subtype.containsExtraValueKey(ASCII_CAPABLE)) {
            items.add(createItem(context, subtype.getLocale()));
        }
    }
    // TODO: Should filter out already existing combinations of locale and layout.
    addAll(items);
}
项目:android-kioskime    文件:InputMethodSettingsImpl.java   
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();
}
项目:ROKOmoji.Emoji.Keyboard.App-Android    文件:KeyboardService.java   
public static boolean rokomojiEnabled(Activity activity) {
//        requestPermissionIfNeeded(Manifest.permission.READ_EXTERNAL_STORAGE, activity);
        InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
        List<InputMethodInfo> imList = imm.getEnabledInputMethodList();
        for (InputMethodInfo imi : imList) {

            if (activity.getPackageName().equalsIgnoreCase(imi.getPackageName()) && SERVICE_NAME.equalsIgnoreCase(imi.getServiceName())) {
                //if (SERVICE_NAME.equalsIgnoreCase(imi.getServiceName())) {
                return true;
            }
        }
        return false;
    }
项目:simple-keyboard    文件:RichInputMethodManager.java   
private static int getImiIndexInList(final InputMethodInfo inputMethodInfo,
        final List<InputMethodInfo> imiList) {
    final int count = imiList.size();
    for (int index = 0; index < count; index++) {
        final InputMethodInfo imi = imiList.get(index);
        if (imi.equals(inputMethodInfo)) {
            return index;
        }
    }
    return INDEX_NOT_FOUND;
}
项目:simple-keyboard    文件:RichInputMethodManager.java   
private static InputMethodInfo getNextNonAuxiliaryIme(final int currentIndex,
        final List<InputMethodInfo> imiList) {
    final int count = imiList.size();
    for (int i = 1; i < count; i++) {
        final int nextIndex = (currentIndex + i) % count;
        final InputMethodInfo nextImi = imiList.get(nextIndex);
        if (!isAuxiliaryIme(nextImi)) {
            return nextImi;
        }
    }
    return imiList.get(currentIndex);
}
项目:simple-keyboard    文件:RichInputMethodManager.java   
private static boolean isAuxiliaryIme(final InputMethodInfo imi) {
    final int count = imi.getSubtypeCount();
    if (count == 0) {
        return false;
    }
    for (int index = 0; index < count; index++) {
        final InputMethodSubtype subtype = imi.getSubtypeAt(index);
        if (!subtype.isAuxiliary()) {
            return false;
        }
    }
    return true;
}
项目:simple-keyboard    文件:RichInputMethodManager.java   
public synchronized InputMethodInfo getInputMethodOfThisIme() {
    if (mCachedThisImeInfo != null) {
        return mCachedThisImeInfo;
    }
    for (final InputMethodInfo imi : mImm.getInputMethodList()) {
        if (imi.getPackageName().equals(mImePackageName)) {
            mCachedThisImeInfo = imi;
            return imi;
        }
    }
    throw new RuntimeException("Input method id for " + mImePackageName + " not found.");
}
项目:simple-keyboard    文件:RichInputMethodManager.java   
public synchronized List<InputMethodSubtype> getEnabledInputMethodSubtypeList(
        final InputMethodInfo imi, final boolean allowsImplicitlySelectedSubtypes) {
    final HashMap<InputMethodInfo, List<InputMethodSubtype>> cache =
            allowsImplicitlySelectedSubtypes
            ? mCachedSubtypeListWithImplicitlySelected
            : mCachedSubtypeListOnlyExplicitlySelected;
    final List<InputMethodSubtype> cachedList = cache.get(imi);
    if (cachedList != null) {
        return cachedList;
    }
    final List<InputMethodSubtype> result = mImm.getEnabledInputMethodSubtypeList(
            imi, allowsImplicitlySelectedSubtypes);
    cache.put(imi, result);
    return result;
}
项目:simple-keyboard    文件:RichInputMethodManager.java   
public InputMethodSubtype findSubtypeByLocaleAndKeyboardLayoutSet(final String localeString,
        final String keyboardLayoutSetName) {
    final InputMethodInfo myImi = getInputMethodInfoOfThisIme();
    final int count = myImi.getSubtypeCount();
    for (int i = 0; i < count; i++) {
        final InputMethodSubtype subtype = myImi.getSubtypeAt(i);
        final String layoutName = SubtypeLocaleUtils.getKeyboardLayoutSetName(subtype);
        if (localeString.equals(subtype.getLocale())
                && keyboardLayoutSetName.equals(layoutName)) {
            return subtype;
        }
    }
    return null;
}
项目:simple-keyboard    文件:RichInputMethodManager.java   
private void updateShortcutIme() {
    if (DEBUG) {
        Log.d(TAG, "Update shortcut IME from : "
                + (mShortcutInputMethodInfo == null
                        ? "<null>" : mShortcutInputMethodInfo.getId()) + ", "
                + (mShortcutSubtype == null ? "<null>" : (
                        mShortcutSubtype.getLocale() + ", " + mShortcutSubtype.getMode())));
    }
    final RichInputMethodSubtype richSubtype = mCurrentRichInputMethodSubtype;
    final boolean implicitlyEnabledSubtype = checkIfSubtypeBelongsToThisImeAndImplicitlyEnabled(
            richSubtype.getRawSubtype());
    final Locale systemLocale = mContext.getResources().getConfiguration().locale;
    LanguageOnSpacebarUtils.onSubtypeChanged(
            richSubtype, implicitlyEnabledSubtype, systemLocale);
    LanguageOnSpacebarUtils.setEnabledSubtypes(getMyEnabledInputMethodSubtypeList(
            true /* allowsImplicitlySelectedSubtypes */));

    // TODO: Update an icon for shortcut IME
    final Map<InputMethodInfo, List<InputMethodSubtype>> shortcuts =
            getInputMethodManager().getShortcutInputMethodsAndSubtypes();
    mShortcutInputMethodInfo = null;
    mShortcutSubtype = null;
    for (final InputMethodInfo imi : shortcuts.keySet()) {
        final List<InputMethodSubtype> subtypes = shortcuts.get(imi);
        // TODO: Returns the first found IMI for now. Should handle all shortcuts as
        // appropriate.
        mShortcutInputMethodInfo = imi;
        // TODO: Pick up the first found subtype for now. Should handle all subtypes
        // as appropriate.
        mShortcutSubtype = subtypes.size() > 0 ? subtypes.get(0) : null;
        break;
    }
    if (DEBUG) {
        Log.d(TAG, "Update shortcut IME to : "
                + (mShortcutInputMethodInfo == null
                        ? "<null>" : mShortcutInputMethodInfo.getId()) + ", "
                + (mShortcutSubtype == null ? "<null>" : (
                        mShortcutSubtype.getLocale() + ", " + mShortcutSubtype.getMode())));
    }
}
项目:simple-keyboard    文件:InputMethodSettingsImpl.java   
private static InputMethodInfo getMyImi(Context context, InputMethodManager imm) {
    final List<InputMethodInfo> imis = imm.getInputMethodList();
    for (int i = 0; i < imis.size(); ++i) {
        final InputMethodInfo imi = imis.get(i);
        if (imis.get(i).getPackageName().equals(context.getPackageName())) {
            return imi;
        }
    }
    return null;
}
项目:Bigbang    文件:XposedBigBang.java   
private Set<String> getInputMethodAsWhiteList(Context context) {
    HashSet<String> packages = new HashSet<>();
    InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    List<InputMethodInfo> methodList = imm.getInputMethodList();
    for (InputMethodInfo info : methodList) {
        packages.add(info.getPackageName());
    }
    return packages;
}
项目:chromium-for-android-56-debug-video    文件: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);
    }
}
项目:Swift-Braille-Soft-keyboard    文件:ImeTrigger.java   
private InputMethodSubtype getVoiceImeSubtype(
        InputMethodManager inputMethodManager, InputMethodInfo inputMethodInfo)
        throws SecurityException,
        IllegalArgumentException {
    Map<InputMethodInfo, List<InputMethodSubtype>> map = inputMethodManager
            .getShortcutInputMethodsAndSubtypes();
    List<InputMethodSubtype> list = map.get(inputMethodInfo);
    if (list != null && list.size() > 0) {
        return list.get(0);
    } else {
        return null;
    }
}
项目:Swift-Braille-Soft-keyboard    文件:ImeTrigger.java   
private static InputMethodInfo getVoiceImeInputMethodInfo(InputMethodManager inputMethodManager)
        throws SecurityException, IllegalArgumentException {
    for (InputMethodInfo inputMethodInfo : inputMethodManager.getEnabledInputMethodList()) {
        for (int i = 0; i < inputMethodInfo.getSubtypeCount(); i++) {
            InputMethodSubtype subtype = inputMethodInfo.getSubtypeAt(i);
            if (VOICE_IME_SUBTYPE_MODE.equals(subtype.getMode())) {
                if (inputMethodInfo.getComponent().getPackageName()
                        .startsWith(VOICE_IME_PACKAGE_PREFIX)) {
                    return inputMethodInfo;
                }
            }
        }
    }
    return null;
}
项目:Swift-Braille-Soft-keyboard    文件:ImeTrigger.java   
/**
 * Returns true if an implementation of Voice IME is installed.
 */
public static boolean isInstalled(InputMethodService inputMethodService) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        return false;
    }

    InputMethodInfo inputMethodInfo = getVoiceImeInputMethodInfo(
            getInputMethodManager(inputMethodService));

    if (inputMethodInfo == null) {
        return false;
    }

    return inputMethodInfo.getSubtypeCount() > 0;
}