display mms attachments at the conversations

This commit is contained in:
tibbi 2020-04-09 10:52:14 +02:00
parent 500f2bc8fe
commit d0b4e17300
3 changed files with 45 additions and 5 deletions

View File

@ -3,6 +3,12 @@ package com.simplemobiletools.smsmessenger.adapters
import android.view.Menu
import android.view.View
import android.view.ViewGroup
import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.load.resource.bitmap.FitCenter
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
import com.bumptech.glide.request.RequestOptions
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
import com.simplemobiletools.commons.extensions.*
@ -27,6 +33,8 @@ class ThreadAdapter(
itemClick: (Any) -> Unit
) : MyRecyclerViewAdapter(activity, recyclerView, fastScroller, itemClick) {
private val roundedCornersRadius = resources.getDimension(R.dimen.normal_margin).toInt()
init {
setupDragListener(true)
}
@ -158,9 +166,23 @@ class ThreadAdapter(
thread_message_body.setTextColor(textColor)
} else {
val background = context.getAdjustedPrimaryColor()
thread_message_wrapper.background.applyColorFilter(background.adjustAlpha(0.8f))
thread_message_body.background.applyColorFilter(background.adjustAlpha(0.8f))
thread_message_body.setTextColor(background.getContrastColor())
}
if (message.attachment != null) {
if (message.attachment.type.startsWith("image/")) {
val options = RequestOptions()
.diskCacheStrategy(DiskCacheStrategy.NONE)
.transform(FitCenter(), RoundedCorners(roundedCornersRadius))
Glide.with(context)
.load(message.attachment.uri)
.transition(DrawableTransitionOptions.withCrossFade())
.apply(options)
.into(thread_message_image)
}
}
}
}

View File

@ -12,17 +12,26 @@
android:id="@+id/thread_message_wrapper"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@drawable/item_received_background"
android:padding="@dimen/activity_margin"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintWidth_percent="0.7">
<ImageView
android:id="@+id/thread_message_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/medium_margin"
android:adjustViewBounds="true" />
<TextView
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_alignParentStart="true"
android:background="@drawable/item_received_background"
android:padding="@dimen/activity_margin"
android:textSize="@dimen/normal_text_size"
tools:text="Received message" />
</RelativeLayout>

View File

@ -12,17 +12,26 @@
android:id="@+id/thread_message_wrapper"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@drawable/item_sent_background"
android:padding="@dimen/activity_margin"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintWidth_percent="0.7">
<ImageView
android:id="@+id/thread_message_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/medium_margin"
android:adjustViewBounds="true" />
<TextView
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_alignParentEnd="true"
android:background="@drawable/item_sent_background"
android:padding="@dimen/activity_margin"
android:textSize="@dimen/normal_text_size"
tools:text="Sent message" />
</RelativeLayout>