mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Added click to remove our own reaction
This commit is contained in:
parent
7aed1d83e3
commit
30f9f381cd
8 changed files with 47 additions and 12 deletions
|
|
@ -1,14 +1,22 @@
|
|||
package org.linphone.ui.main.chat.model
|
||||
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.annotation.WorkerThread
|
||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.core.Address
|
||||
|
||||
class ChatMessageBottomSheetParticipantModel @WorkerThread constructor(
|
||||
address: Address,
|
||||
val value: String
|
||||
val value: String,
|
||||
val isOurOwnReaction: Boolean = false,
|
||||
val onClick: (() -> Unit)? = null
|
||||
) {
|
||||
val sipUri = address.asStringUriOnly()
|
||||
|
||||
val avatarModel = coreContext.contactsManager.getContactAvatarModelForAddress(address)
|
||||
|
||||
@UiThread
|
||||
fun clicked() {
|
||||
onClick?.invoke()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package org.linphone.ui.main.chat.model
|
|||
|
||||
import androidx.annotation.WorkerThread
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.core.ChatMessage
|
||||
import org.linphone.core.tools.Log
|
||||
|
||||
|
|
@ -46,7 +47,24 @@ class ChatMessageReactionsModel @WorkerThread constructor(
|
|||
val count = reactionsMap.getOrDefault(body, 0)
|
||||
reactionsMap[body] = count + 1
|
||||
|
||||
allReactions.add(ChatMessageBottomSheetParticipantModel(reaction.fromAddress, body))
|
||||
val isOurOwn = reaction.fromAddress.weakEqual(chatMessage.chatRoom.localAddress)
|
||||
allReactions.add(
|
||||
ChatMessageBottomSheetParticipantModel(
|
||||
reaction.fromAddress,
|
||||
body,
|
||||
isOurOwn
|
||||
) {
|
||||
if (isOurOwn) {
|
||||
coreContext.postOnCoreThread {
|
||||
Log.i(
|
||||
"$TAG Removing our own reaction for chat message [${chatMessage.messageId}]"
|
||||
)
|
||||
val removeReaction = chatMessage.createReaction("")
|
||||
removeReaction.send()
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
if (!differentReactionsList.contains(body)) {
|
||||
differentReactionsList.add(body)
|
||||
|
|
|
|||
|
|
@ -1,6 +0,0 @@
|
|||
<?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"/>
|
||||
<stroke android:color="@color/white" android:width="2dp" />
|
||||
</shape>
|
||||
|
|
@ -90,7 +90,7 @@
|
|||
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:textColor="@color/gray_main2_500"
|
||||
android:textSize="14sp"
|
||||
android:maxLines="2"
|
||||
android:ellipsize="end"
|
||||
|
|
@ -176,7 +176,7 @@
|
|||
android:layout_marginTop="-5dp"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:orientation="horizontal"
|
||||
android:background="@drawable/shape_chat_bubble_reactions_incoming_background"
|
||||
android:background="@drawable/shape_chat_bubble_reactions_background"
|
||||
android:text="@{model.reactions, default=@string/emoji_love}"
|
||||
android:textSize="15sp"
|
||||
android:textColor="@color/gray_main2_600"
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:text="@{model.replyText, default=`Ceci est une réponse!`}"
|
||||
android:textColor="@color/gray_main2_400"
|
||||
android:textColor="@color/gray_main2_500"
|
||||
android:textSize="14sp"
|
||||
android:maxLines="2"
|
||||
android:ellipsize="end"
|
||||
|
|
@ -137,7 +137,7 @@
|
|||
android:layout_marginTop="-5dp"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:orientation="horizontal"
|
||||
android:background="@drawable/shape_chat_bubble_reactions_outgoing_background"
|
||||
android:background="@drawable/shape_chat_bubble_reactions_background"
|
||||
android:text="@{model.reactions, default=@string/emoji_love}"
|
||||
android:textSize="20sp"
|
||||
android:textColor="@color/gray_main2_600"
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:onClick="@{() -> model.clicked()}"
|
||||
android:background="@drawable/primary_cell_background"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp">
|
||||
|
|
@ -64,6 +65,19 @@
|
|||
app:layout_constraintStart_toEndOf="@id/avatar"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/date_time"
|
||||
app:layout_constraintBottom_toTopOf="@id/remove_reaction"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/default_text_style_300"
|
||||
android:id="@+id/remove_reaction"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/message_reaction_click_to_remove_label"
|
||||
android:textSize="12sp"
|
||||
android:textColor="@color/gray_main2_400"
|
||||
android:visibility="@{model.ourOwnReaction ? View.VISIBLE : View.GONE, default=gone}"
|
||||
app:layout_constraintTop_toBottomOf="@id/name"
|
||||
app:layout_constraintStart_toStartOf="@id/name"
|
||||
app:layout_constraintBottom_toBottomOf="parent"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
|
|
|
|||
|
|
@ -373,6 +373,7 @@
|
|||
<string name="message_delivery_info_error_title">Error %s</string>
|
||||
<string name="message_reactions_info_all_title">Reactions %s</string>
|
||||
<string name="message_reactions_info_emoji_title">%s %s</string>
|
||||
<string name="message_reaction_click_to_remove_label">Click to remove</string>
|
||||
|
||||
<string name="meetings_list_empty">No meeting for the moment…</string>
|
||||
<string name="meetings_list_today_indicator">Today</string>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue