mirror of
https://github.com/M66B/FairEmail.git
synced 2024-12-29 11:15:51 +00:00
Limit search suggestions to current account/folder
This commit is contained in:
parent
a0b735c416
commit
7094edd749
2 changed files with 30 additions and 20 deletions
|
@ -475,17 +475,24 @@ public interface DaoMessage {
|
|||
List<EntityMessage> getSnoozed(Long folder);
|
||||
|
||||
@Query("SELECT id AS _id, subject AS suggestion FROM message" +
|
||||
" WHERE subject LIKE :query" +
|
||||
" WHERE (:account IS NULL OR message.account = :account)" +
|
||||
" AND (:folder IS NULL OR message.folder = :folder)" +
|
||||
" AND subject LIKE :query" +
|
||||
" AND NOT message.ui_hide" +
|
||||
" GROUP BY subject" +
|
||||
|
||||
" UNION" +
|
||||
|
||||
" SELECT id AS _id, sender AS suggestion FROM message" +
|
||||
" WHERE sender LIKE :query" +
|
||||
" WHERE (:account IS NULL OR message.account = :account)" +
|
||||
" AND (:folder IS NULL OR message.folder = :folder)" +
|
||||
" AND sender LIKE :query" +
|
||||
" AND NOT message.ui_hide" +
|
||||
" GROUP BY sender" +
|
||||
|
||||
" ORDER BY sender, subject" +
|
||||
" LIMIT 5")
|
||||
Cursor getSuggestions(String query);
|
||||
Cursor getSuggestions(Long account, Long folder, String query);
|
||||
|
||||
@Query("SELECT language FROM message" +
|
||||
" WHERE (:account IS NULL OR message.account = :account)" +
|
||||
|
|
|
@ -37,6 +37,22 @@ public class FragmentDialogSearch extends FragmentDialogBase {
|
|||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
|
||||
final long account = getArguments().getLong("account", -1);
|
||||
final long folder = getArguments().getLong("folder", -1);
|
||||
|
||||
boolean pro = ActivityBilling.isPro(getContext());
|
||||
|
||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
boolean fts = prefs.getBoolean("fts", false);
|
||||
boolean filter_seen = prefs.getBoolean("filter_seen", false);
|
||||
boolean filter_unflagged = prefs.getBoolean("filter_unflagged", false);
|
||||
boolean last_search_senders = prefs.getBoolean("last_search_senders", true);
|
||||
boolean last_search_recipients = prefs.getBoolean("last_search_recipients", true);
|
||||
boolean last_search_subject = prefs.getBoolean("last_search_subject", true);
|
||||
boolean last_search_keywords = prefs.getBoolean("last_search_keywords", false);
|
||||
boolean last_search_message = prefs.getBoolean("last_search_message", true);
|
||||
String last_search = prefs.getString("last_search", null);
|
||||
|
||||
View dview = LayoutInflater.from(getContext()).inflate(R.layout.dialog_search, null);
|
||||
|
||||
final AutoCompleteTextView etQuery = dview.findViewById(R.id.etQuery);
|
||||
|
@ -60,19 +76,6 @@ public class FragmentDialogSearch extends FragmentDialogBase {
|
|||
final TextView tvAfter = dview.findViewById(R.id.tvAfter);
|
||||
final Group grpMore = dview.findViewById(R.id.grpMore);
|
||||
|
||||
boolean pro = ActivityBilling.isPro(getContext());
|
||||
|
||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
boolean fts = prefs.getBoolean("fts", false);
|
||||
boolean filter_seen = prefs.getBoolean("filter_seen", false);
|
||||
boolean filter_unflagged = prefs.getBoolean("filter_unflagged", false);
|
||||
boolean last_search_senders = prefs.getBoolean("last_search_senders", true);
|
||||
boolean last_search_recipients = prefs.getBoolean("last_search_recipients", true);
|
||||
boolean last_search_subject = prefs.getBoolean("last_search_subject", true);
|
||||
boolean last_search_keywords = prefs.getBoolean("last_search_keywords", false);
|
||||
boolean last_search_message = prefs.getBoolean("last_search_message", true);
|
||||
String last_search = prefs.getString("last_search", null);
|
||||
|
||||
final InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
ibInfo.setOnClickListener(new View.OnClickListener() {
|
||||
|
@ -102,7 +105,10 @@ public class FragmentDialogSearch extends FragmentDialogBase {
|
|||
|
||||
String query = "%" + typed + "%";
|
||||
DB db = DB.getInstance(getContext());
|
||||
return db.message().getSuggestions("%" + query + "%");
|
||||
return db.message().getSuggestions(
|
||||
account < 0 ? null : account,
|
||||
folder < 0 ? null : folder,
|
||||
"%" + query + "%");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -227,9 +233,6 @@ public class FragmentDialogSearch extends FragmentDialogBase {
|
|||
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
long account = getArguments().getLong("account", -1);
|
||||
long folder = getArguments().getLong("folder", -1);
|
||||
|
||||
BoundaryCallbackMessages.SearchCriteria criteria = new BoundaryCallbackMessages.SearchCriteria();
|
||||
|
||||
criteria.query = etQuery.getText().toString();
|
||||
|
|
Loading…
Reference in a new issue