mirror of
https://github.com/SimpleMobileTools/Simple-SMS-Messenger.git
synced 2025-06-05 21:49:22 +02:00
allow sending MMS, sadly it needs internet access
This commit is contained in:
@@ -11,6 +11,11 @@
|
|||||||
<uses-permission android:name="android.provider.Telephony.SMS_RECEIVED" />
|
<uses-permission android:name="android.provider.Telephony.SMS_RECEIVED" />
|
||||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||||
|
|
||||||
|
<!-- Internet is needed and used at sending MMS only -->
|
||||||
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.READ_CONTACTS" />
|
<uses-permission android:name="android.permission.READ_CONTACTS" />
|
||||||
<uses-permission
|
<uses-permission
|
||||||
android:name="android.permission.USE_FINGERPRINT"
|
android:name="android.permission.USE_FINGERPRINT"
|
||||||
@@ -107,6 +112,8 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
|
<service android:name="com.android.mms.transaction.TransactionService"/>
|
||||||
|
|
||||||
<receiver
|
<receiver
|
||||||
android:name=".receivers.SmsReceiver"
|
android:name=".receivers.SmsReceiver"
|
||||||
android:permission="android.permission.BROADCAST_SMS">
|
android:permission="android.permission.BROADCAST_SMS">
|
||||||
@@ -126,6 +133,10 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</receiver>
|
</receiver>
|
||||||
|
|
||||||
|
<receiver
|
||||||
|
android:name=".receivers.MmsSentReceiver"
|
||||||
|
android:taskAffinity="com.klinker.android.messaging.MMS_SENT"/>
|
||||||
|
|
||||||
<receiver
|
<receiver
|
||||||
android:name=".receivers.MmsReceiver"
|
android:name=".receivers.MmsReceiver"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
|
@@ -6,6 +6,7 @@ import android.content.Intent
|
|||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.provider.MediaStore
|
||||||
import android.provider.Telephony
|
import android.provider.Telephony
|
||||||
import android.telephony.SmsManager
|
import android.telephony.SmsManager
|
||||||
import android.text.TextUtils
|
import android.text.TextUtils
|
||||||
@@ -27,6 +28,8 @@ import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
|
|||||||
import com.bumptech.glide.request.RequestListener
|
import com.bumptech.glide.request.RequestListener
|
||||||
import com.bumptech.glide.request.RequestOptions
|
import com.bumptech.glide.request.RequestOptions
|
||||||
import com.bumptech.glide.request.target.Target
|
import com.bumptech.glide.request.target.Target
|
||||||
|
import com.klinker.android.send_message.Settings
|
||||||
|
import com.klinker.android.send_message.Transaction
|
||||||
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||||
@@ -154,22 +157,7 @@ class ThreadActivity : SimpleActivity() {
|
|||||||
thread_add_attachment.applyColorFilter(config.textColor)
|
thread_add_attachment.applyColorFilter(config.textColor)
|
||||||
|
|
||||||
thread_send_message.setOnClickListener {
|
thread_send_message.setOnClickListener {
|
||||||
val msg = thread_type_message.value
|
sendMessage()
|
||||||
if (msg.isEmpty()) {
|
|
||||||
return@setOnClickListener
|
|
||||||
}
|
|
||||||
|
|
||||||
participants.forEach {
|
|
||||||
val intent = Intent(this, SmsSentReceiver::class.java).apply {
|
|
||||||
putExtra(MESSAGE_BODY, msg)
|
|
||||||
putExtra(MESSAGE_ADDRESS, it.phoneNumber)
|
|
||||||
}
|
|
||||||
|
|
||||||
val pendingIntent = PendingIntent.getBroadcast(this, threadId, intent, PendingIntent.FLAG_UPDATE_CURRENT)
|
|
||||||
val smsManager = SmsManager.getDefault()
|
|
||||||
smsManager.sendTextMessage(it.phoneNumber, null, msg, pendingIntent, null)
|
|
||||||
}
|
|
||||||
thread_type_message.setText("")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
thread_send_message.isClickable = false
|
thread_send_message.isClickable = false
|
||||||
@@ -346,6 +334,36 @@ class ThreadActivity : SimpleActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun sendMessage() {
|
||||||
|
val msg = thread_type_message.value
|
||||||
|
if (msg.isEmpty()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
participants.forEach {
|
||||||
|
if (attachmentUris.isEmpty()) {
|
||||||
|
val intent = Intent(this, SmsSentReceiver::class.java).apply {
|
||||||
|
putExtra(MESSAGE_BODY, msg)
|
||||||
|
putExtra(MESSAGE_ADDRESS, it.phoneNumber)
|
||||||
|
}
|
||||||
|
|
||||||
|
val pendingIntent = PendingIntent.getBroadcast(this, threadId, intent, PendingIntent.FLAG_UPDATE_CURRENT)
|
||||||
|
val smsManager = SmsManager.getDefault()
|
||||||
|
smsManager.sendTextMessage(it.phoneNumber, null, msg, pendingIntent, null)
|
||||||
|
} else {
|
||||||
|
val settings = Settings()
|
||||||
|
settings.useSystemSending = true
|
||||||
|
val transaction = Transaction(this, settings)
|
||||||
|
val message = com.klinker.android.send_message.Message(msg, it.phoneNumber)
|
||||||
|
val bitmap = MediaStore.Images.Media.getBitmap(contentResolver, attachmentUris.first())
|
||||||
|
message.setImage(bitmap)
|
||||||
|
transaction.sendNewMessage(message, threadId.toLong())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
thread_type_message.setText("")
|
||||||
|
}
|
||||||
|
|
||||||
// show selected contacts, properly split to new lines when appropriate
|
// show selected contacts, properly split to new lines when appropriate
|
||||||
// based on https://stackoverflow.com/a/13505029/1967672
|
// based on https://stackoverflow.com/a/13505029/1967672
|
||||||
private fun showSelectedContact(views: ArrayList<View>) {
|
private fun showSelectedContact(views: ArrayList<View>) {
|
||||||
|
@@ -0,0 +1,15 @@
|
|||||||
|
package com.simplemobiletools.smsmessenger.receivers
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import com.simplemobiletools.smsmessenger.helpers.refreshMessages
|
||||||
|
|
||||||
|
class MmsSentReceiver : com.klinker.android.send_message.MmsSentReceiver() {
|
||||||
|
override fun onMessageStatusUpdated(context: Context?, intent: Intent?, resultCode: Int) {
|
||||||
|
super.onMessageStatusUpdated(context, intent, resultCode)
|
||||||
|
if (resultCode == Activity.RESULT_OK) {
|
||||||
|
refreshMessages()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user