1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-29 03:05:31 +00:00

Added search in html (debug version only)

This commit is contained in:
M66B 2021-04-27 09:12:10 +02:00
parent e6d4aa8cd4
commit 865500ff1e
5 changed files with 33 additions and 5 deletions

View file

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

View file

@ -305,15 +305,19 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
boolean matched = (match.matched != null && match.matched);
if (query != null) {
if (!matched && criteria.in_message)
if (!matched && (criteria.in_message || criteria.in_html))
try {
File file = EntityMessage.getFile(context, match.id);
if (file.exists()) {
String html = Helper.readText(file);
if (html.toLowerCase().contains(query)) {
String text = HtmlHelper.getFullText(html);
if (text != null && text.toLowerCase().contains(query))
if (criteria.in_html)
matched = true;
else {
String text = HtmlHelper.getFullText(html);
if (text != null && text.toLowerCase().contains(query))
matched = true;
}
}
}
} catch (IOException ex) {
@ -677,6 +681,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
boolean in_message = true;
boolean in_notes = true;
boolean in_headers = false;
boolean in_html = false;
boolean with_unseen;
boolean with_flagged;
boolean with_hidden;
@ -871,6 +876,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
this.in_message == other.in_message &&
this.in_notes == other.in_notes &&
this.in_headers == other.in_headers &&
this.in_html == other.in_html &&
this.with_unseen == other.with_unseen &&
this.with_flagged == other.with_flagged &&
this.with_hidden == other.with_hidden &&
@ -897,6 +903,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
" message=" + in_message +
" notes=" + in_notes +
" headers=" + in_headers +
" html=" + in_html +
" unseen=" + with_unseen +
" flagged=" + with_flagged +
" hidden=" + with_hidden +

View file

@ -100,6 +100,7 @@ public class FragmentDialogSearch extends FragmentDialogBase {
final CheckBox cbMessage = dview.findViewById(R.id.cbMessage);
final CheckBox cbNotes = dview.findViewById(R.id.cbNotes);
final CheckBox cbHeaders = dview.findViewById(R.id.cbHeaders);
final CheckBox cbHtml = dview.findViewById(R.id.cbHtml);
final CheckBox cbUnseen = dview.findViewById(R.id.cbUnseen);
final CheckBox cbFlagged = dview.findViewById(R.id.cbFlagged);
final CheckBox cbHidden = dview.findViewById(R.id.cbHidden);
@ -200,11 +201,14 @@ public class FragmentDialogSearch extends FragmentDialogBase {
ibMore.setImageLevel(1);
grpMore.setVisibility(View.GONE);
cbHeaders.setVisibility(View.GONE);
cbHtml.setVisibility(View.GONE);
} else {
ibMore.setImageLevel(0);
grpMore.setVisibility(View.VISIBLE);
if (BuildConfig.DEBUG)
if (BuildConfig.DEBUG) {
cbHeaders.setVisibility(View.VISIBLE);
cbHtml.setVisibility(View.VISIBLE);
}
}
}
};
@ -223,6 +227,7 @@ public class FragmentDialogSearch extends FragmentDialogBase {
cbMessage.setEnabled(!isChecked);
cbNotes.setEnabled(!isChecked);
cbHeaders.setEnabled(!isChecked);
cbHtml.setEnabled(!isChecked);
cbUnseen.setEnabled(!isChecked);
cbFlagged.setEnabled(!isChecked);
cbHidden.setEnabled(!isChecked);
@ -319,6 +324,7 @@ public class FragmentDialogSearch extends FragmentDialogBase {
grpMore.setVisibility(View.GONE);
cbHeaders.setVisibility(View.GONE);
cbHtml.setVisibility(View.GONE);
etQuery.requestFocus();
if (imm != null)
@ -362,6 +368,7 @@ public class FragmentDialogSearch extends FragmentDialogBase {
criteria.in_message = cbMessage.isChecked();
criteria.in_notes = cbNotes.isChecked();
criteria.in_headers = cbHeaders.isChecked();
criteria.in_html = cbHtml.isChecked();
criteria.with_unseen = cbUnseen.isChecked();
criteria.with_flagged = cbFlagged.isChecked();
criteria.with_hidden = cbHidden.isChecked();

View file

@ -345,6 +345,18 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbNotes" />
<CheckBox
android:id="@+id/cbHtml"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="12dp"
android:text="@string/title_search_in_html"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbHeaders" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvAnd"
android:layout_width="wrap_content"
@ -354,7 +366,7 @@
android:text="@string/title_search_with"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbHeaders" />
app:layout_constraintTop_toBottomOf="@id/cbHtml" />
<CheckBox
android:id="@+id/cbUnseen"

View file

@ -1176,6 +1176,7 @@
<string name="title_search_in_message">In message text</string>
<string name="title_search_in_notes">In local notes</string>
<string name="title_search_in_headers" translatable="false">In headers</string>
<string name="title_search_in_html" translatable="false">In HTML</string>
<string name="title_search_with">Limit search to</string>
<string name="title_search_with_unseen">Unread</string>
<string name="title_search_with_flagged">Starred</string>