From fce6ed2640812e76dffbe17ec6e0547ffa6e87d4 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 13 Apr 2020 11:58:44 +0200 Subject: [PATCH] handle read and send sms separately --- app/build.gradle | 2 +- .../smsmessenger/activities/MainActivity.kt | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index de0272d0..ce57db55 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -36,7 +36,7 @@ android { } dependencies { - implementation 'com.simplemobiletools:commons:5.25.9' + implementation 'com.simplemobiletools:commons:5.25.11' 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/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/MainActivity.kt index 8df30684..b27eb6c5 100644 --- a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/MainActivity.kt @@ -116,14 +116,20 @@ class MainActivity : SimpleActivity() { storedTextColor = config.textColor } - // while READ_SMS permission is mandatory, READ_CONTACTS is optional. If we don't have it, we just won't be able to show the contact name in some cases + // while SEND_SMS and READ_SMS permissions are mandatory, READ_CONTACTS is optional. If we don't have it, we just won't be able to show the contact name in some cases private fun askPermissions() { handlePermission(PERMISSION_READ_SMS) { if (it) { - handlePermission(PERMISSION_READ_CONTACTS) { - bus = EventBus.getDefault() - bus!!.register(this) - initMessenger() + handlePermission(PERMISSION_SEND_SMS) { + if (it) { + handlePermission(PERMISSION_READ_CONTACTS) { + bus = EventBus.getDefault() + bus!!.register(this) + initMessenger() + } + } else { + finish() + } } } else { finish()