From 4d3e1e78ea94fd148931378e50a5136accddd16d Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 8 Oct 2022 18:08:22 +0200 Subject: [PATCH] Shortcut server search --- .../email/BoundaryCallbackMessages.java | 17 +++++++++++++++++ .../eu/faircode/email/FragmentMessages.java | 9 +++++++++ app/src/main/res/values/strings.xml | 1 + 3 files changed, 27 insertions(+) diff --git a/app/src/main/java/eu/faircode/email/BoundaryCallbackMessages.java b/app/src/main/java/eu/faircode/email/BoundaryCallbackMessages.java index bf172e778c..00cd37434a 100644 --- a/app/src/main/java/eu/faircode/email/BoundaryCallbackMessages.java +++ b/app/src/main/java/eu/faircode/email/BoundaryCallbackMessages.java @@ -886,6 +886,23 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback 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 or = new ArrayList<>(); List and = new ArrayList<>(); diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index 3c51ced26e..d9508e8d64 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -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); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0f1d57f2d5..022eb09a3f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1331,6 +1331,7 @@ Folder does not exist The originally received message will be included Search on server is not available for this account + Select a folder for a complex search Message too large to completely reformat Message too large to display completely Message too large for the available memory (%1$d)