Merge "optimization of searching apps in Chinese" am: a0357329e0 am: f655c6e433 am: b634086d6c am: 27ae39420e am: 44150f8da4
Original change: https://android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/1425241 Change-Id: I1b270e7153c41789fb6a7eba88f29b0baa27780e
This commit is contained in:
@@ -60,6 +60,10 @@ public class DefaultAppSearchAlgorithm implements SearchAlgorithm {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (requestSimpleFuzzySearch(query)) {
|
||||
return title.toLowerCase().contains(query);
|
||||
}
|
||||
|
||||
int lastType;
|
||||
int thisType = Character.UNASSIGNED;
|
||||
int nextType = Character.getType(title.codePointAt(0));
|
||||
@@ -160,4 +164,17 @@ public class DefaultAppSearchAlgorithm implements SearchAlgorithm {
|
||||
return new StringMatcher();
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean requestSimpleFuzzySearch(String s) {
|
||||
for (int i = 0; i < s.length(); ) {
|
||||
int codepoint = s.codePointAt(i);
|
||||
i += Character.charCount(codepoint);
|
||||
switch (Character.UnicodeScript.of(codepoint)) {
|
||||
case HAN:
|
||||
//Character.UnicodeScript.HAN: use String.contains to match
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user