add an option to block messages from unknown numbers

This commit is contained in:
Mysochenko Yuriy 2022-05-26 19:11:17 +03:00
parent 8b8ee88c43
commit f92e19e145
2 changed files with 5 additions and 2 deletions

View File

@ -62,7 +62,7 @@ android {
}
dependencies {
implementation 'com.github.SimpleMobileTools:Simple-Commons:d04f40487b'
implementation 'com.github.SimpleMobileTools:Simple-Commons:59f709a2a8'
implementation 'org.greenrobot:eventbus:3.3.1'
implementation 'com.github.tibbi:IndicatorFastScroll:4524cd0b61'
implementation 'com.github.tibbi:android-smsmms:fe58a74d59'

View File

@ -10,6 +10,7 @@ import android.provider.Telephony
import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.request.RequestOptions
import com.simplemobiletools.commons.extensions.baseConfig
import com.simplemobiletools.commons.extensions.getMyContactsCursor
import com.simplemobiletools.commons.extensions.isNumberBlocked
import com.simplemobiletools.commons.helpers.SimpleContactsHelper
@ -48,7 +49,9 @@ class SmsReceiver : BroadcastReceiver() {
Handler(Looper.getMainLooper()).post {
val privateCursor = context.getMyContactsCursor(false, true)
if (!context.isNumberBlocked(address)) {
val simpleContactsHelper = SimpleContactsHelper(context)
val isBlocked = context.baseConfig.blockUnknownNumbers && !simpleContactsHelper.exists(address)
if (!isBlocked && !context.isNumberBlocked(address)) {
ensureBackgroundThread {
val newMessageId = context.insertNewSMS(address, subject, body, date, read, threadId, type, subscriptionId)