Example usage for android.view.inputmethod InputMethodSubtype getLocale

List of usage examples for android.view.inputmethod InputMethodSubtype getLocale

Introduction

In this page you can find the example usage for android.view.inputmethod InputMethodSubtype getLocale.

Prototype

@Deprecated
@NonNull
public String getLocale() 

Source Link

Usage

From source file:Main.java

public static boolean isNoLanguage(final InputMethodSubtype subtype) {
    final String localeString = subtype.getLocale();
    return NO_LANGUAGE.equals(localeString);
}

From source file:Main.java

public static String getLocale(final Context context) {
    InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    InputMethodSubtype ims = imm.getCurrentInputMethodSubtype();
    return ims == null ? "" : ims.getLocale();
}

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

/**
 * Gets input languages//from w  ww  .  j  ava  2 s.  c o 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:com.android.inputmethod.latin.settings.CustomInputStyleSettingsFragment.java

private InputMethodSubtype findDuplicatedSubtype(final InputMethodSubtype subtype) {
    final String localeString = subtype.getLocale();
    final String keyboardLayoutSetName = SubtypeLocaleUtils.getKeyboardLayoutSetName(subtype);
    return mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(localeString, keyboardLayoutSetName);
}

From source file:com.android.screenspeak.eventprocessor.ProcessorPhoneticLetters.java

/**
 * Handle an event that indicates a key is held on the soft keyboard.
 */// ww w .  j a v a  2  s. c o  m
private void processKeyboardKeyEvent(AccessibilityEvent event) {
    final CharSequence text = AccessibilityEventUtils.getEventTextOrDescription(event);
    if (TextUtils.isEmpty(text)) {
        return;
    }

    String localeString = FALLBACK_LOCALE;
    InputMethodManager inputMethodManager = (InputMethodManager) mService
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    InputMethodSubtype inputMethod = inputMethodManager.getCurrentInputMethodSubtype();
    if (inputMethod != null) {
        localeString = inputMethod.getLocale();
    }

    String phoneticLetter = getPhoneticLetter(localeString, text.toString());
    if (phoneticLetter != null) {
        postPhoneticLetterRunnable(phoneticLetter);
    }
}