From 1ac7f26daea71e7cade369735fcc17c29e07cb95 Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 24 Jul 2019 12:00:47 +0200 Subject: [PATCH] Search locally for keywords too --- .../email/BoundaryCallbackMessages.java | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/BoundaryCallbackMessages.java b/app/src/main/java/eu/faircode/email/BoundaryCallbackMessages.java index 7c9727fd58..d691057db5 100644 --- a/app/src/main/java/eu/faircode/email/BoundaryCallbackMessages.java +++ b/app/src/main/java/eu/faircode/email/BoundaryCallbackMessages.java @@ -22,6 +22,7 @@ package eu.faircode.email; import android.content.Context; import android.content.SharedPreferences; import android.os.Handler; +import android.text.TextUtils; import androidx.annotation.NonNull; import androidx.paging.PagedList; @@ -177,6 +178,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback 0) for (int j = 0; j < message.from.length && !match; j++) match = message.from[j].toString().toLowerCase().contains(find); - if (message.to != null) + if (!match && message.to != null && message.to.length > 0) for (int j = 0; j < message.to.length && !match; j++) match = message.to[j].toString().toLowerCase().contains(find); - if (message.subject != null && !match) + if (!match && message.subject != null) match = message.subject.toLowerCase().contains(find); - if (!match && message.content) - match = body.toLowerCase().contains(find); + if (!match && message.keywords != null && message.keywords.length > 0) + for (String keyword : message.keywords) + if (keyword.toLowerCase().contains(find)) { + match = true; + break; + } + + if (!match && message.content) { + try { + String body = Helper.readText(message.getFile(context)); + match = body.toLowerCase().contains(find); + } catch (IOException ex) { + Log.e(ex); + } + } } if (match) {