mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-23 10:20:25 +01:00
Allow single char searches for non-alphanumeric characters.
Fixes #13843
This commit is contained in:
@@ -36,7 +36,7 @@ public class ConversationSearchViewModel extends ViewModel {
|
||||
}
|
||||
|
||||
public void onQueryUpdated(@NonNull String query, long threadId, boolean forced) {
|
||||
if (firstSearch && query.length() < 2) {
|
||||
if (firstSearch && queryTooShort(query)) {
|
||||
result.postValue(new SearchResult(Collections.emptyList(), 0));
|
||||
return;
|
||||
}
|
||||
@@ -108,6 +108,21 @@ public class ConversationSearchViewModel extends ViewModel {
|
||||
});
|
||||
}
|
||||
|
||||
private static boolean queryTooShort(String query) {
|
||||
if (query.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (query.length() >= 2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
char onlyCharacter = query.charAt(0);
|
||||
boolean alphaNumeric = Character.isAlphabetic(onlyCharacter) || Character.isDigit(onlyCharacter);
|
||||
|
||||
return alphaNumeric;
|
||||
}
|
||||
|
||||
public static class SearchResult {
|
||||
|
||||
private final List<MessageResult> results;
|
||||
|
||||
Reference in New Issue
Block a user