From 3ee1fe454be5f1e099f9a5c24d91a53df4808c22 Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 26 Feb 2021 13:44:56 +0100 Subject: [PATCH] Use FTS if enable to search for email addresses --- .../java/eu/faircode/email/ActivityView.java | 22 +++++++++++++------ .../eu/faircode/email/AdapterMessage.java | 2 +- .../eu/faircode/email/FragmentMessages.java | 8 ------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ActivityView.java b/app/src/main/java/eu/faircode/email/ActivityView.java index ea24bc4b9b..0d0382cddb 100644 --- a/app/src/main/java/eu/faircode/email/ActivityView.java +++ b/app/src/main/java/eu/faircode/email/ActivityView.java @@ -128,7 +128,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB static final String ACTION_VIEW_FOLDERS = BuildConfig.APPLICATION_ID + ".VIEW_FOLDERS"; static final String ACTION_VIEW_MESSAGES = BuildConfig.APPLICATION_ID + ".VIEW_MESSAGES"; - static final String ACTION_SEARCH = BuildConfig.APPLICATION_ID + ".SEARCH"; + static final String ACTION_SEARCH_ADDRESS = BuildConfig.APPLICATION_ID + ".SEARCH_ADDRESS"; static final String ACTION_VIEW_THREAD = BuildConfig.APPLICATION_ID + ".VIEW_THREAD"; static final String ACTION_EDIT_FOLDER = BuildConfig.APPLICATION_ID + ".EDIT_FOLDER"; static final String ACTION_EDIT_ANSWERS = BuildConfig.APPLICATION_ID + ".EDIT_ANSWERS"; @@ -639,7 +639,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB IntentFilter iff = new IntentFilter(); iff.addAction(ACTION_VIEW_FOLDERS); iff.addAction(ACTION_VIEW_MESSAGES); - iff.addAction(ACTION_SEARCH); + iff.addAction(ACTION_SEARCH_ADDRESS); iff.addAction(ACTION_VIEW_THREAD); iff.addAction(ACTION_EDIT_FOLDER); iff.addAction(ACTION_EDIT_ANSWERS); @@ -1096,7 +1096,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB searching = true; FragmentMessages.search( ActivityView.this, ActivityView.this, getSupportFragmentManager(), - -1, -1, false, search); + -1, -1, false, new BoundaryCallbackMessages.SearchCriteria(search)); } intent.removeExtra(Intent.EXTRA_PROCESS_TEXT); @@ -1291,8 +1291,8 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB onViewFolders(intent); else if (ACTION_VIEW_MESSAGES.equals(action)) onViewMessages(intent); - else if (ACTION_SEARCH.equals(action)) - onSearchMessages(intent); + else if (ACTION_SEARCH_ADDRESS.equals(action)) + onSearchAddress(intent); else if (ACTION_VIEW_THREAD.equals(action)) onViewThread(intent); else if (ACTION_EDIT_FOLDER.equals(action)) @@ -1331,13 +1331,21 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB fragmentTransaction.commit(); } - private void onSearchMessages(Intent intent) { + private void onSearchAddress(Intent intent) { long account = intent.getLongExtra("account", -1); long folder = intent.getLongExtra("folder", -1); String query = intent.getStringExtra("query"); + + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); + boolean fts = prefs.getBoolean("fts", false); + + BoundaryCallbackMessages.SearchCriteria criteria = new BoundaryCallbackMessages.SearchCriteria(); + criteria.query = query; + criteria.fts = fts; + FragmentMessages.search( this, this, getSupportFragmentManager(), - account, folder, false, query); + account, folder, false, criteria); } private void onViewThread(Intent intent) { diff --git a/app/src/main/java/eu/faircode/email/AdapterMessage.java b/app/src/main/java/eu/faircode/email/AdapterMessage.java index 7a2458a565..d739a9edf9 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMessage.java +++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java @@ -3408,7 +3408,7 @@ public class AdapterMessage extends RecyclerView.Adapter