From 88389a09c939487b61b4a8ccc1413978ac6fb6d3 Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 8 Apr 2020 13:41:47 +0200 Subject: [PATCH] do not show blocked number messages on the main screen --- .../simplemobiletools/smsmessenger/extensions/Context.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/extensions/Context.kt index e82e2648..cddae58b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/extensions/Context.kt @@ -90,6 +90,7 @@ fun Context.getMessages(threadId: Int? = null): ArrayList { messages = messages.distinctBy { it.thread }.toMutableList() as ArrayList } + messages = messages.filter { !isNumberBlocked(it.senderNumber) }.toMutableList() as ArrayList return messages } @@ -470,3 +471,8 @@ fun Context.getThreadId(address: String): Long { 0 } } + +fun Context.isNumberBlocked(number: String): Boolean { + val blockedNumbers = getBlockedNumbers() + return blockedNumbers.map { it.number }.contains(number) && !blockedNumbers.map { it.normalizedNumber }.contains(number) +}