Fix: Show string "Layout" if only single valid IME exists

From UX mocks, we need to show IME names in heading if there
are multiple IMEs. But in situation where we have multiple
IMEs but one of the IMEs doesn't have any valid subtype for PK,
it should work as if there is only a single IME.

Bug: 361528038
Test: manual
Flag: EXEMPT bugfix
Change-Id: Idd03a224b300df31b3265a5d58f79c0fc5d1535a
This commit is contained in:
Vaibhav Devmurari
2024-08-22 12:22:18 +00:00
parent 829b6cdbb1
commit 23e09a5d62

View File

@@ -169,6 +169,19 @@ public class NewKeyboardLayoutEnabledLocalesFragment extends DashboardFragment
preferenceScreen.removeAll(); preferenceScreen.removeAll();
List<InputMethodInfo> infoList = List<InputMethodInfo> infoList =
mImm.getEnabledInputMethodListAsUser(UserHandle.of(mUserId)); mImm.getEnabledInputMethodListAsUser(UserHandle.of(mUserId));
// Remove IMEs with no suitable ime subtypes
infoList.removeIf(imeInfo -> {
List<InputMethodSubtype> subtypes =
mImm.getEnabledInputMethodSubtypeListAsUser(imeInfo.getId(), true,
UserHandle.of(mUserId));
for (InputMethodSubtype subtype : subtypes) {
if (subtype.isSuitableForPhysicalKeyboardLayoutMapping()) {
return false;
}
}
return true;
});
Collections.sort(infoList, new Comparator<InputMethodInfo>() { Collections.sort(infoList, new Comparator<InputMethodInfo>() {
public int compare(InputMethodInfo o1, InputMethodInfo o2) { public int compare(InputMethodInfo o1, InputMethodInfo o2) {
String s1 = o1.loadLabel(mContext.getPackageManager()).toString(); String s1 = o1.loadLabel(mContext.getPackageManager()).toString();