From 23e09a5d62be1b5b77240e8546dbe66a8245e611 Mon Sep 17 00:00:00 2001 From: Vaibhav Devmurari Date: Thu, 22 Aug 2024 12:22:18 +0000 Subject: [PATCH] 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 --- .../NewKeyboardLayoutEnabledLocalesFragment.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/com/android/settings/inputmethod/NewKeyboardLayoutEnabledLocalesFragment.java b/src/com/android/settings/inputmethod/NewKeyboardLayoutEnabledLocalesFragment.java index 849ffb46855..7a5885756dd 100644 --- a/src/com/android/settings/inputmethod/NewKeyboardLayoutEnabledLocalesFragment.java +++ b/src/com/android/settings/inputmethod/NewKeyboardLayoutEnabledLocalesFragment.java @@ -169,6 +169,19 @@ public class NewKeyboardLayoutEnabledLocalesFragment extends DashboardFragment preferenceScreen.removeAll(); List infoList = mImm.getEnabledInputMethodListAsUser(UserHandle.of(mUserId)); + + // Remove IMEs with no suitable ime subtypes + infoList.removeIf(imeInfo -> { + List 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() { public int compare(InputMethodInfo o1, InputMethodInfo o2) { String s1 = o1.loadLabel(mContext.getPackageManager()).toString();