use of android.view.inputmethod.InputMethodSubtype in project android_frameworks_base by AOSPA.
the class InputMethodManagerService method setSelectedInputMethodAndSubtypeLocked.
private void setSelectedInputMethodAndSubtypeLocked(InputMethodInfo imi, int subtypeId, boolean setSubtypeOnly) {
// Update the history of InputMethod and Subtype
mSettings.saveCurrentInputMethodAndSubtypeToHistory(mCurMethodId, mCurrentSubtype);
mCurUserActionNotificationSequenceNumber = Math.max(mCurUserActionNotificationSequenceNumber + 1, 1);
if (DEBUG) {
Slog.d(TAG, "Bump mCurUserActionNotificationSequenceNumber:" + mCurUserActionNotificationSequenceNumber);
}
if (mCurClient != null && mCurClient.client != null) {
executeOrSendMessage(mCurClient.client, mCaller.obtainMessageIO(MSG_SET_USER_ACTION_NOTIFICATION_SEQUENCE_NUMBER, mCurUserActionNotificationSequenceNumber, mCurClient));
}
// Set Subtype here
if (imi == null || subtypeId < 0) {
mSettings.putSelectedSubtype(NOT_A_SUBTYPE_ID);
mCurrentSubtype = null;
} else {
if (subtypeId < imi.getSubtypeCount()) {
InputMethodSubtype subtype = imi.getSubtypeAt(subtypeId);
mSettings.putSelectedSubtype(subtype.hashCode());
mCurrentSubtype = subtype;
} else {
mSettings.putSelectedSubtype(NOT_A_SUBTYPE_ID);
// If the subtype is not specified, choose the most applicable one
mCurrentSubtype = getCurrentInputMethodSubtypeLocked();
}
}
if (!setSubtypeOnly) {
// Set InputMethod here
mSettings.putSelectedInputMethod(imi != null ? imi.getId() : "");
}
}
use of android.view.inputmethod.InputMethodSubtype in project android_frameworks_base by AOSPA.
the class InputMethodManagerService method getShortcutInputMethodsAndSubtypes.
// TODO: We should change the return type from List to List<Parcelable>
@SuppressWarnings("rawtypes")
@Override
public List getShortcutInputMethodsAndSubtypes() {
synchronized (mMethodMap) {
ArrayList<Object> ret = new ArrayList<>();
if (mShortcutInputMethodsAndSubtypes.size() == 0) {
// If there are no selected shortcut subtypes, the framework will try to find
// the most applicable subtype from all subtypes whose mode is
// SUBTYPE_MODE_VOICE. This is an exceptional case, so we will hardcode the mode.
Pair<InputMethodInfo, InputMethodSubtype> info = findLastResortApplicableShortcutInputMethodAndSubtypeLocked(InputMethodUtils.SUBTYPE_MODE_VOICE);
if (info != null) {
ret.add(info.first);
ret.add(info.second);
}
return ret;
}
for (InputMethodInfo imi : mShortcutInputMethodsAndSubtypes.keySet()) {
ret.add(imi);
for (InputMethodSubtype subtype : mShortcutInputMethodsAndSubtypes.get(imi)) {
ret.add(subtype);
}
}
return ret;
}
}
use of android.view.inputmethod.InputMethodSubtype in project android_packages_apps_Settings by LineageOS.
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 omnirom.
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 omnirom.
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