diff options
author | iNPUTmice <daniel@gultsch.de> | 2014-11-17 17:24:33 +0100 |
---|---|---|
committer | iNPUTmice <daniel@gultsch.de> | 2014-11-17 17:24:33 +0100 |
commit | 252c7e68d6e0d0a43a310ff0f466e123dcbc5a90 (patch) | |
tree | 65ef4cc86b33a5c425e4e83b0981659a98ef4b74 /src | |
parent | e30e84c81909066b5adcaa0ca135049ce45b1356 (diff) |
split search keywords by whitespaces and imply AND operatior
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/eu/siacs/conversations/entities/Contact.java | 12 |
1 files changed, 11 insertions, 1 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..0b6c900a 100644 --- a/src/main/java/eu/siacs/conversations/entities/Contact.java +++ b/src/main/java/eu/siacs/conversations/entities/Contact.java @@ -149,7 +149,17 @@ public class Contact implements ListItem { return true; } needle = needle.toLowerCase(); - return jid.toString().contains(needle) || getDisplayName().toLowerCase().contains(needle) || matchInTag(needle); + 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) { |