ignore blocked numbers below Android 7

This commit is contained in:
tibbi 2020-04-19 20:39:37 +02:00
parent 8e0a2c6578
commit 4bb6f47f1b
4 changed files with 13 additions and 22 deletions

View File

@ -56,7 +56,7 @@ android {
}
dependencies {
implementation 'com.simplemobiletools:commons:5.25.21'
implementation 'com.simplemobiletools:commons:5.26.4'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta4'
implementation 'org.greenrobot:eventbus:3.2.0'
implementation 'com.klinkerapps:android-smsmms:5.2.6'

View File

@ -1,21 +1,6 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
# EventBus
-keepattributes *Annotation*
-keepclassmembers class ** {
@org.greenrobot.eventbus.Subscribe <methods>;
}
-keep enum org.greenrobot.eventbus.ThreadMode { *; }

View File

@ -29,6 +29,7 @@ import com.klinker.android.send_message.Transaction
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
import com.simplemobiletools.commons.helpers.isNougatPlus
import com.simplemobiletools.smsmessenger.R
import com.simplemobiletools.smsmessenger.adapters.AutoCompleteTextViewAdapter
import com.simplemobiletools.smsmessenger.adapters.ThreadAdapter
@ -146,6 +147,7 @@ class ThreadActivity : SimpleActivity() {
menuInflater.inflate(R.menu.menu_thread, menu)
menu.apply {
findItem(R.id.delete).isVisible = threadItems.isNotEmpty()
findItem(R.id.block_number).isVisible = isNougatPlus()
}
return true

View File

@ -619,6 +619,10 @@ fun Context.getThreadId(addresses: Set<String>): Long {
}
fun Context.isNumberBlocked(number: String): Boolean {
if (!isNougatPlus()) {
return false
}
val blockedNumbers = getBlockedNumbers()
val numberToCompare = number.trimToComparableNumber()
return blockedNumbers.map { it.numberToCompare }.contains(numberToCompare) || blockedNumbers.map { it.number }.contains(numberToCompare)