show the unknown attachment filename, if available
This commit is contained in:
parent
ba8f14de3b
commit
c4e7fc3068
|
@ -233,6 +233,9 @@ class ThreadAdapter(
|
|||
if (message.isReceivedMessage()) {
|
||||
val attachmentView = layoutInflater.inflate(R.layout.item_received_unknown_attachment, null).apply {
|
||||
thread_received_attachment_label.apply {
|
||||
if (attachment.filename.isNotEmpty()) {
|
||||
thread_received_attachment_label.text = attachment.filename
|
||||
}
|
||||
setTextColor(textColor)
|
||||
setOnClickListener { launchViewIntent(uri, mimetype) }
|
||||
}
|
||||
|
@ -244,6 +247,9 @@ class ThreadAdapter(
|
|||
thread_sent_attachment_label.apply {
|
||||
this.background.applyColorFilter(background.adjustAlpha(0.8f))
|
||||
setTextColor(background.getContrastColor())
|
||||
if (attachment.filename.isNotEmpty()) {
|
||||
thread_sent_attachment_label.text = attachment.filename
|
||||
}
|
||||
setOnClickListener { launchViewIntent(uri, mimetype) }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -222,17 +222,24 @@ fun Context.getMmsAttachment(id: Int): MessageAttachment? {
|
|||
val selectionArgs = arrayOf(id.toString())
|
||||
val messageAttachment = MessageAttachment(id, "", arrayListOf())
|
||||
|
||||
var attachmentName = ""
|
||||
queryCursor(uri, projection, selection, selectionArgs, showErrors = true) { cursor ->
|
||||
val partId = cursor.getStringValue(Mms._ID)
|
||||
val mimetype = cursor.getStringValue(Mms.Part.CONTENT_TYPE)
|
||||
if (mimetype == "text/plain") {
|
||||
messageAttachment.text = cursor.getStringValue(Mms.Part.TEXT) ?: ""
|
||||
} 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), mimetype, 0, 0, "")
|
||||
messageAttachment.attachments.add(attachment)
|
||||
} else if (mimetype != "application/smil") {
|
||||
val attachment = Attachment(Uri.withAppendedPath(uri, partId), mimetype, 0, 0)
|
||||
val attachment = Attachment(Uri.withAppendedPath(uri, partId), mimetype, 0, 0, attachmentName)
|
||||
messageAttachment.attachments.add(attachment)
|
||||
} else {
|
||||
val text = cursor.getStringValue(Mms.Part.TEXT)
|
||||
val cutName = text.substringAfter("ref src=\"").substringBefore("\"")
|
||||
if (cutName.isNotEmpty()) {
|
||||
attachmentName = cutName
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,4 +2,4 @@ package com.simplemobiletools.smsmessenger.models
|
|||
|
||||
import android.net.Uri
|
||||
|
||||
data class Attachment(var uri: Uri, var mimetype: String, var width: Int, var height: Int)
|
||||
data class Attachment(var uri: Uri, var mimetype: String, var width: Int, var height: Int, var filename: String)
|
||||
|
|
Loading…
Reference in New Issue