mirror of
https://github.com/SimpleMobileTools/Simple-SMS-Messenger.git
synced 2025-02-11 17:20:45 +01:00
Minor messaging code improvement
This commit is contained in:
parent
3d9cb5bdac
commit
ca1ad0043b
@ -4,8 +4,6 @@ import android.app.AlarmManager
|
|||||||
import android.app.PendingIntent
|
import android.app.PendingIntent
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Handler
|
|
||||||
import android.os.Looper
|
|
||||||
import androidx.core.app.AlarmManagerCompat
|
import androidx.core.app.AlarmManagerCompat
|
||||||
import com.klinker.android.send_message.Settings
|
import com.klinker.android.send_message.Settings
|
||||||
import com.klinker.android.send_message.Transaction
|
import com.klinker.android.send_message.Transaction
|
||||||
@ -71,12 +69,10 @@ fun Context.sendMessage(text: String, addresses: List<String>, subscriptionId: I
|
|||||||
|
|
||||||
transaction.setExplicitBroadcastForSentSms(smsSentIntent)
|
transaction.setExplicitBroadcastForSentSms(smsSentIntent)
|
||||||
transaction.setExplicitBroadcastForDeliveredSms(deliveredIntent)
|
transaction.setExplicitBroadcastForDeliveredSms(deliveredIntent)
|
||||||
Handler(Looper.getMainLooper()).post {
|
try {
|
||||||
try {
|
transaction.sendNewMessage(message)
|
||||||
transaction.sendNewMessage(message)
|
} catch (e: Exception) {
|
||||||
} catch (e: Exception) {
|
showErrorToast(e)
|
||||||
showErrorToast(e)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@ package com.simplemobiletools.smsmessenger.receivers
|
|||||||
import android.content.BroadcastReceiver
|
import android.content.BroadcastReceiver
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.os.Handler
|
||||||
|
import android.os.Looper
|
||||||
import android.os.PowerManager
|
import android.os.PowerManager
|
||||||
import com.simplemobiletools.commons.extensions.showErrorToast
|
import com.simplemobiletools.commons.extensions.showErrorToast
|
||||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||||
@ -43,7 +45,9 @@ class ScheduledMessageReceiver : BroadcastReceiver() {
|
|||||||
val attachments = message.attachment?.attachments ?: emptyList()
|
val attachments = message.attachment?.attachments ?: emptyList()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
context.sendMessage(message.body, addresses, message.subscriptionId, attachments)
|
Handler(Looper.getMainLooper()).post {
|
||||||
|
context.sendMessage(message.body, addresses, message.subscriptionId, attachments)
|
||||||
|
}
|
||||||
|
|
||||||
// delete temporary conversation and message as it's already persisted to the telephony db now
|
// delete temporary conversation and message as it's already persisted to the telephony db now
|
||||||
context.deleteScheduledMessage(messageId)
|
context.deleteScheduledMessage(messageId)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user