use of android.view.inputmethod.InputMethodInfo in project android_frameworks_base by ParanoidAndroid.
the class InputMethodsPanel method getEnabledInputMethodAndSubtypeList.
private TreeMap<InputMethodInfo, List<InputMethodSubtype>> getEnabledInputMethodAndSubtypeList() {
String newEnabledIMIs = Settings.Secure.getString(mContext.getContentResolver(), Settings.Secure.ENABLED_INPUT_METHODS);
String currentSystemLocaleString = mContext.getResources().getConfiguration().locale.toString();
if (!TextUtils.equals(mEnabledInputMethodAndSubtypesCacheStr, newEnabledIMIs) || !TextUtils.equals(mLastSystemLocaleString, currentSystemLocaleString) || mPackageChanged) {
mEnabledInputMethodAndSubtypesCache.clear();
final List<InputMethodInfo> imis = mImm.getEnabledInputMethodList();
for (InputMethodInfo imi : imis) {
mEnabledInputMethodAndSubtypesCache.put(imi, mImm.getEnabledInputMethodSubtypeList(imi, true));
}
mEnabledInputMethodAndSubtypesCacheStr = newEnabledIMIs;
mPackageChanged = false;
mLastSystemLocaleString = currentSystemLocaleString;
}
return mEnabledInputMethodAndSubtypesCache;
}
use of android.view.inputmethod.InputMethodInfo in project android_frameworks_base by ParanoidAndroid.
the class InputMethodsPanel method getCurrentInputMethodInfo.
private InputMethodInfo getCurrentInputMethodInfo() {
String curInputMethodId = Settings.Secure.getString(getContext().getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD);
Set<InputMethodInfo> cachedImiSet = mEnabledInputMethodAndSubtypesCache.keySet();
// 1. Search IMI in cache
for (InputMethodInfo imi : cachedImiSet) {
if (imi.getId().equals(curInputMethodId)) {
return imi;
}
}
// 2. Get current enabled IMEs and search IMI
cachedImiSet = getEnabledInputMethodAndSubtypeList().keySet();
for (InputMethodInfo imi : cachedImiSet) {
if (imi.getId().equals(curInputMethodId)) {
return imi;
}
}
return null;
}
use of android.view.inputmethod.InputMethodInfo in project android_frameworks_base by ParanoidAndroid.
the class QuickSettingsModel method getCurrentInputMethodName.
private static String getCurrentInputMethodName(Context context, ContentResolver resolver, InputMethodManager imm, List<InputMethodInfo> imis, PackageManager pm) {
if (resolver == null || imis == null)
return null;
final String currentInputMethodId = Settings.Secure.getString(resolver, Settings.Secure.DEFAULT_INPUT_METHOD);
if (TextUtils.isEmpty(currentInputMethodId))
return null;
for (InputMethodInfo imi : imis) {
if (currentInputMethodId.equals(imi.getId())) {
final InputMethodSubtype subtype = imm.getCurrentInputMethodSubtype();
final CharSequence summary = subtype != null ? subtype.getDisplayName(context, imi.getPackageName(), imi.getServiceInfo().applicationInfo) : context.getString(R.string.quick_settings_ime_label);
return summary.toString();
}
}
return null;
}
use of android.view.inputmethod.InputMethodInfo in project android_frameworks_base by ParanoidAndroid.
the class QuickSettingsModel method needsToShowImeSwitchOngoingNotification.
/* This implementation is taken from
InputMethodManagerService.needsToShowImeSwitchOngoingNotification(). */
private boolean needsToShowImeSwitchOngoingNotification(InputMethodManager imm) {
List<InputMethodInfo> imis = imm.getEnabledInputMethodList();
final int N = imis.size();
if (N > 2)
return true;
if (N < 1)
return false;
int nonAuxCount = 0;
int auxCount = 0;
InputMethodSubtype nonAuxSubtype = null;
InputMethodSubtype auxSubtype = null;
for (int i = 0; i < N; ++i) {
final InputMethodInfo imi = imis.get(i);
final List<InputMethodSubtype> subtypes = imm.getEnabledInputMethodSubtypeList(imi, true);
final int subtypeCount = subtypes.size();
if (subtypeCount == 0) {
++nonAuxCount;
} else {
for (int j = 0; j < subtypeCount; ++j) {
final InputMethodSubtype subtype = subtypes.get(j);
if (!subtype.isAuxiliary()) {
++nonAuxCount;
nonAuxSubtype = subtype;
} else {
++auxCount;
auxSubtype = subtype;
}
}
}
}
if (nonAuxCount > 1 || auxCount > 1) {
return true;
} else if (nonAuxCount == 1 && auxCount == 1) {
if (nonAuxSubtype != null && auxSubtype != null && (nonAuxSubtype.getLocale().equals(auxSubtype.getLocale()) || auxSubtype.overridesImplicitlyEnabledSubtype() || nonAuxSubtype.overridesImplicitlyEnabledSubtype()) && nonAuxSubtype.containsExtraValueKey(TAG_TRY_SUPPRESSING_IME_SWITCHER)) {
return false;
}
return true;
}
return false;
}
use of android.view.inputmethod.InputMethodInfo in project android_frameworks_base by ParanoidAndroid.
the class InputMethodButton method needsToShowIMEButtonWhenVisibilityAuto.
// Refer to InputMethodManagerService.needsToShowImeSwitchOngoingNotification()
private boolean needsToShowIMEButtonWhenVisibilityAuto() {
List<InputMethodInfo> imis = mImm.getEnabledInputMethodList();
final int N = imis.size();
if (N > 2)
return true;
if (N < 1)
return false;
int nonAuxCount = 0;
int auxCount = 0;
InputMethodSubtype nonAuxSubtype = null;
InputMethodSubtype auxSubtype = null;
for (int i = 0; i < N; ++i) {
final InputMethodInfo imi = imis.get(i);
final List<InputMethodSubtype> subtypes = mImm.getEnabledInputMethodSubtypeList(imi, true);
final int subtypeCount = subtypes.size();
if (subtypeCount == 0) {
++nonAuxCount;
} else {
for (int j = 0; j < subtypeCount; ++j) {
final InputMethodSubtype subtype = subtypes.get(j);
if (!subtype.isAuxiliary()) {
++nonAuxCount;
nonAuxSubtype = subtype;
} else {
++auxCount;
auxSubtype = subtype;
}
}
}
}
if (nonAuxCount > 1 || auxCount > 1) {
return true;
} else if (nonAuxCount == 1 && auxCount == 1) {
if (nonAuxSubtype != null && auxSubtype != null && (nonAuxSubtype.getLocale().equals(auxSubtype.getLocale()) || auxSubtype.overridesImplicitlyEnabledSubtype() || nonAuxSubtype.overridesImplicitlyEnabledSubtype()) && nonAuxSubtype.containsExtraValueKey(TAG_TRY_SUPPRESSING_IME_SWITCHER)) {
return false;
}
return true;
}
return false;
}
Aggregations