diff options
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/eu/siacs/conversations/entities/Contact.java | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/Contact.java b/src/main/java/eu/siacs/conversations/entities/Contact.java index 99a74907..a451c142 100644 --- a/src/main/java/eu/siacs/conversations/entities/Contact.java +++ b/src/main/java/eu/siacs/conversations/entities/Contact.java @@ -145,11 +145,21 @@ public class Contact implements ListItem { } public boolean match(String needle) { - if (needle == null) { + if (needle == null || needle.isEmpty()) { return true; } - needle = needle.toLowerCase(); - return jid.toString().contains(needle) || getDisplayName().toLowerCase().contains(needle) || matchInTag(needle); + needle = needle.toLowerCase().trim(); + String[] parts = needle.split("\\s+"); + if (parts.length > 1) { + for(int i = 0; i < parts.length; ++i) { + if (!match(parts[i])) { + return false; + } + } + return true; + } else { + return jid.toString().contains(needle) || getDisplayName().toLowerCase().contains(needle) || matchInTag(needle); + } } private boolean matchInTag(String needle) { |