mirror of https://github.com/M66B/FairEmail.git
Limit search suggestions to current account/folder
This commit is contained in:
parent
a0b735c416
commit
7094edd749
|
@ -475,17 +475,24 @@ public interface DaoMessage {
|
||||||
List<EntityMessage> getSnoozed(Long folder);
|
List<EntityMessage> getSnoozed(Long folder);
|
||||||
|
|
||||||
@Query("SELECT id AS _id, subject AS suggestion FROM message" +
|
@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" +
|
" AND NOT message.ui_hide" +
|
||||||
" GROUP BY subject" +
|
" GROUP BY subject" +
|
||||||
|
|
||||||
" UNION" +
|
" UNION" +
|
||||||
|
|
||||||
" SELECT id AS _id, sender AS suggestion FROM message" +
|
" 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" +
|
" AND NOT message.ui_hide" +
|
||||||
" GROUP BY sender" +
|
" GROUP BY sender" +
|
||||||
|
|
||||||
" ORDER BY sender, subject" +
|
" ORDER BY sender, subject" +
|
||||||
" LIMIT 5")
|
" LIMIT 5")
|
||||||
Cursor getSuggestions(String query);
|
Cursor getSuggestions(Long account, Long folder, String query);
|
||||||
|
|
||||||
@Query("SELECT language FROM message" +
|
@Query("SELECT language FROM message" +
|
||||||
" WHERE (:account IS NULL OR message.account = :account)" +
|
" WHERE (:account IS NULL OR message.account = :account)" +
|
||||||
|
|
|
@ -37,6 +37,22 @@ public class FragmentDialogSearch extends FragmentDialogBase {
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
|
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);
|
View dview = LayoutInflater.from(getContext()).inflate(R.layout.dialog_search, null);
|
||||||
|
|
||||||
final AutoCompleteTextView etQuery = dview.findViewById(R.id.etQuery);
|
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 TextView tvAfter = dview.findViewById(R.id.tvAfter);
|
||||||
final Group grpMore = dview.findViewById(R.id.grpMore);
|
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);
|
final InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
|
|
||||||
ibInfo.setOnClickListener(new View.OnClickListener() {
|
ibInfo.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@ -102,7 +105,10 @@ public class FragmentDialogSearch extends FragmentDialogBase {
|
||||||
|
|
||||||
String query = "%" + typed + "%";
|
String query = "%" + typed + "%";
|
||||||
DB db = DB.getInstance(getContext());
|
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() {
|
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
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();
|
BoundaryCallbackMessages.SearchCriteria criteria = new BoundaryCallbackMessages.SearchCriteria();
|
||||||
|
|
||||||
criteria.query = etQuery.getText().toString();
|
criteria.query = etQuery.getText().toString();
|
||||||
|
|
Loading…
Reference in New Issue