Merge "Teach IMMS#shouldShowImeSwitcherLocked() about shouldShowInInputMethodPicker attr" into sc-dev am: 8968116543

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14811983

Change-Id: Icbf518e72b691e554ef4456c0c97ec630956b7d8
This commit is contained in:
TreeHugger Robot
2021-06-03 15:13:46 +00:00
committed by Automerger Merge Worker
2 changed files with 14 additions and 4 deletions

View File

@@ -2762,7 +2762,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
return false; return false;
} }
List<InputMethodInfo> imis = mSettings.getEnabledInputMethodListLocked(); List<InputMethodInfo> imis = mSettings.getEnabledInputMethodListWithFilterLocked(
InputMethodInfo::shouldShowInInputMethodPicker);
final int N = imis.size(); final int N = imis.size();
if (N > 2) return true; if (N > 2) return true;
if (N < 1) return false; if (N < 1) return false;

View File

@@ -54,6 +54,7 @@ import java.util.Arrays;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.function.Predicate;
/** /**
* This class provides random static utility methods for {@link InputMethodManagerService} and its * This class provides random static utility methods for {@link InputMethodManagerService} and its
@@ -946,8 +947,14 @@ final class InputMethodUtils {
} }
ArrayList<InputMethodInfo> getEnabledInputMethodListLocked() { ArrayList<InputMethodInfo> getEnabledInputMethodListLocked() {
return getEnabledInputMethodListWithFilterLocked(null /* matchingCondition */);
}
@NonNull
ArrayList<InputMethodInfo> getEnabledInputMethodListWithFilterLocked(
@Nullable Predicate<InputMethodInfo> matchingCondition) {
return createEnabledInputMethodListLocked( return createEnabledInputMethodListLocked(
getEnabledInputMethodsAndSubtypeListLocked()); getEnabledInputMethodsAndSubtypeListLocked(), matchingCondition);
} }
List<InputMethodSubtype> getEnabledInputMethodSubtypeListLocked( List<InputMethodSubtype> getEnabledInputMethodSubtypeListLocked(
@@ -1036,11 +1043,13 @@ final class InputMethodUtils {
} }
private ArrayList<InputMethodInfo> createEnabledInputMethodListLocked( private ArrayList<InputMethodInfo> createEnabledInputMethodListLocked(
List<Pair<String, ArrayList<String>>> imsList) { List<Pair<String, ArrayList<String>>> imsList,
Predicate<InputMethodInfo> matchingCondition) {
final ArrayList<InputMethodInfo> res = new ArrayList<>(); final ArrayList<InputMethodInfo> res = new ArrayList<>();
for (Pair<String, ArrayList<String>> ims: imsList) { for (Pair<String, ArrayList<String>> ims: imsList) {
InputMethodInfo info = mMethodMap.get(ims.first); InputMethodInfo info = mMethodMap.get(ims.first);
if (info != null && !info.isVrOnly()) { if (info != null && !info.isVrOnly()
&& (matchingCondition == null || matchingCondition.test(info))) {
res.add(info); res.add(info);
} }
} }