mirror of
https://github.com/SimpleMobileTools/Simple-SMS-Messenger.git
synced 2025-01-11 07:43:59 +01:00
renaming attachment type onto mimetype
This commit is contained in:
parent
5c79ca361d
commit
ba8f14de3b
@ -89,13 +89,13 @@ class ThreadActivity : SimpleActivity() {
|
||||
messages.filter { it.attachment != null }.forEach {
|
||||
it.attachment!!.attachments.forEach {
|
||||
try {
|
||||
if (it.type.startsWith("image/")) {
|
||||
if (it.mimetype.startsWith("image/")) {
|
||||
val fileOptions = BitmapFactory.Options()
|
||||
fileOptions.inJustDecodeBounds = true
|
||||
BitmapFactory.decodeStream(contentResolver.openInputStream(it.uri), null, fileOptions)
|
||||
it.width = fileOptions.outWidth
|
||||
it.height = fileOptions.outHeight
|
||||
} else if (it.type.startsWith("video/")) {
|
||||
} else if (it.mimetype.startsWith("video/")) {
|
||||
val metaRetriever = MediaMetadataRetriever()
|
||||
metaRetriever.setDataSource(this, it.uri)
|
||||
it.width = metaRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH).toInt()
|
||||
|
@ -196,9 +196,9 @@ class ThreadAdapter(
|
||||
thread_mesage_attachments_holder.removeAllViews()
|
||||
if (message.attachment?.attachments?.isNotEmpty() == true) {
|
||||
for (attachment in message.attachment.attachments) {
|
||||
val type = attachment.type
|
||||
val mimetype = attachment.mimetype
|
||||
val uri = attachment.uri
|
||||
if (type.startsWith("image/") || type.startsWith("video/")) {
|
||||
if (mimetype.startsWith("image/") || mimetype.startsWith("video/")) {
|
||||
val imageView = layoutInflater.inflate(R.layout.item_attachment_image, null)
|
||||
thread_mesage_attachments_holder.addView(imageView)
|
||||
|
||||
@ -228,13 +228,13 @@ class ThreadAdapter(
|
||||
}
|
||||
|
||||
builder.into(imageView.attachment_image)
|
||||
imageView.attachment_image.setOnClickListener { launchViewIntent(uri, type) }
|
||||
imageView.attachment_image.setOnClickListener { launchViewIntent(uri, mimetype) }
|
||||
} else {
|
||||
if (message.isReceivedMessage()) {
|
||||
val attachmentView = layoutInflater.inflate(R.layout.item_received_unknown_attachment, null).apply {
|
||||
thread_received_attachment_label.apply {
|
||||
setTextColor(textColor)
|
||||
setOnClickListener { launchViewIntent(uri, type) }
|
||||
setOnClickListener { launchViewIntent(uri, mimetype) }
|
||||
}
|
||||
}
|
||||
thread_mesage_attachments_holder.addView(attachmentView)
|
||||
@ -244,23 +244,23 @@ class ThreadAdapter(
|
||||
thread_sent_attachment_label.apply {
|
||||
this.background.applyColorFilter(background.adjustAlpha(0.8f))
|
||||
setTextColor(background.getContrastColor())
|
||||
setOnClickListener { launchViewIntent(uri, type) }
|
||||
setOnClickListener { launchViewIntent(uri, mimetype) }
|
||||
}
|
||||
}
|
||||
thread_mesage_attachments_holder.addView(attachmentView)
|
||||
}
|
||||
}
|
||||
|
||||
thread_message_play_outline.beVisibleIf(type.startsWith("video/"))
|
||||
thread_message_play_outline.beVisibleIf(mimetype.startsWith("video/"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun launchViewIntent(uri: Uri, type: String) {
|
||||
private fun launchViewIntent(uri: Uri, mimetype: String) {
|
||||
Intent().apply {
|
||||
action = Intent.ACTION_VIEW
|
||||
setDataAndType(uri, type)
|
||||
setDataAndType(uri, mimetype)
|
||||
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
|
||||
|
||||
if (resolveActivity(activity.packageManager) != null) {
|
||||
|
@ -224,14 +224,14 @@ fun Context.getMmsAttachment(id: Int): MessageAttachment? {
|
||||
|
||||
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") {
|
||||
val mimetype = cursor.getStringValue(Mms.Part.CONTENT_TYPE)
|
||||
if (mimetype == "text/plain") {
|
||||
messageAttachment.text = cursor.getStringValue(Mms.Part.TEXT) ?: ""
|
||||
} else if (type.startsWith("image/") || type.startsWith("video/")) {
|
||||
val attachment = Attachment(Uri.withAppendedPath(uri, partId), type, 0, 0)
|
||||
} else if (mimetype.startsWith("image/") || mimetype.startsWith("video/")) {
|
||||
val attachment = Attachment(Uri.withAppendedPath(uri, partId), mimetype, 0, 0)
|
||||
messageAttachment.attachments.add(attachment)
|
||||
} else if (type != "application/smil") {
|
||||
val attachment = Attachment(Uri.withAppendedPath(uri, partId), type, 0, 0)
|
||||
} else if (mimetype != "application/smil") {
|
||||
val attachment = Attachment(Uri.withAppendedPath(uri, partId), mimetype, 0, 0)
|
||||
messageAttachment.attachments.add(attachment)
|
||||
}
|
||||
}
|
||||
|
@ -2,4 +2,4 @@ package com.simplemobiletools.smsmessenger.models
|
||||
|
||||
import android.net.Uri
|
||||
|
||||
data class Attachment(var uri: Uri, var type: String, var width: Int, var height: Int)
|
||||
data class Attachment(var uri: Uri, var mimetype: String, var width: Int, var height: Int)
|
||||
|
Loading…
Reference in New Issue
Block a user