diff --git a/app/src/main/java/org/linphone/utils/DataBindingUtils.kt b/app/src/main/java/org/linphone/utils/DataBindingUtils.kt
index 6137289ec..1aa348258 100644
--- a/app/src/main/java/org/linphone/utils/DataBindingUtils.kt
+++ b/app/src/main/java/org/linphone/utils/DataBindingUtils.kt
@@ -52,6 +52,7 @@ import androidx.lifecycle.lifecycleScope
import coil.dispose
import coil.load
import coil.request.videoFrameMillis
+import coil.size.Dimension
import coil.transform.RoundedCornersTransformation
import com.google.android.material.imageview.ShapeableImageView
import kotlinx.coroutines.Dispatchers
@@ -218,20 +219,38 @@ fun ImageView.loadFileImage(file: String?) {
@UiThread
@BindingAdapter("coilBubble")
fun ImageView.loadImageForChatBubble(file: String?) {
+ loadImageForChatBubble(this, file, false)
+}
+
+@UiThread
+@BindingAdapter("coilBubbleGrid")
+fun ImageView.loadImageForChatBubbleGrid(file: String?) {
+ loadImageForChatBubble(this, file, true)
+}
+
+private fun loadImageForChatBubble(imageView: ImageView, file: String?, grid: Boolean) {
if (!file.isNullOrEmpty()) {
- val radius = context.resources.getDimension(
+ val dimen = if (grid) {
+ imageView.resources.getDimension(R.dimen.chat_bubble_grid_image_size).toInt()
+ } else {
+ imageView.resources.getDimension(R.dimen.chat_bubble_big_image_max_size).toInt()
+ }
+ val width = if (grid) Dimension(dimen) else Dimension.Undefined
+ val height = Dimension(dimen)
+ val radius = imageView.resources.getDimension(
R.dimen.chat_bubble_images_rounded_corner_radius
)
if (FileUtils.isExtensionVideo(file)) {
- load(file) {
+ imageView.load(file) {
videoFrameMillis(0)
transformations(RoundedCornersTransformation(radius))
+ size(width, height)
listener(
onError = { _, result ->
Log.e(
"[Data Binding] [Coil] Error getting preview picture from video? [$file]: ${result.throwable}"
)
- visibility = View.GONE
+ imageView.visibility = View.GONE
},
onSuccess = { _, _ ->
// TODO: Display "play" button above video preview
@@ -239,14 +258,15 @@ fun ImageView.loadImageForChatBubble(file: String?) {
)
}
} else {
- load(file) {
+ imageView.load(file) {
transformations(RoundedCornersTransformation(radius))
+ size(width, height)
listener(
onError = { _, result ->
Log.e(
"[Data Binding] [Coil] Error getting picture from file [$file]: ${result.throwable}"
)
- visibility = View.GONE
+ imageView.visibility = View.GONE
}
)
}
diff --git a/app/src/main/res/layout/chat_bubble_content.xml b/app/src/main/res/layout/chat_bubble_content.xml
deleted file mode 100644
index ede048154..000000000
--- a/app/src/main/res/layout/chat_bubble_content.xml
+++ /dev/null
@@ -1,76 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/layout/chat_bubble_content_grid_cell.xml b/app/src/main/res/layout/chat_bubble_content_grid_cell.xml
index 5024fef85..abf8b2f52 100644
--- a/app/src/main/res/layout/chat_bubble_content_grid_cell.xml
+++ b/app/src/main/res/layout/chat_bubble_content_grid_cell.xml
@@ -10,11 +10,11 @@
+ coilBubbleGrid="@{model.path}"/>
\ No newline at end of file
diff --git a/app/src/main/res/layout/chat_bubble_incoming.xml b/app/src/main/res/layout/chat_bubble_incoming.xml
index dc3004551..bb9d01de3 100644
--- a/app/src/main/res/layout/chat_bubble_incoming.xml
+++ b/app/src/main/res/layout/chat_bubble_incoming.xml
@@ -5,6 +5,7 @@
+
-
-
+ app:layout_constraintStart_toStartOf="@id/bubble" />
+ app:layout_constraintStart_toEndOf="@id/reply"
+ app:layout_constraintBottom_toTopOf="@id/bubble" />
+ app:layout_constraintStart_toStartOf="@id/bubble"
+ app:layout_constraintEnd_toEndOf="@id/bubble"
+ app:layout_constraintTop_toBottomOf="@id/name" />
-
-
-
-
-
+ app:layout_constraintStart_toEndOf="@id/avatar">
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/chat_bubble_outgoing.xml b/app/src/main/res/layout/chat_bubble_outgoing.xml
index e6509c1bc..cf0b750d8 100644
--- a/app/src/main/res/layout/chat_bubble_outgoing.xml
+++ b/app/src/main/res/layout/chat_bubble_outgoing.xml
@@ -5,6 +5,7 @@
+
-
-
-
-
+ app:layout_constraintStart_toEndOf="@id/reply"
+ app:layout_constraintBottom_toTopOf="@id/bubble" />
+ app:layout_constraintStart_toStartOf="@id/bubble"
+ app:layout_constraintEnd_toEndOf="@id/bubble"
+ app:layout_constraintTop_toTopOf="parent" />
-
-
-
+ app:layout_constraintEnd_toEndOf="parent">
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/values/dimen.xml b/app/src/main/res/values/dimen.xml
index b9d104870..d89cf515b 100644
--- a/app/src/main/res/values/dimen.xml
+++ b/app/src/main/res/values/dimen.xml
@@ -66,7 +66,9 @@
12dp
5dp
30sp
- 200dp
+ 88dp
+ 150dp
+ 291dp
5dp
10dp