Refactoring

This commit is contained in:
M66B 2020-04-10 12:26:23 +02:00
parent 5548691e4a
commit 5a9dcd9f87
4 changed files with 19 additions and 17 deletions

View File

@ -231,8 +231,8 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
criteria.with_hidden,
criteria.with_encrypted,
criteria.with_attachments,
criteria.from,
criteria.to,
criteria.after,
criteria.before,
SEARCH_LIMIT, state.offset);
Log.i("Boundary device folder=" + folder +
" criteria=" + criteria +
@ -426,10 +426,10 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
state.ifolder.getPermanentFlags().contains(Flags.Flag.FLAGGED))
and.add(new FlagTerm(new Flags(Flags.Flag.FLAGGED), true));
if (criteria.from != null)
and.add(new ReceivedDateTerm(ComparisonTerm.GT, new Date(criteria.from)));
if (criteria.to != null)
and.add(new ReceivedDateTerm(ComparisonTerm.LT, new Date(criteria.to)));
if (criteria.after != null)
and.add(new ReceivedDateTerm(ComparisonTerm.GT, new Date(criteria.after)));
if (criteria.before != null)
and.add(new ReceivedDateTerm(ComparisonTerm.LT, new Date(criteria.before)));
SearchTerm term = null;
@ -625,8 +625,8 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
boolean with_hidden;
boolean with_encrypted;
boolean with_attachments;
Long from = null;
Long to = null;
Long after = null;
Long before = null;
SearchCriteria() {
}
@ -685,8 +685,8 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
this.with_hidden == other.with_hidden &&
this.with_encrypted == other.with_encrypted &&
this.with_attachments == other.with_attachments &&
Objects.equals(this.from, other.from) &&
Objects.equals(this.to, other.to));
Objects.equals(this.after, other.after) &&
Objects.equals(this.before, other.before));
} else
return false;
}

View File

@ -296,14 +296,14 @@ public interface DaoMessage {
" AND (NOT :hidden OR NOT ui_snoozed IS NULL)" +
" AND (NOT :encrypted OR ui_encrypt > 0)" +
" AND (NOT :attachments OR attachments > 0)" +
" AND (:from IS NULL OR received > :from)" +
" AND (:to IS NULL OR received < :to)" +
" AND (:after IS NULL OR received > :after)" +
" AND (:before IS NULL OR received < :before)" +
" ORDER BY received DESC" +
" LIMIT :limit OFFSET :offset")
List<TupleMatch> matchMessages(
Long account, Long folder, String find,
boolean unseen, boolean flagged, boolean hidden, boolean encrypted, boolean attachments,
Long from, Long to,
Long after, Long before,
int limit, int offset);
@Query("SELECT id" +

View File

@ -140,10 +140,10 @@ public class FtsDbHelper extends SQLiteOpenHelper {
select += "account = " + account + " AND ";
if (folder != null)
select += "folder = " + folder + " AND ";
if (criteria.from != null)
select += "time > " + criteria.from + " AND ";
if (criteria.to != null)
select += "time < " + criteria.to + " AND ";
if (criteria.after != null)
select += "time > " + criteria.after + " AND ";
if (criteria.before != null)
select += "time < " + criteria.before + " AND ";
Log.i("FTS select=" + select + " search=" + search);
List<Long> result = new ArrayList<>();

View File

@ -917,6 +917,8 @@
<string name="title_search_with_hidden">Hidden (on device only)</string>
<string name="title_search_with_encrypted">Encrypted (on device only)</string>
<string name="title_search_with_attachments">With attachments (on device only)</string>
<string name="title_search_with_before">Before</string>
<string name="title_search_with_after">After</string>
<string name="title_search_flag_unseen">unread</string>
<string name="title_search_flag_flagged">starred</string>
<string name="title_search_flag_hidden">hidden</string>