mirror of
https://github.com/SimpleMobileTools/Simple-SMS-Messenger.git
synced 2025-02-07 04:43:24 +01:00
Only show failure notification when in background
This commit is contained in:
parent
2fc70b2dc5
commit
0523d93243
@ -70,6 +70,7 @@ dependencies {
|
|||||||
implementation "me.leolin:ShortcutBadger:1.1.22"
|
implementation "me.leolin:ShortcutBadger:1.1.22"
|
||||||
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
|
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
|
||||||
implementation 'com.googlecode.ez-vcard:ez-vcard:0.11.3'
|
implementation 'com.googlecode.ez-vcard:ez-vcard:0.11.3'
|
||||||
|
implementation 'androidx.lifecycle:lifecycle-process:2.5.1'
|
||||||
|
|
||||||
kapt "androidx.room:room-compiler:2.4.3"
|
kapt "androidx.room:room-compiler:2.4.3"
|
||||||
implementation "androidx.room:room-runtime:2.4.3"
|
implementation "androidx.room:room-runtime:2.4.3"
|
||||||
|
@ -7,6 +7,8 @@ import android.net.Uri
|
|||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
import android.provider.Telephony
|
import android.provider.Telephony
|
||||||
|
import androidx.lifecycle.Lifecycle
|
||||||
|
import androidx.lifecycle.ProcessLifecycleOwner
|
||||||
import com.klinker.android.send_message.SentReceiver
|
import com.klinker.android.send_message.SentReceiver
|
||||||
import com.simplemobiletools.commons.extensions.getMyContactsCursor
|
import com.simplemobiletools.commons.extensions.getMyContactsCursor
|
||||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||||
@ -20,12 +22,10 @@ class SmsStatusSentReceiver : SentReceiver() {
|
|||||||
val uri = Uri.parse(intent.getStringExtra("message_uri"))
|
val uri = Uri.parse(intent.getStringExtra("message_uri"))
|
||||||
val messageId = uri?.lastPathSegment?.toLong() ?: 0L
|
val messageId = uri?.lastPathSegment?.toLong() ?: 0L
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
if (intent.extras!!.containsKey("errorCode")) {
|
|
||||||
showSendingFailedNotification(context, messageId)
|
|
||||||
}
|
|
||||||
val type = if (receiverResultCode == Activity.RESULT_OK) {
|
val type = if (receiverResultCode == Activity.RESULT_OK) {
|
||||||
Telephony.Sms.MESSAGE_TYPE_SENT
|
Telephony.Sms.MESSAGE_TYPE_SENT
|
||||||
} else {
|
} else {
|
||||||
|
showSendingFailedNotification(context, messageId)
|
||||||
Telephony.Sms.MESSAGE_TYPE_FAILED
|
Telephony.Sms.MESSAGE_TYPE_FAILED
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,6 +46,9 @@ class SmsStatusSentReceiver : SentReceiver() {
|
|||||||
|
|
||||||
private fun showSendingFailedNotification(context: Context, messageId: Long) {
|
private fun showSendingFailedNotification(context: Context, messageId: Long) {
|
||||||
Handler(Looper.getMainLooper()).post {
|
Handler(Looper.getMainLooper()).post {
|
||||||
|
if (ProcessLifecycleOwner.get().lifecycle.currentState.isAtLeast(Lifecycle.State.RESUMED)) {
|
||||||
|
return@post
|
||||||
|
}
|
||||||
val privateCursor = context.getMyContactsCursor(favoritesOnly = false, withPhoneNumbersOnly = true)
|
val privateCursor = context.getMyContactsCursor(favoritesOnly = false, withPhoneNumbersOnly = true)
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
val address = context.getMessageRecipientAddress(messageId)
|
val address = context.getMessageRecipientAddress(messageId)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user