mirror of
https://github.com/SimpleMobileTools/Simple-SMS-Messenger.git
synced 2025-02-17 04:00:35 +01:00
store attachment uri as a string
This commit is contained in:
parent
ceb9896988
commit
4cad413478
@ -146,12 +146,12 @@ class ThreadActivity : SimpleActivity() {
|
|||||||
if (it.mimetype.startsWith("image/")) {
|
if (it.mimetype.startsWith("image/")) {
|
||||||
val fileOptions = BitmapFactory.Options()
|
val fileOptions = BitmapFactory.Options()
|
||||||
fileOptions.inJustDecodeBounds = true
|
fileOptions.inJustDecodeBounds = true
|
||||||
BitmapFactory.decodeStream(contentResolver.openInputStream(it.uri), null, fileOptions)
|
BitmapFactory.decodeStream(contentResolver.openInputStream(it.getUri()), null, fileOptions)
|
||||||
it.width = fileOptions.outWidth
|
it.width = fileOptions.outWidth
|
||||||
it.height = fileOptions.outHeight
|
it.height = fileOptions.outHeight
|
||||||
} else if (it.mimetype.startsWith("video/")) {
|
} else if (it.mimetype.startsWith("video/")) {
|
||||||
val metaRetriever = MediaMetadataRetriever()
|
val metaRetriever = MediaMetadataRetriever()
|
||||||
metaRetriever.setDataSource(this, it.uri)
|
metaRetriever.setDataSource(this, it.getUri())
|
||||||
it.width = metaRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH)!!.toInt()
|
it.width = metaRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH)!!.toInt()
|
||||||
it.height = metaRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT)!!.toInt()
|
it.height = metaRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT)!!.toInt()
|
||||||
}
|
}
|
||||||
|
@ -225,7 +225,7 @@ class ThreadAdapter(activity: SimpleActivity, var messages: ArrayList<ThreadItem
|
|||||||
if (message.attachment?.attachments?.isNotEmpty() == true) {
|
if (message.attachment?.attachments?.isNotEmpty() == true) {
|
||||||
for (attachment in message.attachment.attachments) {
|
for (attachment in message.attachment.attachments) {
|
||||||
val mimetype = attachment.mimetype
|
val mimetype = attachment.mimetype
|
||||||
val uri = attachment.uri
|
val uri = attachment.getUri()
|
||||||
if (mimetype.startsWith("image/") || mimetype.startsWith("video/")) {
|
if (mimetype.startsWith("image/") || mimetype.startsWith("video/")) {
|
||||||
val imageView = layoutInflater.inflate(R.layout.item_attachment_image, null)
|
val imageView = layoutInflater.inflate(R.layout.item_attachment_image, null)
|
||||||
thread_mesage_attachments_holder.addView(imageView)
|
thread_mesage_attachments_holder.addView(imageView)
|
||||||
|
@ -262,10 +262,10 @@ fun Context.getMmsAttachment(id: Long): MessageAttachment {
|
|||||||
if (mimetype == "text/plain") {
|
if (mimetype == "text/plain") {
|
||||||
messageAttachment.text = cursor.getStringValue(Mms.Part.TEXT) ?: ""
|
messageAttachment.text = cursor.getStringValue(Mms.Part.TEXT) ?: ""
|
||||||
} else if (mimetype.startsWith("image/") || mimetype.startsWith("video/")) {
|
} else if (mimetype.startsWith("image/") || mimetype.startsWith("video/")) {
|
||||||
val attachment = Attachment(Uri.withAppendedPath(uri, partId), mimetype, 0, 0, "")
|
val attachment = Attachment(Uri.withAppendedPath(uri, partId).toString(), mimetype, 0, 0, "")
|
||||||
messageAttachment.attachments.add(attachment)
|
messageAttachment.attachments.add(attachment)
|
||||||
} else if (mimetype != "application/smil") {
|
} else if (mimetype != "application/smil") {
|
||||||
val attachment = Attachment(Uri.withAppendedPath(uri, partId), mimetype, 0, 0, attachmentName)
|
val attachment = Attachment(Uri.withAppendedPath(uri, partId).toString(), mimetype, 0, 0, attachmentName)
|
||||||
messageAttachment.attachments.add(attachment)
|
messageAttachment.attachments.add(attachment)
|
||||||
} else {
|
} else {
|
||||||
val text = cursor.getStringValue(Mms.Part.TEXT)
|
val text = cursor.getStringValue(Mms.Part.TEXT)
|
||||||
|
@ -2,4 +2,6 @@ package com.simplemobiletools.smsmessenger.models
|
|||||||
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
|
|
||||||
data class Attachment(var uri: Uri, var mimetype: String, var width: Int, var height: Int, var filename: String)
|
data class Attachment(var uriString: String, var mimetype: String, var width: Int, var height: Int, var filename: String) {
|
||||||
|
fun getUri() = Uri.parse(uriString)
|
||||||
|
}
|
||||||
|
@ -24,7 +24,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!!.attachments.first().uri)
|
.load(mms.attachment!!.attachments.first().getUri())
|
||||||
.centerCrop()
|
.centerCrop()
|
||||||
.into(size, size)
|
.into(size, size)
|
||||||
.get()
|
.get()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user