Started to display incoming messages reply to message

This commit is contained in:
Sylvain Berfini 2023-10-24 15:02:54 +02:00
parent 077e625512
commit 58c30a638f
10 changed files with 58 additions and 9 deletions

View file

@ -37,6 +37,8 @@ class ChatMessageModel @WorkerThread constructor(
val chatMessage: ChatMessage,
val avatarModel: ContactAvatarModel,
val isFromGroup: Boolean,
val isReply: Boolean,
val replyText: String,
val isGroupedWithPreviousOne: Boolean,
val isGroupedWithNextOne: Boolean
) {

View file

@ -21,7 +21,9 @@ package org.linphone.ui.main.chat.model
import androidx.annotation.WorkerThread
import org.linphone.core.EventLog
import org.linphone.core.tools.Log
import org.linphone.ui.main.contacts.model.ContactAvatarModel
import org.linphone.utils.LinphoneUtils
class EventLogModel @WorkerThread constructor(
val eventLog: EventLog,
@ -30,6 +32,10 @@ class EventLogModel @WorkerThread constructor(
isGroupedWithPreviousOne: Boolean,
isGroupedWithNextOne: Boolean
) {
companion object {
private const val TAG = "[Event Log Model]"
}
val type: EventLog.Type = eventLog.type
val isEvent = type != EventLog.Type.ConferenceChatMessage
@ -37,10 +43,27 @@ class EventLogModel @WorkerThread constructor(
val model = if (isEvent) {
EventModel(eventLog)
} else {
val chatMessage = eventLog.chatMessage!!
val reply = if (chatMessage.isReply) {
val replyMessage = chatMessage.replyMessage
if (replyMessage != null) {
LinphoneUtils.getTextDescribingMessage(replyMessage)
} else {
Log.e(
"$TAG Failed to find the reply message from ID [${chatMessage.replyMessageId}]"
)
"<?>"
}
} else {
""
}
ChatMessageModel(
eventLog.chatMessage!!,
chatMessage,
avatarModel,
isFromGroup,
chatMessage.isReply,
reply,
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:bottomRightRadius="16dp" android:bottomLeftRadius="16dp" />
<solid android:color="@color/gray_main2_100"/>
<solid android:color="@color/gray_100"/>
</shape>

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:radius="16dp" />
<solid android:color="@color/gray_main2_100"/>
<solid android:color="@color/gray_100"/>
</shape>

View file

@ -0,0 +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" />
<solid android:color="@color/gray_200"/>
</shape>

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:topLeftRadius="16dp" android:topRightRadius="16dp" android:bottomLeftRadius="16dp" />
<solid android:color="@color/orange_main_100"/>
<solid android:color="@color/gray_main2_100"/>
</shape>

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:radius="16dp" />
<solid android:color="@color/orange_main_100"/>
<solid android:color="@color/gray_main2_100"/>
</shape>

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners android:radius="20dp" />
<solid android:color="@color/gray_main2_100"/>
<solid android:color="@color/gray_100"/>
<stroke android:color="@color/white" android:width="2dp" />
</shape>

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners android:radius="20dp" />
<solid android:color="@color/orange_main_100"/>
<solid android:color="@color/gray_main2_100"/>
<stroke android:color="@color/white" android:width="2dp" />
</shape>

View file

@ -63,8 +63,27 @@
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_constraintStart_toStartOf="@id/background" />
<androidx.appcompat.widget.AppCompatTextView
style="@style/default_text_style"
android:id="@+id/reply"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:text="@{model.replyText, default=`Ceci est une réponse!`}"
android:textColor="@color/gray_main2_400"
android:textSize="14sp"
android:padding="10dp"
android:background="@drawable/shape_chat_bubble_incoming_reply"
android:visibility="@{model.isReply ? View.VISIBLE : View.GONE, default=gone}"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintStart_toStartOf="@id/background"
app:layout_constraintEnd_toEndOf="@id/background"
app:layout_constraintTop_toBottomOf="@id/name"
app:layout_constraintBottom_toTopOf="@id/background"/>
<androidx.constraintlayout.widget.Barrier
android:id="@+id/background_end_barrier"
android:layout_width="wrap_content"
@ -81,7 +100,7 @@
android:src="@{model.isGroupedWithPreviousOne ? @drawable/shape_chat_bubble_incoming_full : @drawable/shape_chat_bubble_incoming_first, default=@drawable/shape_chat_bubble_incoming_first}"
app:layout_constraintStart_toEndOf="@id/avatar"
app:layout_constraintEnd_toEndOf="@id/background_end_barrier"
app:layout_constraintTop_toTopOf="@id/avatar"
app:layout_constraintTop_toBottomOf="@id/reply"
app:layout_constraintBottom_toBottomOf="@id/date_time"/>
<androidx.appcompat.widget.AppCompatTextView
@ -99,7 +118,7 @@
android:gravity="center_vertical|start"
app:layout_constrainedWidth="true"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintTop_toTopOf="@id/avatar"
app:layout_constraintTop_toBottomOf="@id/reply"
app:layout_constraintStart_toEndOf="@id/avatar"
app:layout_constraintEnd_toEndOf="parent"/>