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;
}
}
}
}
}
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);
}
}
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;
}
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);
}
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;
}
}
}
}
}
Aggregations