mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Simple reactions to chat message display
This commit is contained in:
parent
f821707cc6
commit
b9e4fcf1a6
2 changed files with 40 additions and 1 deletions
|
|
@ -58,6 +58,8 @@ class ChatMessageModel @WorkerThread constructor(
|
|||
|
||||
val chatRoomIsReadOnly = chatMessage.chatRoom.isReadOnly
|
||||
|
||||
val reactions = MutableLiveData<String>()
|
||||
|
||||
val dismissLongPressMenuEvent: MutableLiveData<Event<Boolean>> by lazy {
|
||||
MutableLiveData<Event<Boolean>>()
|
||||
}
|
||||
|
|
@ -73,17 +75,20 @@ class ChatMessageModel @WorkerThread constructor(
|
|||
Log.i(
|
||||
"$TAG New reaction [${reaction.body}] from [${reaction.fromAddress.asStringUriOnly()}] for chat message with ID [$id]"
|
||||
)
|
||||
updateReactionsList()
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
override fun onReactionRemoved(message: ChatMessage, address: Address) {
|
||||
Log.i("$TAG A reaction was removed for chat message with ID [$id]")
|
||||
updateReactionsList()
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
chatMessage.addListener(chatMessageListener)
|
||||
statusIcon.postValue(LinphoneUtils.getChatIconResId(chatMessage.state))
|
||||
updateReactionsList()
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
|
|
@ -100,4 +105,20 @@ class ChatMessageModel @WorkerThread constructor(
|
|||
dismissLongPressMenuEvent.postValue(Event(true))
|
||||
}
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
private fun updateReactionsList() {
|
||||
var reactionsList = ""
|
||||
val allReactions = chatMessage.reactions
|
||||
|
||||
if (allReactions.isNotEmpty()) {
|
||||
for (reaction in allReactions) {
|
||||
val body = reaction.body
|
||||
reactionsList += body
|
||||
}
|
||||
}
|
||||
|
||||
Log.i("$TAG Reactions for message [$id] are [$reactionsList]")
|
||||
reactions.postValue(reactionsList)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@
|
|||
app:layout_constraintStart_toEndOf="@id/avatar"
|
||||
app:layout_constraintEnd_toEndOf="@id/background_end_barrier"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"/>
|
||||
app:layout_constraintBottom_toBottomOf="@id/date_time"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/default_text_style"
|
||||
|
|
@ -114,6 +114,24 @@
|
|||
app:layout_constraintBottom_toBottomOf="@id/date_time"
|
||||
app:tint="@color/orange_main_500" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/reactions"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="2dp"
|
||||
android:layout_marginTop="-10dp"
|
||||
android:layout_marginStart="5dp"
|
||||
android:layout_marginEnd="5dp"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:orientation="horizontal"
|
||||
android:text="@{model.reactions, default=@string/emoji_love}"
|
||||
android:textSize="20sp"
|
||||
android:textColor="@color/gray_main2_600"
|
||||
android:visibility="@{model.reactions.length() > 0 ? View.VISIBLE : View.GONE, default=gone}"
|
||||
app:layout_constraintStart_toStartOf="@id/background"
|
||||
app:layout_constraintTop_toBottomOf="@id/background"
|
||||
app:layout_constraintBottom_toBottomOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</layout>
|
||||
Loading…
Add table
Reference in a new issue