mirror of
https://github.com/SimpleMobileTools/Simple-SMS-Messenger.git
synced 2025-06-05 21:49:22 +02:00
display mms attachments at the conversations
This commit is contained in:
@@ -3,6 +3,12 @@ package com.simplemobiletools.smsmessenger.adapters
|
|||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
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.adapters.MyRecyclerViewAdapter
|
||||||
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
@@ -27,6 +33,8 @@ class ThreadAdapter(
|
|||||||
itemClick: (Any) -> Unit
|
itemClick: (Any) -> Unit
|
||||||
) : MyRecyclerViewAdapter(activity, recyclerView, fastScroller, itemClick) {
|
) : MyRecyclerViewAdapter(activity, recyclerView, fastScroller, itemClick) {
|
||||||
|
|
||||||
|
private val roundedCornersRadius = resources.getDimension(R.dimen.normal_margin).toInt()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
setupDragListener(true)
|
setupDragListener(true)
|
||||||
}
|
}
|
||||||
@@ -158,9 +166,23 @@ class ThreadAdapter(
|
|||||||
thread_message_body.setTextColor(textColor)
|
thread_message_body.setTextColor(textColor)
|
||||||
} else {
|
} else {
|
||||||
val background = context.getAdjustedPrimaryColor()
|
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())
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -12,17 +12,26 @@
|
|||||||
android:id="@+id/thread_message_wrapper"
|
android:id="@+id/thread_message_wrapper"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@drawable/item_received_background"
|
|
||||||
android:padding="@dimen/activity_margin"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:layout_constraintWidth_percent="0.7">
|
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
|
<TextView
|
||||||
android:id="@+id/thread_message_body"
|
android:id="@+id/thread_message_body"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="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"
|
android:textSize="@dimen/normal_text_size"
|
||||||
tools:text="Received message" />
|
tools:text="Received message" />
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
@@ -12,17 +12,26 @@
|
|||||||
android:id="@+id/thread_message_wrapper"
|
android:id="@+id/thread_message_wrapper"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@drawable/item_sent_background"
|
|
||||||
android:padding="@dimen/activity_margin"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:layout_constraintWidth_percent="0.7">
|
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
|
<TextView
|
||||||
android:id="@+id/thread_message_body"
|
android:id="@+id/thread_message_body"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="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"
|
android:textSize="@dimen/normal_text_size"
|
||||||
tools:text="Sent message" />
|
tools:text="Sent message" />
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
Reference in New Issue
Block a user