add handling for multiple attachments in one mms
This commit is contained in:
parent
a5d8633593
commit
cc6dcafa88
|
@ -30,6 +30,7 @@ import com.simplemobiletools.smsmessenger.models.Message
|
|||
import com.simplemobiletools.smsmessenger.models.ThreadDateTime
|
||||
import com.simplemobiletools.smsmessenger.models.ThreadError
|
||||
import com.simplemobiletools.smsmessenger.models.ThreadItem
|
||||
import kotlinx.android.synthetic.main.item_attachment_image.view.*
|
||||
import kotlinx.android.synthetic.main.item_received_message.view.*
|
||||
import kotlinx.android.synthetic.main.item_thread_date_time.view.*
|
||||
|
||||
|
@ -187,8 +188,13 @@ class ThreadAdapter(
|
|||
thread_message_body.setTextColor(background.getContrastColor())
|
||||
}
|
||||
|
||||
thread_mesage_attachments_holder.removeAllViews()
|
||||
if (message.attachment?.attachments?.isNotEmpty() == true) {
|
||||
val attachment = message.attachment.attachments.first()
|
||||
message.attachment.attachments.forEach {
|
||||
val attachment = it
|
||||
val imageView = layoutInflater.inflate(R.layout.item_attachment_image, null)
|
||||
thread_mesage_attachments_holder.addView(imageView)
|
||||
|
||||
val type = attachment.type
|
||||
if (type.startsWith("image/") || type.startsWith("video/")) {
|
||||
val uri = attachment.uri
|
||||
|
@ -203,15 +209,17 @@ class ThreadAdapter(
|
|||
.listener(object : RequestListener<Drawable> {
|
||||
override fun onLoadFailed(e: GlideException?, model: Any?, target: Target<Drawable>?, isFirstResource: Boolean): Boolean {
|
||||
thread_message_play_outline.beGone()
|
||||
thread_mesage_attachments_holder.removeView(imageView)
|
||||
return false
|
||||
}
|
||||
|
||||
override fun onResourceReady(dr: Drawable?, a: Any?, t: Target<Drawable>?, d: DataSource?, i: Boolean) = false
|
||||
override fun onResourceReady(dr: Drawable?, a: Any?, t: Target<Drawable>?, d: DataSource?, i: Boolean) =
|
||||
false
|
||||
|
||||
})
|
||||
.into(thread_message_image)
|
||||
.into(imageView.attachment_image)
|
||||
|
||||
thread_message_image.setOnClickListener {
|
||||
attachment_image.setOnClickListener {
|
||||
Intent().apply {
|
||||
action = Intent.ACTION_VIEW
|
||||
setDataAndType(uri, type)
|
||||
|
@ -225,6 +233,7 @@ class ThreadAdapter(
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupDateTime(view: View, dateTime: ThreadDateTime) {
|
||||
view.apply {
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/attachment_image"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:adjustViewBounds="true"
|
||||
android:paddingBottom="@dimen/medium_margin" />
|
|
@ -26,13 +26,11 @@
|
|||
android:layout_marginEnd="@dimen/medium_margin"
|
||||
android:visibility="gone" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/thread_message_image"
|
||||
<LinearLayout
|
||||
android:id="@+id/thread_mesage_attachments_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/medium_margin"
|
||||
android:layout_toEndOf="@+id/thread_message_photo"
|
||||
android:adjustViewBounds="true" />
|
||||
android:orientation="vertical" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/thread_message_play_outline"
|
||||
|
|
|
@ -17,19 +17,18 @@
|
|||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintWidth_percent="0.7">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/thread_message_image"
|
||||
<LinearLayout
|
||||
android:id="@+id/thread_mesage_attachments_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/medium_margin"
|
||||
android:adjustViewBounds="true" />
|
||||
android:orientation="vertical" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/thread_message_play_outline"
|
||||
android:layout_width="@dimen/play_outline_size"
|
||||
android:layout_height="@dimen/play_outline_size"
|
||||
android:layout_alignEnd="@+id/thread_message_image"
|
||||
android:layout_alignBottom="@+id/thread_message_image"
|
||||
android:layout_alignEnd="@+id/thread_mesage_attachments_holder"
|
||||
android:layout_alignBottom="@+id/thread_mesage_attachments_holder"
|
||||
android:layout_margin="@dimen/medium_margin"
|
||||
android:src="@drawable/ic_play_outline"
|
||||
android:visibility="gone" />
|
||||
|
@ -38,7 +37,7 @@
|
|||
android:id="@+id/thread_message_body"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/thread_message_image"
|
||||
android:layout_below="@+id/thread_mesage_attachments_holder"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:background="@drawable/item_sent_background"
|
||||
android:padding="@dimen/normal_margin"
|
||||
|
|
Loading…
Reference in New Issue