Shortcut server search

pull/209/head
M66B 2 years ago
parent 454def231d
commit 4d3e1e78ea

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

@ -1331,6 +1331,7 @@
<string name="title_no_folder">Folder does not exist</string>
<string name="title_no_format">The originally received message will be included</string>
<string name="title_no_search">Search on server is not available for this account</string>
<string name="title_complex_search">Select a folder for a complex search</string>
<string name="title_too_large">Message too large to completely reformat</string>
<string name="title_truncated">Message too large to display completely</string>
<string name="title_insufficient_memory">Message too large for the available memory (%1$d)</string>

Loading…
Cancel
Save