mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-11 19:43:11 +02:00
Added search by size
This commit is contained in:
@@ -71,6 +71,7 @@ import javax.mail.search.OrTerm;
|
||||
import javax.mail.search.ReceivedDateTerm;
|
||||
import javax.mail.search.RecipientStringTerm;
|
||||
import javax.mail.search.SearchTerm;
|
||||
import javax.mail.search.SizeTerm;
|
||||
import javax.mail.search.SubjectTerm;
|
||||
|
||||
import io.requery.android.database.sqlite.SQLiteDatabase;
|
||||
@@ -239,6 +240,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
|
||||
criteria.with_hidden,
|
||||
criteria.with_encrypted,
|
||||
criteria.with_attachments,
|
||||
criteria.with_size,
|
||||
criteria.after,
|
||||
criteria.before,
|
||||
SEARCH_LIMIT, state.offset);
|
||||
@@ -617,6 +619,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
|
||||
boolean with_hidden;
|
||||
boolean with_encrypted;
|
||||
boolean with_attachments;
|
||||
Integer with_size = null;
|
||||
Long after = null;
|
||||
Long before = null;
|
||||
|
||||
@@ -642,7 +645,8 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
|
||||
with_flagged ||
|
||||
with_hidden ||
|
||||
with_encrypted ||
|
||||
with_attachments);
|
||||
with_attachments ||
|
||||
with_size != null);
|
||||
}
|
||||
|
||||
SearchTerm getTerms(boolean utf8, Flags flags, String[] keywords) {
|
||||
@@ -685,6 +689,9 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
|
||||
if (with_flagged && flags.contains(Flags.Flag.FLAGGED))
|
||||
and.add(new FlagTerm(new Flags(Flags.Flag.FLAGGED), true));
|
||||
|
||||
if (with_size != null)
|
||||
and.add(new SizeTerm(ComparisonTerm.GT, with_size));
|
||||
|
||||
if (after != null)
|
||||
and.add(new ReceivedDateTerm(ComparisonTerm.GE, new Date(after)));
|
||||
if (before != null)
|
||||
@@ -716,6 +723,9 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
|
||||
flags.add(context.getString(R.string.title_search_flag_encrypted));
|
||||
if (with_attachments)
|
||||
flags.add(context.getString(R.string.title_search_flag_attachments));
|
||||
if (with_size != null)
|
||||
flags.add(context.getString(R.string.title_search_flag_size,
|
||||
Helper.humanReadableByteCount(with_size, true)));
|
||||
return (query == null ? "" : query)
|
||||
+ (flags.size() > 0 ? " +" : "")
|
||||
+ TextUtils.join(",", flags);
|
||||
@@ -736,6 +746,7 @@ 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.with_size, other.with_size) &&
|
||||
Objects.equals(this.after, other.after) &&
|
||||
Objects.equals(this.before, other.before));
|
||||
} else
|
||||
@@ -756,6 +767,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
|
||||
" hidden=" + with_hidden +
|
||||
" encrypted=" + with_encrypted +
|
||||
" attachments=" + with_attachments +
|
||||
" size=" + with_size +
|
||||
" after=" + (after == null ? "" : new Date(after)) +
|
||||
" before=" + (before == null ? "" : new Date(before));
|
||||
}
|
||||
|
||||
@@ -320,6 +320,7 @@ 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 (NOT :size OR total > :size)" +
|
||||
" AND (:after IS NULL OR received > :after)" +
|
||||
" AND (:before IS NULL OR received < :before)" +
|
||||
" ORDER BY received DESC" +
|
||||
@@ -328,6 +329,7 @@ public interface DaoMessage {
|
||||
Long account, Long folder, String find,
|
||||
boolean senders, boolean recipients, boolean subject, boolean keywords, boolean message,
|
||||
boolean unseen, boolean flagged, boolean hidden, boolean encrypted, boolean attachments,
|
||||
Integer size,
|
||||
Long after, Long before,
|
||||
int limit, int offset);
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import android.widget.CompoundButton;
|
||||
import android.widget.DatePicker;
|
||||
import android.widget.FilterQueryProvider;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -73,6 +74,7 @@ public class FragmentDialogSearch extends FragmentDialogBase {
|
||||
final CheckBox cbHidden = dview.findViewById(R.id.cbHidden);
|
||||
final CheckBox cbEncrypted = dview.findViewById(R.id.cbEncrypted);
|
||||
final CheckBox cbAttachments = dview.findViewById(R.id.cbAttachments);
|
||||
final Spinner spMessageSize = dview.findViewById(R.id.spMessageSize);
|
||||
final Button btnBefore = dview.findViewById(R.id.btnBefore);
|
||||
final Button btnAfter = dview.findViewById(R.id.btnAfter);
|
||||
final TextView tvBefore = dview.findViewById(R.id.tvBefore);
|
||||
@@ -97,7 +99,6 @@ public class FragmentDialogSearch extends FragmentDialogBase {
|
||||
new int[]{android.R.id.text1},
|
||||
0);
|
||||
|
||||
|
||||
adapter.setFilterQueryProvider(new FilterQueryProvider() {
|
||||
public Cursor runQuery(CharSequence typed) {
|
||||
Log.i("Search suggest=" + typed);
|
||||
@@ -156,6 +157,7 @@ public class FragmentDialogSearch extends FragmentDialogBase {
|
||||
cbHidden.setEnabled(!isChecked);
|
||||
cbEncrypted.setEnabled(!isChecked);
|
||||
cbAttachments.setEnabled(!isChecked);
|
||||
spMessageSize.setEnabled(!isChecked);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -255,6 +257,12 @@ public class FragmentDialogSearch extends FragmentDialogBase {
|
||||
criteria.with_hidden = cbHidden.isChecked();
|
||||
criteria.with_encrypted = cbEncrypted.isChecked();
|
||||
criteria.with_attachments = cbAttachments.isChecked();
|
||||
|
||||
int pos = spMessageSize.getSelectedItemPosition();
|
||||
if (pos > 0) {
|
||||
int[] sizes = getResources().getIntArray(R.array.sizeValues);
|
||||
criteria.with_size = sizes[pos];
|
||||
}
|
||||
}
|
||||
|
||||
Object after = tvAfter.getTag();
|
||||
|
||||
Reference in New Issue
Block a user