use of android.view.inputmethod.InputMethodSubtype in project android_packages_apps_Settings by crdroidandroid.
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 android_packages_apps_Settings by crdroidandroid.
the class PhysicalKeyboardFragment method onLoadFinishedInternal.
private void onLoadFinishedInternal(final int loaderId, @NonNull final List<Keyboards> keyboardsList) {
if (!mLoaderIDs.remove(loaderId)) {
// Already destroyed loader. Ignore.
return;
}
Collections.sort(keyboardsList);
final PreferenceScreen preferenceScreen = getPreferenceScreen();
preferenceScreen.removeAll();
for (Keyboards keyboards : keyboardsList) {
final PreferenceCategory category = new PreferenceCategory(getPrefContext(), null);
category.setTitle(keyboards.mDeviceInfo.mDeviceName);
category.setOrder(0);
preferenceScreen.addPreference(category);
for (Keyboards.KeyboardInfo info : keyboards.mKeyboardInfoList) {
mTempKeyboardInfoList.clear();
final InputMethodInfo imi = info.mImi;
final InputMethodSubtype imSubtype = info.mImSubtype;
if (imi != null) {
KeyboardInfoPreference pref = new KeyboardInfoPreference(getPrefContext(), info);
pref.setOnPreferenceClickListener(preference -> {
showKeyboardLayoutScreen(keyboards.mDeviceInfo.mDeviceIdentifier, imi, imSubtype);
return true;
});
mTempKeyboardInfoList.add(pref);
Collections.sort(mTempKeyboardInfoList);
}
for (KeyboardInfoPreference pref : mTempKeyboardInfoList) {
category.addPreference(pref);
}
}
}
mTempKeyboardInfoList.clear();
mKeyboardAssistanceCategory.setOrder(1);
preferenceScreen.addPreference(mKeyboardAssistanceCategory);
updateShowVirtualKeyboardSwitch();
}
use of android.view.inputmethod.InputMethodSubtype in project android_packages_apps_Settings by SudaMod.
the class UserDictionaryList method getUserDictionaryLocalesSet.
@NonNull
public static TreeSet<String> getUserDictionaryLocalesSet(Context context) {
final Cursor cursor = context.getContentResolver().query(UserDictionary.Words.CONTENT_URI, new String[] { UserDictionary.Words.LOCALE }, null, null, null);
final TreeSet<String> localeSet = new TreeSet<>();
if (cursor == null) {
// The user dictionary service is not present or disabled. Return empty set.
return localeSet;
}
try {
if (cursor.moveToFirst()) {
final int columnIndex = cursor.getColumnIndex(UserDictionary.Words.LOCALE);
do {
final String locale = cursor.getString(columnIndex);
localeSet.add(null != locale ? locale : "");
} while (cursor.moveToNext());
}
} finally {
cursor.close();
}
// CAVEAT: Keep this for consistency of the implementation between Keyboard and Settings
// if (!UserDictionarySettings.IS_SHORTCUT_API_SUPPORTED) {
// // For ICS, we need to show "For all languages" in case that the keyboard locale
// // is different from the system locale
// localeSet.add("");
// }
final InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
final List<InputMethodInfo> imis = imm.getEnabledInputMethodList();
for (final InputMethodInfo imi : imis) {
final List<InputMethodSubtype> subtypes = imm.getEnabledInputMethodSubtypeList(imi, true);
for (InputMethodSubtype subtype : subtypes) {
final String locale = subtype.getLocale();
if (!TextUtils.isEmpty(locale)) {
localeSet.add(locale);
}
}
}
// correct to add it.
if (!localeSet.contains(Locale.getDefault().getLanguage().toString())) {
localeSet.add(Locale.getDefault().toString());
}
return localeSet;
}
use of android.view.inputmethod.InputMethodSubtype in project android_packages_apps_Settings by DirtyUnicorns.
the class UserDictionaryList method getUserDictionaryLocalesSet.
@NonNull
public static TreeSet<String> getUserDictionaryLocalesSet(Context context) {
final Cursor cursor = context.getContentResolver().query(UserDictionary.Words.CONTENT_URI, new String[] { UserDictionary.Words.LOCALE }, null, null, null);
final TreeSet<String> localeSet = new TreeSet<>();
if (cursor == null) {
// The user dictionary service is not present or disabled. Return empty set.
return localeSet;
}
try {
if (cursor.moveToFirst()) {
final int columnIndex = cursor.getColumnIndex(UserDictionary.Words.LOCALE);
do {
final String locale = cursor.getString(columnIndex);
localeSet.add(null != locale ? locale : "");
} while (cursor.moveToNext());
}
} finally {
cursor.close();
}
// CAVEAT: Keep this for consistency of the implementation between Keyboard and Settings
// if (!UserDictionarySettings.IS_SHORTCUT_API_SUPPORTED) {
// // For ICS, we need to show "For all languages" in case that the keyboard locale
// // is different from the system locale
// localeSet.add("");
// }
final InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
final List<InputMethodInfo> imis = imm.getEnabledInputMethodList();
for (final InputMethodInfo imi : imis) {
final List<InputMethodSubtype> subtypes = imm.getEnabledInputMethodSubtypeList(imi, true);
for (InputMethodSubtype subtype : subtypes) {
final String locale = subtype.getLocale();
if (!TextUtils.isEmpty(locale)) {
localeSet.add(locale);
}
}
}
// correct to add it.
if (!localeSet.contains(Locale.getDefault().getLanguage().toString())) {
localeSet.add(Locale.getDefault().toString());
}
return localeSet;
}
use of android.view.inputmethod.InputMethodSubtype in project platform_packages_apps_Settings by BlissRoms.
the class PhysicalKeyboardFragment method onLoadFinishedInternal.
private void onLoadFinishedInternal(final int loaderId, @NonNull final List<Keyboards> keyboardsList) {
if (!mLoaderIDs.remove(loaderId)) {
// Already destroyed loader. Ignore.
return;
}
Collections.sort(keyboardsList);
final PreferenceScreen preferenceScreen = getPreferenceScreen();
preferenceScreen.removeAll();
for (Keyboards keyboards : keyboardsList) {
final PreferenceCategory category = new PreferenceCategory(getPrefContext(), null);
category.setTitle(keyboards.mDeviceInfo.mDeviceName);
category.setOrder(0);
preferenceScreen.addPreference(category);
for (Keyboards.KeyboardInfo info : keyboards.mKeyboardInfoList) {
mTempKeyboardInfoList.clear();
final InputMethodInfo imi = info.mImi;
final InputMethodSubtype imSubtype = info.mImSubtype;
if (imi != null) {
KeyboardInfoPreference pref = new KeyboardInfoPreference(getPrefContext(), info);
pref.setOnPreferenceClickListener(preference -> {
showKeyboardLayoutScreen(keyboards.mDeviceInfo.mDeviceIdentifier, imi, imSubtype);
return true;
});
mTempKeyboardInfoList.add(pref);
Collections.sort(mTempKeyboardInfoList);
}
for (KeyboardInfoPreference pref : mTempKeyboardInfoList) {
category.addPreference(pref);
}
}
}
mTempKeyboardInfoList.clear();
mKeyboardAssistanceCategory.setOrder(1);
preferenceScreen.addPreference(mKeyboardAssistanceCategory);
updateShowVirtualKeyboardSwitch();
}
Aggregations