Improved reply layout

This commit is contained in:
Sylvain Berfini 2023-11-08 12:21:37 +01:00
parent cd3b9e1422
commit e61a6a0b7f
6 changed files with 93 additions and 23 deletions

View file

@ -48,6 +48,7 @@ class ChatMessageModel @WorkerThread constructor(
val avatarModel: ContactAvatarModel,
val isFromGroup: Boolean,
val isReply: Boolean,
val replyTo: String,
val replyText: String,
val replyToMessageId: String?,
val isGroupedWithPreviousOne: Boolean,

View file

@ -20,6 +20,7 @@
package org.linphone.ui.main.chat.model
import androidx.annotation.WorkerThread
import org.linphone.LinphoneApplication.Companion.coreContext
import org.linphone.core.EventLog
import org.linphone.core.tools.Log
import org.linphone.ui.main.contacts.model.ContactAvatarModel
@ -46,9 +47,15 @@ class EventLogModel @WorkerThread constructor(
EventModel(eventLog)
} else {
val chatMessage = eventLog.chatMessage!!
val reply = if (chatMessage.isReply) {
var replyTo = ""
val replyText = if (chatMessage.isReply) {
val replyMessage = chatMessage.replyMessage
if (replyMessage != null) {
val from = replyMessage.fromAddress
replyTo = coreContext.contactsManager.findContactByAddress(from)?.name ?: LinphoneUtils.getDisplayName(
from
)
LinphoneUtils.getTextDescribingMessage(replyMessage)
} else {
Log.e(
@ -65,7 +72,8 @@ class EventLogModel @WorkerThread constructor(
avatarModel,
isFromGroup,
chatMessage.isReply,
reply,
replyTo,
replyText,
chatMessage.replyMessageId,
isGroupedWithPreviousOne,
isGroupedWithNextOne,

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners android:topRightRadius="16dp" android:topLeftRadius="16dp" />
<corners android:radius="16dp" />
<solid android:color="@color/gray_200"/>
</shape>

View file

@ -67,38 +67,68 @@
android:ellipsize="end"
android:visibility="@{!model.isFromGroup ? View.GONE: model.isGroupedWithPreviousOne ? View.GONE : View.VISIBLE}"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/reply"
app:layout_constraintBottom_toTopOf="@id/reply_icon"
app:layout_constraintStart_toStartOf="@id/bubble" />
<androidx.constraintlayout.widget.Group
android:id="@+id/reply_group"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="@{model.isReply ? View.VISIBLE : View.GONE, default=gone}"
app:constraint_referenced_ids="reply, reply_background, reply_name, reply_icon"/>
<androidx.appcompat.widget.AppCompatTextView
style="@style/default_text_style_300"
android:id="@+id/reply_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:text="@{model.replyTo, default=`John Doe`}"
android:textSize="12sp"
android:textColor="@color/gray_main2_500"
app:drawableTint="@color/gray_main2_500"
app:layout_constraintStart_toEndOf="@id/reply_icon"
app:layout_constraintTop_toBottomOf="@id/name"
app:layout_constraintBottom_toTopOf="@id/reply" />
<ImageView
android:id="@+id/reply_icon"
android:layout_width="@dimen/small_icon_size"
android:layout_height="@dimen/small_icon_size"
android:layout_marginStart="8dp"
android:src="@drawable/reply"
android:visibility="@{model.isReply ? View.VISIBLE : View.GONE, default=gone}"
app:tint="@color/gray_main2_500"
app:layout_constraintStart_toEndOf="@id/reply"
app:layout_constraintBottom_toTopOf="@id/bubble" />
app:layout_constraintStart_toStartOf="@id/reply"
app:layout_constraintTop_toTopOf="@id/reply_name"
app:layout_constraintBottom_toBottomOf="@id/reply_name" />
<View
android:id="@+id/reply_background"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="-20dp"
android:background="@drawable/shape_chat_bubble_reply"
app:layout_constraintTop_toTopOf="@id/reply"
app:layout_constraintStart_toStartOf="@id/reply"
app:layout_constraintEnd_toEndOf="@id/reply"
app:layout_constraintBottom_toTopOf="@id/bubble"/>
<androidx.appcompat.widget.AppCompatTextView
style="@style/default_text_style"
android:id="@+id/reply"
android:onClick="@{scrollToRepliedMessageClickListener}"
android:background="@drawable/shape_chat_bubble_reply"
android:layout_width="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginEnd="32dp"
android:text="@{model.replyText, default=`Reply`}"
android:textColor="@color/gray_main2_500"
android:textSize="14sp"
android:maxLines="2"
android:ellipsize="end"
android:padding="10dp"
android:visibility="@{model.isReply ? View.VISIBLE : View.GONE, default=gone}"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintWidth_max="@dimen/chat_bubble_max_reply_width"
app:layout_constraintStart_toStartOf="@id/bubble"
app:layout_constraintEnd_toEndOf="@id/bubble"
app:layout_constraintTop_toBottomOf="@id/name" />
app:layout_constraintTop_toBottomOf="@id/reply_name" />
<LinearLayout
android:id="@+id/bubble"

View file

@ -33,35 +33,65 @@
android:layout_marginEnd="8dp"
android:layout_marginTop="@{model.isGroupedWithPreviousOne ? @dimen/chat_bubble_grouped_top_margin : @dimen/chat_bubble_top_margin, default=@dimen/chat_bubble_top_margin}">
<androidx.constraintlayout.widget.Group
android:id="@+id/reply_group"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="@{model.isReply ? View.VISIBLE : View.GONE, default=gone}"
app:constraint_referenced_ids="reply, reply_background, reply_name, reply_icon"/>
<androidx.appcompat.widget.AppCompatTextView
style="@style/default_text_style_300"
android:id="@+id/reply_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:text="@{model.replyTo, default=`John Doe`}"
android:textSize="12sp"
android:textColor="@color/gray_main2_500"
app:drawableTint="@color/gray_main2_500"
app:layout_constraintEnd_toEndOf="@id/reply"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/reply" />
<ImageView
android:id="@+id/reply_icon"
android:layout_width="@dimen/small_icon_size"
android:layout_height="@dimen/small_icon_size"
android:layout_marginEnd="8dp"
android:src="@drawable/reply"
android:visibility="@{model.isReply ? View.VISIBLE : View.GONE, default=gone}"
app:tint="@color/gray_main2_500"
app:layout_constraintStart_toEndOf="@id/reply"
app:layout_constraintBottom_toTopOf="@id/bubble" />
app:layout_constraintEnd_toStartOf="@id/reply_name"
app:layout_constraintTop_toTopOf="@id/reply_name"
app:layout_constraintBottom_toBottomOf="@id/reply_name" />
<View
android:id="@+id/reply_background"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="-20dp"
android:background="@drawable/shape_chat_bubble_reply"
app:layout_constraintTop_toTopOf="@id/reply"
app:layout_constraintStart_toStartOf="@id/reply"
app:layout_constraintEnd_toEndOf="@id/reply"
app:layout_constraintBottom_toTopOf="@id/bubble"/>
<androidx.appcompat.widget.AppCompatTextView
style="@style/default_text_style"
android:onClick="@{scrollToRepliedMessageClickListener}"
android:id="@+id/reply"
android:layout_width="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:background="@drawable/shape_chat_bubble_reply"
android:text="@{model.replyText, default=`Reply`}"
android:textColor="@color/gray_main2_500"
android:textSize="14sp"
android:maxLines="2"
android:ellipsize="end"
android:padding="10dp"
android:visibility="@{model.isReply ? View.VISIBLE : View.GONE, default=gone}"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintStart_toStartOf="@id/bubble"
app:layout_constraintWidth_max="@dimen/chat_bubble_max_reply_width"
app:layout_constraintEnd_toEndOf="@id/bubble"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toBottomOf="@id/reply_name" />
<LinearLayout
android:id="@+id/bubble"

View file

@ -69,6 +69,7 @@
<dimen name="chat_bubble_grid_image_size">88dp</dimen>
<dimen name="chat_bubble_big_image_max_size">150dp</dimen>
<dimen name="chat_bubble_meeting_invite_width">271dp</dimen>
<dimen name="chat_bubble_max_reply_width">271dp</dimen>
<dimen name="chat_bubble_max_width">291dp</dimen>
<dimen name="chat_bubble_images_rounded_corner_radius">5dp</dimen>
<dimen name="chat_bubble_start_margin_when_avatar_displayed">10dp</dimen>