Example usage for android.view.inputmethod InputMethodManager getEnabledInputMethodList

List of usage examples for android.view.inputmethod InputMethodManager getEnabledInputMethodList

Introduction

In this page you can find the example usage for android.view.inputmethod InputMethodManager getEnabledInputMethodList.

Prototype

public List<InputMethodInfo> getEnabledInputMethodList() 

Source Link

Usage

From source file:Main.java

/**
 * 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./*from   w  ww  . j a v a  2 s  . c om*/
 */
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;
}

From source file:Main.java

public static String isVoiceSearchServiceExist(Context context) {
    if (DEBUG)/*  w  ww .ja  v  a2 s .  com*/
        Log.i(TAG, "isVoiceSearchServiceExist()");

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

    //boolean isVoiceSearchServiceEnabled = false;
    for (int i = 0; i < mInputMethodProperties.size(); i++) {
        InputMethodInfo imi = mInputMethodProperties.get(i);
        if (DEBUG)
            Log.i(TAG, "enabled IM " + i + ":" + imi.getId());

        if (imi.getId().equals("com.google.android.voicesearch/.ime.VoiceInputMethodService")) {
            return "com.google.android.voicesearch/.ime.VoiceInputMethodService";
        } else if (imi.getId().equals(
                "com.google.android.googlequicksearchbox/com.google.android.voicesearch.ime.VoiceInputMethodService")) {
            return "com.google.android.googlequicksearchbox/com.google.android.voicesearch.ime.VoiceInputMethodService";
        }
    }
    return null;

}

From source file:com.adguard.android.commons.RawResources.java

/**
 * Gets input languages// ww  w .  j ava 2  s .co  m
 *
 * @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;
}

From source file:io.digibyte.tools.util.Utils.java

public static boolean isUsingCustomInputMethod(Activity context) {
    if (context == null)
        return false;
    InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    if (imm == null) {
        return false;
    }//from w w  w . j  ava 2s  . co  m
    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;
}

From source file:net.HeZi.Android.HeInputLibrary.HeInput_Activation_Fragment.java

private void updateUI() {
    boolean bActivated = false;
    boolean bDefaultKeyboard = false;
    boolean bDialectSelected = false;

    activeHeInputBtn.setEnabled(true);//from  w  ww.  j  a  v  a  2 s . c  o m
    selectDefaultMethodBtn.setEnabled(false);
    selectDefaultMethodBtn.setTextColor(Color.GRAY);
    selectChineseDialectBtn.setEnabled(false);
    selectChineseDialectBtn.setTextColor(Color.GRAY);

    //Check Activited
    //http://stackoverflow.com/questions/4210086/how-can-i-get-a-list-of-all-the-input-methods-and-their-names-that-are-install
    InputMethodManager imeManager = (InputMethodManager) getActivity().getApplicationContext()
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    List<InputMethodInfo> InputMethods = imeManager.getEnabledInputMethodList();

    for (InputMethodInfo item : InputMethods) {
        if (item.getPackageName().toLowerCase().equals(hostApplicationName.toLowerCase())) {
            bActivated = true;

            inputId = item.getId();
            Log.d("Input Id: ", "InputId: " + inputId);
            setting_instruction.setText(getString(R.string.instruction_2_steps));

            activeHeInputBtn.setEnabled(false);
            activeHeInputBtn.setTextColor(Color.GRAY);
            activeHeInputBtn.setText(getString(R.string.heInput_activated));

            selectDefaultMethodBtn.setEnabled(true);
            selectDefaultMethodBtn.setTextColor(Color.RED);

            selectChineseDialectBtn.setEnabled(false);
            selectChineseDialectBtn.setTextColor(Color.GRAY);

            break;
        }
    }

    // Check default keyboard
    if (bActivated) {
        String defaultName = Settings.Secure.getString(getActivity().getContentResolver(),
                Settings.Secure.DEFAULT_INPUT_METHOD);
        if (defaultName.toLowerCase().contains(hostApplicationName.toLowerCase())) {
            bDefaultKeyboard = true;
        }
    }

    if (bActivated && bDefaultKeyboard) {
        setting_instruction.setText(getString(R.string.instruction_setting_done));

        selectDefaultMethodBtn.setEnabled(false);
        selectDefaultMethodBtn.setTextColor(Color.GRAY);
        selectDefaultMethodBtn.setText(getString(R.string.heInput_is_default));

        selectChineseDialectBtn.setEnabled(true);
        selectChineseDialectBtn.setTextColor(Color.RED);

        editText.setVisibility(View.VISIBLE);
        editText.requestFocus();
    }
}

From source file:org.awesomeapp.messenger.MainActivity.java

private void checkCustomFont() {

    if (Preferences.isLanguageTibetan()) {
        CustomTypefaceManager.loadFromAssets(this, true);

    } else {/*from  w  w  w  . jav a 2s  .  co m*/
        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);
    }

}

From source file:info.guardianproject.otr.app.im.app.NewChatActivity.java

private void checkCustomFont() {
    if (CustomTypefaceManager.getCurrentTypeface(this) == null) {
        InputMethodManager imm = (InputMethodManager) 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);

            //imi contains the information about the keyboard you are using
            if (imi.getPackageName().equals("org.ironrabbit.bhoboard")) {
                CustomTypefaceManager.loadFromKeyboard(this);
                break;
            }/*from  w w w.jav a  2  s  .co  m*/

        }

    }
}