Added search for messages with a local note

This commit is contained in:
M66B 2021-03-25 14:02:12 +01:00
parent f7a85deeec
commit 2a09da7467
6 changed files with 34 additions and 8 deletions

View File

@ -278,6 +278,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
criteria.with_hidden,
criteria.with_encrypted,
criteria.with_attachments,
criteria.with_notes,
criteria.with_types == null ? 0 : criteria.with_types.length,
criteria.with_types == null ? new String[]{} : criteria.with_types,
criteria.with_size,
@ -682,6 +683,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
boolean with_hidden;
boolean with_encrypted;
boolean with_attachments;
boolean with_notes;
String[] with_types;
Integer with_size = null;
Long after = null;
@ -843,6 +845,8 @@ 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_notes)
flags.add(context.getString(R.string.title_search_flag_notes));
if (with_types != null)
if (with_types.length == 1 && "text/calendar".equals(with_types[0]))
flags.add(context.getString(R.string.title_search_flag_invite));
@ -872,6 +876,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 &&
this.with_notes == other.with_notes &&
Arrays.equals(this.with_types, other.with_types) &&
Objects.equals(this.with_size, other.with_size) &&
Objects.equals(this.after, other.after) &&
@ -895,7 +900,8 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
" flagged=" + with_flagged +
" hidden=" + with_hidden +
" encrypted=" + with_encrypted +
" attachments=" + with_attachments +
" w/attachments=" + with_attachments +
" w/notes=" + with_notes +
" type=" + (with_types == null ? null : TextUtils.join(",", with_types)) +
" size=" + with_size +
" after=" + (after == null ? "" : new Date(after)) +

View File

@ -332,7 +332,8 @@ public interface DaoMessage {
" AND (NOT :flagged OR ui_flagged)" +
" AND (NOT :hidden OR NOT ui_snoozed IS NULL)" +
" AND (NOT :encrypted OR ui_encrypt > 0)" +
" AND (NOT :attachments OR attachments > 0)" +
" AND (NOT :with_attachments OR attachments > 0)" +
" AND (NOT :with_notes OR NOT `notes` IS NULL)" +
" AND (:type_count = 0 OR attachment.type IN (:types))" +
" AND (:size IS NULL OR total > :size)" +
" AND (:after IS NULL OR received > :after)" +
@ -343,7 +344,7 @@ public interface DaoMessage {
List<TupleMatch> matchMessages(
Long account, Long folder, String find,
boolean senders, boolean recipients, boolean subject, boolean keywords, boolean message, boolean notes,
boolean unseen, boolean flagged, boolean hidden, boolean encrypted, boolean attachments,
boolean unseen, boolean flagged, boolean hidden, boolean encrypted, boolean with_attachments, boolean with_notes,
int type_count, String[] types,
Integer size,
Long after, Long before,

View File

@ -79,6 +79,7 @@ public class FragmentDialogSearch extends FragmentDialogBase {
View dview = LayoutInflater.from(context).inflate(R.layout.dialog_search, null);
final AutoCompleteTextView etQuery = dview.findViewById(R.id.etQuery);
final ImageButton ibNotes = dview.findViewById(R.id.ibNotes);
final ImageButton ibAttachment = dview.findViewById(R.id.ibAttachment);
final ImageButton ibEvent = dview.findViewById(R.id.ibInvite);
final ImageButton ibUnseen = dview.findViewById(R.id.ibUnseen);
@ -388,16 +389,17 @@ public class FragmentDialogSearch extends FragmentDialogBase {
BoundaryCallbackMessages.SearchCriteria criteria = new BoundaryCallbackMessages.SearchCriteria();
int id = v.getId();
if (id == R.id.ibAttachment) {
if (id == R.id.ibNotes)
criteria.with_notes = true;
else if (id == R.id.ibAttachment)
criteria.with_attachments = true;
} else if (id == R.id.ibInvite) {
else if (id == R.id.ibInvite) {
criteria.with_attachments = true;
criteria.with_types = new String[]{"text/calendar"};
} else if (id == R.id.ibUnseen) {
} else if (id == R.id.ibUnseen)
criteria.with_unseen = true;
} else if (id == R.id.ibFlagged) {
else if (id == R.id.ibFlagged)
criteria.with_flagged = true;
}
FragmentMessages.search(
context, getViewLifecycleOwner(), getParentFragmentManager(),
@ -405,6 +407,7 @@ public class FragmentDialogSearch extends FragmentDialogBase {
}
};
ibNotes.setOnClickListener(onClick);
ibAttachment.setOnClickListener(onClick);
ibEvent.setOnClickListener(onClick);
ibUnseen.setOnClickListener(onClick);

View File

@ -1138,6 +1138,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
if (criteria.with_hidden ||
criteria.with_encrypted ||
criteria.with_attachments ||
criteria.with_notes ||
criteria.with_types != null)
fabSearch.hide();
else

View File

@ -20,6 +20,20 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageButton
android:id="@+id/ibNotes"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_marginEnd="12dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/title_search_flag_notes"
android:padding="6dp"
android:scaleType="fitCenter"
android:tooltipText="@string/title_search_flag_notes"
app:layout_constraintEnd_toStartOf="@+id/ibAttachment"
app:layout_constraintTop_toBottomOf="@id/tvCaption"
app:srcCompat="@drawable/twotone_sticky_note_2_24" />
<ImageButton
android:id="@+id/ibAttachment"
android:layout_width="36dp"

View File

@ -1151,6 +1151,7 @@
<string name="title_search_flag_hidden">hidden</string>
<string name="title_search_flag_encrypted">encrypted</string>
<string name="title_search_flag_attachments">attachments</string>
<string name="title_search_flag_notes">notes</string>
<string name="title_search_flag_invite">invitation</string>
<string name="title_search_flag_size">size &gt; %1$s</string>