prepare for handling multiple mms attachments
This commit is contained in:
parent
59ba80d65a
commit
a5d8633593
|
@ -187,10 +187,11 @@ class ThreadAdapter(
|
|||
thread_message_body.setTextColor(background.getContrastColor())
|
||||
}
|
||||
|
||||
if (message.attachment != null) {
|
||||
val type = message.attachment.type
|
||||
if (message.attachment?.attachments?.isNotEmpty() == true) {
|
||||
val attachment = message.attachment.attachments.first()
|
||||
val type = attachment.type
|
||||
if (type.startsWith("image/") || type.startsWith("video/")) {
|
||||
val uri = message.attachment.uri
|
||||
val uri = attachment.uri
|
||||
val options = RequestOptions()
|
||||
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||
.transform(FitCenter(), RoundedCorners(roundedCornersRadius))
|
||||
|
|
|
@ -142,6 +142,7 @@ fun Context.getMMS(threadId: Int? = null, sortOrder: String? = null): ArrayList<
|
|||
contactsMap.put(it.id, it)
|
||||
}
|
||||
}
|
||||
|
||||
return messages
|
||||
}
|
||||
|
||||
|
@ -218,20 +219,20 @@ fun Context.getMmsAttachment(id: Int): MessageAttachment? {
|
|||
)
|
||||
val selection = "${Mms.Part.MSG_ID} = ?"
|
||||
val selectionArgs = arrayOf(id.toString())
|
||||
val attachment = MessageAttachment(id, "", null, "")
|
||||
val messageAttachment = MessageAttachment(id, "", arrayListOf())
|
||||
|
||||
queryCursor(uri, projection, selection, selectionArgs, showErrors = true) { cursor ->
|
||||
val partId = cursor.getStringValue(Mms._ID)
|
||||
val type = cursor.getStringValue(Mms.Part.CONTENT_TYPE)
|
||||
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/")) {
|
||||
attachment.uri = Uri.withAppendedPath(uri, partId)
|
||||
attachment.type = type
|
||||
val attachment = Attachment(Uri.withAppendedPath(uri, partId), type)
|
||||
messageAttachment.attachments.add(attachment)
|
||||
}
|
||||
}
|
||||
|
||||
return attachment
|
||||
return messageAttachment
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
import android.net.Uri
|
||||
|
||||
data class MessageAttachment(val id: Int, var text: String, var uri: Uri?, var type: String)
|
||||
data class MessageAttachment(val id: Int, var text: String, var attachments: ArrayList<Attachment>)
|
||||
|
|
|
@ -19,7 +19,7 @@ class MmsReceiver : com.klinker.android.send_message.MmsReceivedReceiver() {
|
|||
val glideBitmap = try {
|
||||
Glide.with(context)
|
||||
.asBitmap()
|
||||
.load(mms.attachment!!.uri)
|
||||
.load(mms.attachment!!.attachments.first().uri)
|
||||
.centerCrop()
|
||||
.into(size, size)
|
||||
.get()
|
||||
|
|
Loading…
Reference in New Issue