try harder at opening unknown attachments, guess mimetype from filename
This commit is contained in:
parent
c4e7fc3068
commit
a40438a08c
1 changed files with 10 additions and 5 deletions
|
|
@ -228,7 +228,7 @@ class ThreadAdapter(
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.into(imageView.attachment_image)
|
builder.into(imageView.attachment_image)
|
||||||
imageView.attachment_image.setOnClickListener { launchViewIntent(uri, mimetype) }
|
imageView.attachment_image.setOnClickListener { launchViewIntent(uri, mimetype, attachment.filename) }
|
||||||
} else {
|
} else {
|
||||||
if (message.isReceivedMessage()) {
|
if (message.isReceivedMessage()) {
|
||||||
val attachmentView = layoutInflater.inflate(R.layout.item_received_unknown_attachment, null).apply {
|
val attachmentView = layoutInflater.inflate(R.layout.item_received_unknown_attachment, null).apply {
|
||||||
|
|
@ -237,7 +237,7 @@ class ThreadAdapter(
|
||||||
thread_received_attachment_label.text = attachment.filename
|
thread_received_attachment_label.text = attachment.filename
|
||||||
}
|
}
|
||||||
setTextColor(textColor)
|
setTextColor(textColor)
|
||||||
setOnClickListener { launchViewIntent(uri, mimetype) }
|
setOnClickListener { launchViewIntent(uri, mimetype, attachment.filename) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
thread_mesage_attachments_holder.addView(attachmentView)
|
thread_mesage_attachments_holder.addView(attachmentView)
|
||||||
|
|
@ -250,7 +250,7 @@ class ThreadAdapter(
|
||||||
if (attachment.filename.isNotEmpty()) {
|
if (attachment.filename.isNotEmpty()) {
|
||||||
thread_sent_attachment_label.text = attachment.filename
|
thread_sent_attachment_label.text = attachment.filename
|
||||||
}
|
}
|
||||||
setOnClickListener { launchViewIntent(uri, mimetype) }
|
setOnClickListener { launchViewIntent(uri, mimetype, attachment.filename) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
thread_mesage_attachments_holder.addView(attachmentView)
|
thread_mesage_attachments_holder.addView(attachmentView)
|
||||||
|
|
@ -263,7 +263,7 @@ class ThreadAdapter(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun launchViewIntent(uri: Uri, mimetype: String) {
|
private fun launchViewIntent(uri: Uri, mimetype: String, filename: String) {
|
||||||
Intent().apply {
|
Intent().apply {
|
||||||
action = Intent.ACTION_VIEW
|
action = Intent.ACTION_VIEW
|
||||||
setDataAndType(uri, mimetype)
|
setDataAndType(uri, mimetype)
|
||||||
|
|
@ -271,11 +271,16 @@ class ThreadAdapter(
|
||||||
|
|
||||||
if (resolveActivity(activity.packageManager) != null) {
|
if (resolveActivity(activity.packageManager) != null) {
|
||||||
activity.startActivity(this)
|
activity.startActivity(this)
|
||||||
|
} else {
|
||||||
|
val newMimetype = filename.getMimeType()
|
||||||
|
if (newMimetype.isNotEmpty() && mimetype != newMimetype) {
|
||||||
|
launchViewIntent(uri, newMimetype, filename)
|
||||||
} else {
|
} else {
|
||||||
activity.toast(R.string.no_app_found)
|
activity.toast(R.string.no_app_found)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun setupDateTime(view: View, dateTime: ThreadDateTime) {
|
private fun setupDateTime(view: View, dateTime: ThreadDateTime) {
|
||||||
view.apply {
|
view.apply {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue