Added search to: and keyword:

pull/209/head
M66B 2 years ago
parent f62b8c74c7
commit 46163f1717

@ -1146,6 +1146,16 @@ This will result in searching like this:
("apple" AND "banana" AND NOT "cherry") OR "nuts" ("apple" AND "banana" AND NOT "cherry") OR "nuts"
``` ```
Since version 1.1979 it is possible to use these prefixes as a search expression:
```
from:<email address>
to:<email address>
keyword:<keyword>
```
There should be no space between the prefix and the search term, which will be applied as an AND-condition.
Search expressions can be used for searching on the email server only, and not for searching on the device. Search expressions can be used for searching on the email server only, and not for searching on the device.
Since version 1.1733 it is possible to save searches, which means that a named entry in the navigation menu will be created to repeat the same search later. Since version 1.1733 it is possible to save searches, which means that a named entry in the navigation menu will be created to repeat the same search later.

@ -885,6 +885,8 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
Long before = null; Long before = null;
private static final String FROM = "from:"; private static final String FROM = "from:";
private static final String TO = "to:";
private static final String KEYWORD = "keyword:";
boolean onServer() { boolean onServer() {
if (query == null) if (query == null)
@ -899,6 +901,10 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
return true; return true;
else if (w.length() > FROM.length() && w.startsWith(FROM)) else if (w.length() > FROM.length() && w.startsWith(FROM))
return true; return true;
else if (w.length() > TO.length() && w.startsWith(TO))
return true;
else if (w.length() > KEYWORD.length() && w.startsWith(KEYWORD))
return true;
return false; return false;
} }
@ -923,7 +929,9 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
List<String> plus = new ArrayList<>(); List<String> plus = new ArrayList<>();
List<String> minus = new ArrayList<>(); List<String> minus = new ArrayList<>();
List<String> opt = new ArrayList<>(); List<String> opt = new ArrayList<>();
List<String> from = new ArrayList<>(); List<String> andFrom = new ArrayList<>();
List<String> andTo = new ArrayList<>();
List<String> andKeyword = new ArrayList<>();
StringBuilder all = new StringBuilder(); StringBuilder all = new StringBuilder();
for (String w : search.trim().split("\\s+")) { for (String w : search.trim().split("\\s+")) {
if (all.length() > 0) if (all.length() > 0)
@ -938,15 +946,20 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
} else if (w.length() > 1 && w.startsWith("?")) { } else if (w.length() > 1 && w.startsWith("?")) {
opt.add(w.substring(1)); opt.add(w.substring(1));
all.append(w.substring(1)); all.append(w.substring(1));
} else if (w.length() > FROM.length() && w.startsWith(FROM)) { } else if (w.length() > FROM.length() && w.startsWith(FROM))
from.add(w.substring(FROM.length())); andFrom.add(w.substring(FROM.length()));
} else { else if (w.length() > TO.length() && w.startsWith(TO))
andTo.add(w.substring(TO.length()));
else if (w.length() > KEYWORD.length() && w.startsWith(KEYWORD))
andKeyword.add(w.substring(KEYWORD.length()));
else {
word.add(w); word.add(w);
all.append(w); all.append(w);
} }
} }
if (plus.size() + minus.size() + opt.size() + from.size() > 0) if (plus.size() + minus.size() + opt.size() +
andFrom.size() + andTo.size() + andKeyword.size() > 0)
search = all.toString(); search = all.toString();
// Yahoo! does not support keyword search, but uses the flags $Forwarded $Junk $NotJunk // Yahoo! does not support keyword search, but uses the flags $Forwarded $Junk $NotJunk
@ -957,21 +970,26 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
break; break;
} }
if (from.size() > 0) { if (andFrom.size() > 0) {
for (String term : from) for (String term : andFrom)
and.add(new FromStringTerm(term)); and.add(new FromStringTerm(term));
} else { } else {
if (in_senders) if (in_senders && !TextUtils.isEmpty(search))
or.add(new FromStringTerm(search)); or.add(new FromStringTerm(search));
} }
if (in_recipients) { if (andTo.size() > 0) {
or.add(new RecipientStringTerm(Message.RecipientType.TO, search)); for (String term : andTo)
or.add(new RecipientStringTerm(Message.RecipientType.CC, search)); and.add(new RecipientStringTerm(Message.RecipientType.TO, term));
or.add(new RecipientStringTerm(Message.RecipientType.BCC, search)); } else {
if (in_recipients && !TextUtils.isEmpty(search)) {
or.add(new RecipientStringTerm(Message.RecipientType.TO, search));
or.add(new RecipientStringTerm(Message.RecipientType.CC, search));
or.add(new RecipientStringTerm(Message.RecipientType.BCC, search));
}
} }
if (in_subject) if (in_subject && !TextUtils.isEmpty(search))
if (plus.size() + minus.size() + opt.size() == 0) if (plus.size() + minus.size() + opt.size() == 0)
or.add(new SubjectTerm(search)); or.add(new SubjectTerm(search));
else else
@ -982,15 +1000,21 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
or.add(new SubjectTerm(search)); or.add(new SubjectTerm(search));
} }
if (in_keywords && hasKeywords) { if (hasKeywords)
String keyword = MessageHelper.sanitizeKeyword(search); if (andKeyword.size() > 0) {
if (TextUtils.isEmpty(keyword)) for (String term : andKeyword)
Log.w("Keyword empty=" + search); and.add(new FlagTerm(new Flags(term), true));
else } else {
or.add(new FlagTerm(new Flags(keyword), true)); if (in_keywords && !TextUtils.isEmpty(search)) {
} String keyword = MessageHelper.sanitizeKeyword(search);
if (TextUtils.isEmpty(keyword))
Log.w("Keyword empty=" + search);
else
or.add(new FlagTerm(new Flags(keyword), true));
}
}
if (in_message) if (in_message && !TextUtils.isEmpty(search))
if (plus.size() + minus.size() + opt.size() == 0) if (plus.size() + minus.size() + opt.size() == 0)
or.add(new BodyTerm(search)); or.add(new BodyTerm(search));
else else

Loading…
Cancel
Save