From 61c1e7b6b5757fe126a55d64042663ed93ef4fa8 Mon Sep 17 00:00:00 2001 From: Naveen Date: Tue, 10 Jan 2023 17:01:38 +0530 Subject: [PATCH] Check result code when updating MMS status This fixes the issue where attachments are marked sent even when they aren't --- .../smsmessenger/receivers/MmsSentReceiver.kt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/receivers/MmsSentReceiver.kt b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/receivers/MmsSentReceiver.kt index 27949b7f..ee1288dc 100644 --- a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/receivers/MmsSentReceiver.kt +++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/receivers/MmsSentReceiver.kt @@ -16,8 +16,14 @@ class MmsSentReceiver : SendStatusReceiver() { override fun updateAndroidDatabase(context: Context, intent: Intent, receiverResultCode: Int) { val uri = Uri.parse(intent.getStringExtra(EXTRA_CONTENT_URI)) - val values = ContentValues(1) - values.put(Telephony.Mms.MESSAGE_BOX, Telephony.Mms.MESSAGE_BOX_SENT) + val messageBox = if (receiverResultCode == Activity.RESULT_OK) { + Telephony.Mms.MESSAGE_BOX_SENT + } else { + Telephony.Mms.MESSAGE_BOX_FAILED + } + val values = ContentValues(1).apply { + put(Telephony.Mms.MESSAGE_BOX, messageBox) + } try { context.contentResolver.update(uri, values, null, null) } catch (e: SQLiteException) {