From 4bb6f47f1b8de978bb9a5e7b33ec50de0f08143d Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 19 Apr 2020 20:39:37 +0200 Subject: [PATCH] ignore blocked numbers below Android 7 --- app/build.gradle | 2 +- app/proguard-rules.pro | 27 +++++-------------- .../smsmessenger/activities/ThreadActivity.kt | 2 ++ .../smsmessenger/extensions/Context.kt | 4 +++ 4 files changed, 13 insertions(+), 22 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index b823d54a..a51c7b78 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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' diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index f1b42451..e6c59860 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -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 ; +} +-keep enum org.greenrobot.eventbus.ThreadMode { *; } diff --git a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/ThreadActivity.kt b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/ThreadActivity.kt index e6572c9e..f5a03c70 100644 --- a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/ThreadActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/ThreadActivity.kt @@ -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 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 988b70ef..4cae6460 100644 --- a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/extensions/Context.kt @@ -619,6 +619,10 @@ fun Context.getThreadId(addresses: Set): 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)