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

This commit is contained in:
TreeHugger Robot
2021-06-03 15:10:17 +00:00
committed by Android (Google) Code Review
2 changed files with 14 additions and 4 deletions

View File

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

View File

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