Added searching for notes

pull/194/head
M66B 4 years ago
parent 63d747690b
commit 4dc85ee892

@ -455,6 +455,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
criteria.in_subject = false; criteria.in_subject = false;
criteria.in_keywords = false; criteria.in_keywords = false;
criteria.in_message = false; criteria.in_message = false;
criteria.in_notes = false;
criteria.with_flagged = true; criteria.with_flagged = true;
FragmentMessages.search( FragmentMessages.search(
context, owner, parentFragment.getParentFragmentManager(), context, owner, parentFragment.getParentFragmentManager(),

@ -242,6 +242,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
criteria.in_subject, criteria.in_subject,
criteria.in_keywords, criteria.in_keywords,
criteria.in_message, criteria.in_message,
criteria.in_notes,
criteria.with_unseen, criteria.with_unseen,
criteria.with_flagged, criteria.with_flagged,
criteria.with_hidden, criteria.with_hidden,
@ -647,6 +648,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
boolean in_subject = true; boolean in_subject = true;
boolean in_keywords = true; boolean in_keywords = true;
boolean in_message = true; boolean in_message = true;
boolean in_notes = true;
boolean with_unseen; boolean with_unseen;
boolean with_flagged; boolean with_flagged;
boolean with_hidden; boolean with_hidden;
@ -836,6 +838,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
this.in_subject == other.in_subject && this.in_subject == other.in_subject &&
this.in_keywords == other.in_keywords && this.in_keywords == other.in_keywords &&
this.in_message == other.in_message && this.in_message == other.in_message &&
this.in_notes == other.in_notes &&
this.with_unseen == other.with_unseen && this.with_unseen == other.with_unseen &&
this.with_flagged == other.with_flagged && this.with_flagged == other.with_flagged &&
this.with_hidden == other.with_hidden && this.with_hidden == other.with_hidden &&
@ -859,6 +862,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
" subject=" + in_subject + " subject=" + in_subject +
" keywords=" + in_keywords + " keywords=" + in_keywords +
" message=" + in_message + " message=" + in_message +
" notes=" + in_notes +
" unseen=" + with_unseen + " unseen=" + with_unseen +
" flagged=" + with_flagged + " flagged=" + with_flagged +
" hidden=" + with_hidden + " hidden=" + with_hidden +

@ -315,6 +315,7 @@ public interface DaoMessage {
" OR (:subject AND `subject` LIKE :find COLLATE NOCASE)" + // unsuitable index " OR (:subject AND `subject` LIKE :find COLLATE NOCASE)" + // unsuitable index
" OR (:keywords AND `keywords` LIKE :find COLLATE NOCASE)" + // no index " OR (:keywords AND `keywords` LIKE :find COLLATE NOCASE)" + // no index
" OR (:message AND `preview` LIKE :find COLLATE NOCASE)" + // no index " OR (:message AND `preview` LIKE :find COLLATE NOCASE)" + // no index
" OR (:notes AND `notes` LIKE :find COLLATE NOCASE)" + // no index
" OR (attachment.name LIKE :find COLLATE NOCASE)" + // no index " OR (attachment.name LIKE :find COLLATE NOCASE)" + // no index
" OR (attachment.type LIKE :find COLLATE NOCASE)) AS matched" + // no index " OR (attachment.type LIKE :find COLLATE NOCASE)) AS matched" + // no index
" FROM message" + " FROM message" +
@ -335,7 +336,7 @@ public interface DaoMessage {
" LIMIT :limit OFFSET :offset") " LIMIT :limit OFFSET :offset")
List<TupleMatch> matchMessages( List<TupleMatch> matchMessages(
Long account, Long folder, String find, Long account, Long folder, String find,
boolean senders, boolean recipients, boolean subject, boolean keywords, boolean message, 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 attachments,
int type_count, String[] types, int type_count, String[] types,
Integer size, Integer size,

@ -72,6 +72,7 @@ public class FragmentDialogSearch extends FragmentDialogBase {
boolean last_search_subject = prefs.getBoolean("last_search_subject", true); boolean last_search_subject = prefs.getBoolean("last_search_subject", true);
boolean last_search_keywords = prefs.getBoolean("last_search_keywords", false); boolean last_search_keywords = prefs.getBoolean("last_search_keywords", false);
boolean last_search_message = prefs.getBoolean("last_search_message", true); boolean last_search_message = prefs.getBoolean("last_search_message", true);
boolean last_search_notes = prefs.getBoolean("last_search_notes", true);
String last_search = prefs.getString("last_search", null); 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);
@ -90,6 +91,7 @@ public class FragmentDialogSearch extends FragmentDialogBase {
final CheckBox cbSubject = dview.findViewById(R.id.cbSubject); final CheckBox cbSubject = dview.findViewById(R.id.cbSubject);
final CheckBox cbKeywords = dview.findViewById(R.id.cbKeywords); final CheckBox cbKeywords = dview.findViewById(R.id.cbKeywords);
final CheckBox cbMessage = dview.findViewById(R.id.cbMessage); final CheckBox cbMessage = dview.findViewById(R.id.cbMessage);
final CheckBox cbNotes = dview.findViewById(R.id.cbNotes);
final CheckBox cbUnseen = dview.findViewById(R.id.cbUnseen); final CheckBox cbUnseen = dview.findViewById(R.id.cbUnseen);
final CheckBox cbFlagged = dview.findViewById(R.id.cbFlagged); final CheckBox cbFlagged = dview.findViewById(R.id.cbFlagged);
final CheckBox cbHidden = dview.findViewById(R.id.cbHidden); final CheckBox cbHidden = dview.findViewById(R.id.cbHidden);
@ -173,6 +175,7 @@ public class FragmentDialogSearch extends FragmentDialogBase {
cbSubject.setEnabled(!isChecked); cbSubject.setEnabled(!isChecked);
cbKeywords.setEnabled(!isChecked); cbKeywords.setEnabled(!isChecked);
cbMessage.setEnabled(!isChecked); cbMessage.setEnabled(!isChecked);
cbNotes.setEnabled(!isChecked);
cbUnseen.setEnabled(!isChecked); cbUnseen.setEnabled(!isChecked);
cbFlagged.setEnabled(!isChecked); cbFlagged.setEnabled(!isChecked);
cbHidden.setEnabled(!isChecked); cbHidden.setEnabled(!isChecked);
@ -217,6 +220,13 @@ public class FragmentDialogSearch extends FragmentDialogBase {
} }
}); });
cbNotes.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
prefs.edit().putBoolean("last_search_notes", isChecked).apply();
}
});
spMessageSize.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { spMessageSize.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override @Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
@ -256,6 +266,7 @@ public class FragmentDialogSearch extends FragmentDialogBase {
cbSubject.setChecked(last_search_subject); cbSubject.setChecked(last_search_subject);
cbKeywords.setChecked(last_search_keywords); cbKeywords.setChecked(last_search_keywords);
cbMessage.setChecked(last_search_message); cbMessage.setChecked(last_search_message);
cbNotes.setChecked(last_search_notes);
tvAfter.setText(null); tvAfter.setText(null);
tvBefore.setText(null); tvBefore.setText(null);
@ -289,6 +300,7 @@ public class FragmentDialogSearch extends FragmentDialogBase {
criteria.in_subject = cbSubject.isChecked(); criteria.in_subject = cbSubject.isChecked();
criteria.in_keywords = cbKeywords.isChecked(); criteria.in_keywords = cbKeywords.isChecked();
criteria.in_message = cbMessage.isChecked(); criteria.in_message = cbMessage.isChecked();
criteria.in_notes = cbNotes.isChecked();
criteria.with_unseen = cbUnseen.isChecked(); criteria.with_unseen = cbUnseen.isChecked();
criteria.with_flagged = cbFlagged.isChecked(); criteria.with_flagged = cbFlagged.isChecked();
criteria.with_hidden = cbHidden.isChecked(); criteria.with_hidden = cbHidden.isChecked();

@ -239,6 +239,19 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbMessage" /> app:layout_constraintTop_toBottomOf="@id/cbMessage" />
<CheckBox
android:id="@+id/cbNotes"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="12dp"
android:checked="true"
android:text="@string/title_search_in_notes"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvSearchTextHint" />
<eu.faircode.email.FixedTextView <eu.faircode.email.FixedTextView
android:id="@+id/tvAnd" android:id="@+id/tvAnd"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -248,7 +261,7 @@
android:text="@string/title_search_with" android:text="@string/title_search_with"
android:textAppearance="@style/TextAppearance.AppCompat.Medium" android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvSearchTextHint" /> app:layout_constraintTop_toBottomOf="@id/cbNotes" />
<CheckBox <CheckBox
android:id="@+id/cbUnseen" android:id="@+id/cbUnseen"
@ -399,7 +412,7 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"
app:constraint_referenced_ids=" app:constraint_referenced_ids="
cbSearchIndex,tvSearchIndexHint,cbSenders,cbRecipients,cbSubject,cbKeywords,cbMessage,tvSearchTextHint, cbSearchIndex,tvSearchIndexHint,cbSenders,cbRecipients,cbSubject,cbKeywords,cbMessage,tvSearchTextHint,cbNotes,
tvAnd,cbUnseen,cbFlagged,cbHidden,cbEncrypted,cbAttachments, tvAnd,cbUnseen,cbFlagged,cbHidden,cbEncrypted,cbAttachments,
btnAfter,btnBefore,tvBefore,tvAfter" /> btnAfter,btnBefore,tvBefore,tvAfter" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

@ -1121,6 +1121,7 @@
<string name="title_search_in_subject">In subject</string> <string name="title_search_in_subject">In subject</string>
<string name="title_search_in_keywords">In keywords (if supported)</string> <string name="title_search_in_keywords">In keywords (if supported)</string>
<string name="title_search_in_message">In message text</string> <string name="title_search_in_message">In message text</string>
<string name="title_search_in_notes">In local notes</string>
<string name="title_search_with">Limit search to</string> <string name="title_search_with">Limit search to</string>
<string name="title_search_with_unseen">Unread</string> <string name="title_search_with_unseen">Unread</string>
<string name="title_search_with_flagged">Starred</string> <string name="title_search_with_flagged">Starred</string>

Loading…
Cancel
Save