Fixed searching w/o index

pull/194/head
M66B 4 years ago
parent 2ba307618c
commit d909c69245

@ -201,7 +201,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean fts = prefs.getBoolean("fts", false); boolean fts = prefs.getBoolean("fts", false);
boolean pro = ActivityBilling.isPro(context); boolean pro = ActivityBilling.isPro(context);
if (fts && pro && criteria.isQueryOnly()) { if (fts && pro && criteria.fts && criteria.query != null) {
if (state.ids == null) { if (state.ids == null) {
SQLiteDatabase sdb = FtsDbHelper.getInstance(context); SQLiteDatabase sdb = FtsDbHelper.getInstance(context);
state.ids = FtsDbHelper.match(sdb, account, folder, criteria); state.ids = FtsDbHelper.match(sdb, account, folder, criteria);
@ -641,6 +641,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
static class SearchCriteria implements Serializable { static class SearchCriteria implements Serializable {
String query; String query;
boolean fts = false;
boolean in_senders = true; boolean in_senders = true;
boolean in_recipients = true; boolean in_recipients = true;
boolean in_subject = true; boolean in_subject = true;
@ -663,26 +664,6 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
this.query = query; this.query = query;
} }
boolean isQueryOnly() {
return (!TextUtils.isEmpty(query) &&
in_senders &&
in_recipients &&
in_subject &&
in_keywords &&
in_message &&
isWithout());
}
boolean isWithout() {
return !(with_unseen ||
with_flagged ||
with_hidden ||
with_encrypted ||
with_attachments ||
with_types != null ||
with_size != null);
}
boolean isExpression() { boolean isExpression() {
if (this.query == null) if (this.query == null)
return false; return false;
@ -890,6 +871,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
@Override @Override
public String toString() { public String toString() {
return query + return query +
" fts=" + fts +
" senders=" + in_senders + " senders=" + in_senders +
" recipients=" + in_recipients + " recipients=" + in_recipients +
" subject=" + in_subject + " subject=" + in_subject +

@ -282,7 +282,8 @@ public class FragmentDialogSearch extends FragmentDialogBase {
else else
prefs.edit().putString("last_search", criteria.query).apply(); prefs.edit().putString("last_search", criteria.query).apply();
if (!cbSearchIndex.isChecked()) { criteria.fts = cbSearchIndex.isChecked();
if (!fts) {
criteria.in_senders = cbSenders.isChecked(); criteria.in_senders = cbSenders.isChecked();
criteria.in_recipients = cbRecipients.isChecked(); criteria.in_recipients = cbRecipients.isChecked();
criteria.in_subject = cbSubject.isChecked(); criteria.in_subject = cbSubject.isChecked();

Loading…
Cancel
Save