Differentiate between formatted and preview text

This commit is contained in:
M66B 2020-02-11 19:37:26 +01:00
parent ffebe78922
commit fe35cc0c1e
4 changed files with 7 additions and 3 deletions

View File

@ -252,7 +252,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
if (file.exists()) { if (file.exists()) {
String html = Helper.readText(file); String html = Helper.readText(file);
if (html.toLowerCase(Locale.ROOT).contains(find)) { if (html.toLowerCase(Locale.ROOT).contains(find)) {
String text = HtmlHelper.getText(html); String text = HtmlHelper.getPreviewText(html);
if (text.toLowerCase(Locale.ROOT).contains(find)) if (text.toLowerCase(Locale.ROOT).contains(find))
match.matched = true; match.matched = true;
} }

View File

@ -3213,7 +3213,7 @@ class Core {
String text = null; String text = null;
try { try {
String html = Helper.readText(message.getFile(context)); String html = Helper.readText(message.getFile(context));
text = HtmlHelper.getText(html); text = HtmlHelper.getPreviewText(html);
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(ex); Log.e(ex);
text = message.preview; text = message.preview;

View File

@ -1070,6 +1070,10 @@ public class HtmlHelper {
return preview; return preview;
} }
static String getPreviewText(String html) {
return JsoupEx.parse(html).text();
}
static String getText(String html) { static String getText(String html) {
final StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();

View File

@ -71,7 +71,7 @@ public class WorkerFts extends Worker {
File file = message.getFile(getApplicationContext()); File file = message.getFile(getApplicationContext());
String html = Helper.readText(file); String html = Helper.readText(file);
String text = HtmlHelper.getText(html); String text = HtmlHelper.getPreviewText(html);
try { try {
sdb.beginTransaction(); sdb.beginTransaction();
FtsDbHelper.insert(sdb, message, text); FtsDbHelper.insert(sdb, message, text);