mirror of
https://github.com/SimpleMobileTools/Simple-SMS-Messenger.git
synced 2025-06-05 21:49:22 +02:00
prepare for handling multiple mms attachments
This commit is contained in:
@@ -187,10 +187,11 @@ class ThreadAdapter(
|
|||||||
thread_message_body.setTextColor(background.getContrastColor())
|
thread_message_body.setTextColor(background.getContrastColor())
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message.attachment != null) {
|
if (message.attachment?.attachments?.isNotEmpty() == true) {
|
||||||
val type = message.attachment.type
|
val attachment = message.attachment.attachments.first()
|
||||||
|
val type = attachment.type
|
||||||
if (type.startsWith("image/") || type.startsWith("video/")) {
|
if (type.startsWith("image/") || type.startsWith("video/")) {
|
||||||
val uri = message.attachment.uri
|
val uri = attachment.uri
|
||||||
val options = RequestOptions()
|
val options = RequestOptions()
|
||||||
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||||
.transform(FitCenter(), RoundedCorners(roundedCornersRadius))
|
.transform(FitCenter(), RoundedCorners(roundedCornersRadius))
|
||||||
|
@@ -142,6 +142,7 @@ fun Context.getMMS(threadId: Int? = null, sortOrder: String? = null): ArrayList<
|
|||||||
contactsMap.put(it.id, it)
|
contactsMap.put(it.id, it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return messages
|
return messages
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,20 +219,20 @@ fun Context.getMmsAttachment(id: Int): MessageAttachment? {
|
|||||||
)
|
)
|
||||||
val selection = "${Mms.Part.MSG_ID} = ?"
|
val selection = "${Mms.Part.MSG_ID} = ?"
|
||||||
val selectionArgs = arrayOf(id.toString())
|
val selectionArgs = arrayOf(id.toString())
|
||||||
val attachment = MessageAttachment(id, "", null, "")
|
val messageAttachment = MessageAttachment(id, "", arrayListOf())
|
||||||
|
|
||||||
queryCursor(uri, projection, selection, selectionArgs, showErrors = true) { cursor ->
|
queryCursor(uri, projection, selection, selectionArgs, showErrors = true) { cursor ->
|
||||||
val partId = cursor.getStringValue(Mms._ID)
|
val partId = cursor.getStringValue(Mms._ID)
|
||||||
val type = cursor.getStringValue(Mms.Part.CONTENT_TYPE)
|
val type = cursor.getStringValue(Mms.Part.CONTENT_TYPE)
|
||||||
if (type == "text/plain") {
|
if (type == "text/plain") {
|
||||||
attachment.text = cursor.getStringValue(Mms.Part.TEXT) ?: ""
|
messageAttachment.text = cursor.getStringValue(Mms.Part.TEXT) ?: ""
|
||||||
} else if (type.startsWith("image/") || type.startsWith("video/")) {
|
} else if (type.startsWith("image/") || type.startsWith("video/")) {
|
||||||
attachment.uri = Uri.withAppendedPath(uri, partId)
|
val attachment = Attachment(Uri.withAppendedPath(uri, partId), type)
|
||||||
attachment.type = type
|
messageAttachment.attachments.add(attachment)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return attachment
|
return messageAttachment
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Context.getLatestMMS(): Message? {
|
fun Context.getLatestMMS(): Message? {
|
||||||
|
@@ -0,0 +1,5 @@
|
|||||||
|
package com.simplemobiletools.smsmessenger.models
|
||||||
|
|
||||||
|
import android.net.Uri
|
||||||
|
|
||||||
|
data class Attachment(var uri: Uri?, var type: String)
|
@@ -1,5 +1,3 @@
|
|||||||
package com.simplemobiletools.smsmessenger.models
|
package com.simplemobiletools.smsmessenger.models
|
||||||
|
|
||||||
import android.net.Uri
|
data class MessageAttachment(val id: Int, var text: String, var attachments: ArrayList<Attachment>)
|
||||||
|
|
||||||
data class MessageAttachment(val id: Int, var text: String, var uri: Uri?, var type: String)
|
|
||||||
|
@@ -19,7 +19,7 @@ class MmsReceiver : com.klinker.android.send_message.MmsReceivedReceiver() {
|
|||||||
val glideBitmap = try {
|
val glideBitmap = try {
|
||||||
Glide.with(context)
|
Glide.with(context)
|
||||||
.asBitmap()
|
.asBitmap()
|
||||||
.load(mms.attachment!!.uri)
|
.load(mms.attachment!!.attachments.first().uri)
|
||||||
.centerCrop()
|
.centerCrop()
|
||||||
.into(size, size)
|
.into(size, size)
|
||||||
.get()
|
.get()
|
||||||
|
Reference in New Issue
Block a user