Search in sources :

Example 31 with InputMethodSubtype

use of android.view.inputmethod.InputMethodSubtype in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class InputMethodSettingValuesWrapper method updateAsciiCapableEnabledImis.

// TODO: Add a cts to ensure at least one AsciiCapableSubtypeEnabledImis exist
private void updateAsciiCapableEnabledImis() {
    synchronized (mMethodMap) {
        mAsciiCapableEnabledImis.clear();
        final List<InputMethodInfo> enabledImis = mSettings.getEnabledInputMethodListLocked();
        for (final InputMethodInfo imi : enabledImis) {
            final int subtypeCount = imi.getSubtypeCount();
            for (int i = 0; i < subtypeCount; ++i) {
                final InputMethodSubtype subtype = imi.getSubtypeAt(i);
                if (InputMethodUtils.SUBTYPE_MODE_KEYBOARD.equalsIgnoreCase(subtype.getMode()) && subtype.isAsciiCapable()) {
                    mAsciiCapableEnabledImis.add(imi);
                    break;
                }
            }
        }
    }
}
Also used : InputMethodSubtype(android.view.inputmethod.InputMethodSubtype) InputMethodInfo(android.view.inputmethod.InputMethodInfo)

Example 32 with InputMethodSubtype

use of android.view.inputmethod.InputMethodSubtype in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class InputMethodSettingValuesWrapper method getCurrentInputMethodName.

CharSequence getCurrentInputMethodName(Context context) {
    synchronized (mMethodMap) {
        final InputMethodInfo imi = mMethodMap.get(mSettings.getSelectedInputMethod());
        if (imi == null) {
            Log.w(TAG, "Invalid selected imi: " + mSettings.getSelectedInputMethod());
            return "";
        }
        final InputMethodSubtype subtype = mImm.getCurrentInputMethodSubtype();
        return InputMethodUtils.getImeAndSubtypeDisplayName(context, imi, subtype);
    }
}
Also used : InputMethodSubtype(android.view.inputmethod.InputMethodSubtype) InputMethodInfo(android.view.inputmethod.InputMethodInfo)

Example 33 with InputMethodSubtype

use of android.view.inputmethod.InputMethodSubtype in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class CryptKeeper method hasMultipleEnabledIMEsOrSubtypes.

/**
     * Method adapted from com.android.inputmethod.latin.Utils
     *
     * @param imm The input method manager
     * @param shouldIncludeAuxiliarySubtypes
     * @return true if we have multiple IMEs to choose from
     */
private boolean hasMultipleEnabledIMEsOrSubtypes(InputMethodManager imm, final boolean shouldIncludeAuxiliarySubtypes) {
    final List<InputMethodInfo> enabledImis = imm.getEnabledInputMethodList();
    // Number of the filtered IMEs
    int filteredImisCount = 0;
    for (InputMethodInfo imi : enabledImis) {
        // We can return true immediately after we find two or more filtered IMEs.
        if (filteredImisCount > 1)
            return true;
        final List<InputMethodSubtype> subtypes = imm.getEnabledInputMethodSubtypeList(imi, true);
        // IMEs that have no subtypes should be counted.
        if (subtypes.isEmpty()) {
            ++filteredImisCount;
            continue;
        }
        int auxCount = 0;
        for (InputMethodSubtype subtype : subtypes) {
            if (subtype.isAuxiliary()) {
                ++auxCount;
            }
        }
        final int nonAuxCount = subtypes.size() - auxCount;
        // subtypes should be counted as well.
        if (nonAuxCount > 0 || (shouldIncludeAuxiliarySubtypes && auxCount > 1)) {
            ++filteredImisCount;
            continue;
        }
    }
    return filteredImisCount > 1 || // input method subtype (The current IME should be LatinIME.)
    imm.getEnabledInputMethodSubtypeList(null, false).size() > 1;
}
Also used : InputMethodSubtype(android.view.inputmethod.InputMethodSubtype) InputMethodInfo(android.view.inputmethod.InputMethodInfo)

