mirror of
https://github.com/M66B/FairEmail.git
synced 2026-03-29 13:24:52 +02:00
Shortcut server search
This commit is contained in:
@@ -886,6 +886,23 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
|
||||
|
||||
private static final String FROM = "from:";
|
||||
|
||||
boolean onServer() {
|
||||
if (query == null)
|
||||
return false;
|
||||
|
||||
for (String w : query.trim().split("\\s+"))
|
||||
if (w.length() > 1 && w.startsWith("+"))
|
||||
return true;
|
||||
else if (w.length() > 1 && w.startsWith("-"))
|
||||
return true;
|
||||
else if (w.length() > 1 && w.startsWith("?"))
|
||||
return true;
|
||||
else if (w.length() > FROM.length() && w.startsWith(FROM))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
SearchTerm getTerms(boolean utf8, Flags flags, String[] keywords) {
|
||||
List<SearchTerm> or = new ArrayList<>();
|
||||
List<SearchTerm> and = new ArrayList<>();
|
||||
|
||||
@@ -10015,6 +10015,15 @@ public class FragmentMessages extends FragmentBase
|
||||
static void search(
|
||||
final Context context, final LifecycleOwner owner, final FragmentManager manager,
|
||||
long account, long folder, boolean server, BoundaryCallbackMessages.SearchCriteria criteria) {
|
||||
if (criteria.onServer()) {
|
||||
if (account > 0 && folder > 0)
|
||||
server = true;
|
||||
else {
|
||||
ToastEx.makeText(context, R.string.title_complex_search, Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (owner.getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
|
||||
manager.popBackStack("search", FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user