Properly update sent message type

This commit is contained in:
Naveen 2022-12-07 22:39:04 +05:30
parent 860e6c255b
commit 6e7dbb9056
1 changed files with 6 additions and 3 deletions

View File

@ -1,5 +1,6 @@
package com.simplemobiletools.smsmessenger.receivers package com.simplemobiletools.smsmessenger.receivers
import android.app.Activity
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.net.Uri import android.net.Uri
@ -19,11 +20,13 @@ 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 {
val type = if (intent.extras!!.containsKey("errorCode")) { if (intent.extras!!.containsKey("errorCode")) {
showSendingFailedNotification(context, messageId) showSendingFailedNotification(context, messageId)
Telephony.Sms.MESSAGE_TYPE_FAILED }
} else { val type = if (receiverResultCode == Activity.RESULT_OK) {
Telephony.Sms.MESSAGE_TYPE_SENT Telephony.Sms.MESSAGE_TYPE_SENT
} else {
Telephony.Sms.MESSAGE_TYPE_FAILED
} }
context.updateMessageType(messageId, type) context.updateMessageType(messageId, type)