Example 34 with InputMethodSubtype

use of android.view.inputmethod.InputMethodSubtype in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class InputMethodAndLanguageSettings method saveEnabledSubtypesOf.

private void saveEnabledSubtypesOf(final InputMethodInfo imi) {
    final HashSet<String> enabledSubtypeIdSet = new HashSet<>();
    final List<InputMethodSubtype> enabledSubtypes = mImm.getEnabledInputMethodSubtypeList(imi, true);
    for (final InputMethodSubtype subtype : enabledSubtypes) {
        final String subtypeId = Integer.toString(subtype.hashCode());
        enabledSubtypeIdSet.add(subtypeId);
    }
    final HashMap<String, HashSet<String>> imeToEnabledSubtypeIdsMap = loadPreviouslyEnabledSubtypeIdsMap();
    final String imiId = imi.getId();
    imeToEnabledSubtypeIdsMap.put(imiId, enabledSubtypeIdSet);
    savePreviouslyEnabledSubtypeIdsMap(imeToEnabledSubtypeIdsMap);
}
Also used : InputMethodSubtype(android.view.inputmethod.InputMethodSubtype) HashSet(java.util.HashSet)

Example 35 with InputMethodSubtype

use of android.view.inputmethod.InputMethodSubtype in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class InputMethodAndSubtypeEnabler method updateImplicitlyEnabledSubtypesOf.

private void updateImplicitlyEnabledSubtypesOf(final InputMethodInfo imi, final boolean check) {
    final String imiId = imi.getId();
    final List<Preference> subtypePrefs = mInputMethodAndSubtypePrefsMap.get(imiId);
    final List<InputMethodSubtype> implicitlyEnabledSubtypes = mImm.getEnabledInputMethodSubtypeList(imi, true);
    if (subtypePrefs == null || implicitlyEnabledSubtypes == null) {
        return;
    }
    for (final Preference pref : subtypePrefs) {
        if (!(pref instanceof TwoStatePreference)) {
            continue;
        }
        final TwoStatePreference subtypePref = (TwoStatePreference) pref;
        subtypePref.setChecked(false);
        if (check) {
            for (final InputMethodSubtype subtype : implicitlyEnabledSubtypes) {
                final String implicitlyEnabledSubtypePrefKey = imiId + subtype.hashCode();
                if (subtypePref.getKey().equals(implicitlyEnabledSubtypePrefKey)) {
                    subtypePref.setChecked(true);
                    break;
                }
            }
        }
    }
}
Also used : InputMethodSubtype(android.view.inputmethod.InputMethodSubtype) TwoStatePreference(android.support.v7.preference.TwoStatePreference) TwoStatePreference(android.support.v7.preference.TwoStatePreference) Preference(android.support.v7.preference.Preference)

Aggregations

InputMethodSubtype (android.view.inputmethod.InputMethodSubtype)195 InputMethodInfo (android.view.inputmethod.InputMethodInfo)92 ArrayList (java.util.ArrayList)48 Locale (java.util.Locale)17 LocaleList (android.os.LocaleList)15 ImeSubtypeListItem (com.android.internal.inputmethod.InputMethodSubtypeSwitchingController.ImeSubtypeListItem)15 InputMethodManager (android.view.inputmethod.InputMethodManager)14 Context (android.content.Context)12 SmallTest (android.test.suitebuilder.annotation.SmallTest)10 View (android.view.View)9 TextView (android.widget.TextView)9 RichInputMethodSubtype (com.android.inputmethod.latin.RichInputMethodSubtype)8 List (java.util.List)8 Intent (android.content.Intent)7 Pair (android.util.Pair)7 AlertDialog (android.app.AlertDialog)6 PendingIntent (android.app.PendingIntent)6 DialogInterface (android.content.DialogInterface)6 OnCancelListener (android.content.DialogInterface.OnCancelListener)6 TypedArray (android.content.res.TypedArray)6