mirror of
https://github.com/SimpleMobileTools/Simple-SMS-Messenger.git
synced 2025-01-30 17:14:55 +01:00
Use sendMessage extension
This commit is contained in:
parent
1f36738be0
commit
06f6a9ae05
@ -3,10 +3,8 @@ package com.simplemobiletools.smsmessenger.services
|
||||
import android.app.Service
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import com.klinker.android.send_message.Transaction
|
||||
import com.simplemobiletools.smsmessenger.helpers.getSendMessageSettings
|
||||
import com.simplemobiletools.smsmessenger.receivers.SmsStatusDeliveredReceiver
|
||||
import com.simplemobiletools.smsmessenger.receivers.SmsStatusSentReceiver
|
||||
import com.klinker.android.send_message.Settings
|
||||
import com.simplemobiletools.smsmessenger.messaging.sendMessageCompat
|
||||
|
||||
class HeadlessSmsSendService : Service() {
|
||||
override fun onBind(intent: Intent?) = null
|
||||
@ -19,17 +17,11 @@ class HeadlessSmsSendService : Service() {
|
||||
|
||||
val number = Uri.decode(intent.dataString!!.removePrefix("sms:").removePrefix("smsto:").removePrefix("mms").removePrefix("mmsto:").trim())
|
||||
val text = intent.getStringExtra(Intent.EXTRA_TEXT)
|
||||
val settings = getSendMessageSettings()
|
||||
val transaction = Transaction(this, settings)
|
||||
val message = com.klinker.android.send_message.Message(text, number)
|
||||
|
||||
val smsSentIntent = Intent(this, SmsStatusSentReceiver::class.java)
|
||||
val deliveredIntent = Intent(this, SmsStatusDeliveredReceiver::class.java)
|
||||
|
||||
transaction.setExplicitBroadcastForSentSms(smsSentIntent)
|
||||
transaction.setExplicitBroadcastForDeliveredSms(deliveredIntent)
|
||||
|
||||
transaction.sendNewMessage(message)
|
||||
if (!text.isNullOrEmpty()) {
|
||||
val addresses = listOf(number)
|
||||
val subId = Settings.DEFAULT_SUBSCRIPTION_ID
|
||||
sendMessageCompat(text, addresses, subId, emptyList())
|
||||
}
|
||||
} catch (ignored: Exception) {
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user