Shortcut server search

This commit is contained in:
M66B
2022-10-08 18:08:22 +02:00
parent 454def231d
commit 4d3e1e78ea
3 changed files with 27 additions and 0 deletions

View File

@@ -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<>();

View File

@@ -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);