Renamed chat message to simply message

This commit is contained in:
Sylvain Berfini 2023-11-27 14:03:04 +01:00
parent 45ca7aa348
commit ff2d04351f
21 changed files with 99 additions and 99 deletions

View file

@ -195,7 +195,7 @@ class NotificationsManager @MainThread constructor(private val context: Context)
if (defaultAccountAddress != null && defaultAccountAddress.weakEqual(address)) return
Log.i(
"$TAG Reaction received [${reaction.body}] from [${address.asStringUriOnly()}] for chat message [$message]"
"$TAG Reaction received [${reaction.body}] from [${address.asStringUriOnly()}] for message [$message]"
)
if (corePreferences.disableChat) return
@ -229,7 +229,7 @@ class NotificationsManager @MainThread constructor(private val context: Context)
address: Address
) {
Log.i(
"$TAG [${address.asStringUriOnly()}] removed it's previously sent reaction for chat message [$message]"
"$TAG [${address.asStringUriOnly()}] removed it's previously sent reaction for message [$message]"
)
if (corePreferences.disableChat) return

View file

@ -31,9 +31,9 @@ import org.linphone.R
import org.linphone.databinding.ChatBubbleIncomingBinding
import org.linphone.databinding.ChatBubbleOutgoingBinding
import org.linphone.databinding.ChatEventBinding
import org.linphone.ui.main.chat.model.ChatMessageModel
import org.linphone.ui.main.chat.model.EventLogModel
import org.linphone.ui.main.chat.model.EventModel
import org.linphone.ui.main.chat.model.MessageModel
import org.linphone.utils.Event
import org.linphone.utils.startAnimatedDrawable
@ -46,16 +46,16 @@ class ConversationEventAdapter : ListAdapter<EventLogModel, RecyclerView.ViewHol
const val EVENT = 3
}
val chatMessageLongPressEvent = MutableLiveData<Event<ChatMessageModel>>()
val chatMessageLongPressEvent = MutableLiveData<Event<MessageModel>>()
val showDeliveryForChatMessageModelEvent: MutableLiveData<Event<ChatMessageModel>> by lazy {
MutableLiveData<Event<ChatMessageModel>>()
val showDeliveryForChatMessageModelEvent: MutableLiveData<Event<MessageModel>> by lazy {
MutableLiveData<Event<MessageModel>>()
}
val showReactionForChatMessageModelEvent: MutableLiveData<Event<ChatMessageModel>> by lazy {
MutableLiveData<Event<ChatMessageModel>>()
val showReactionForChatMessageModelEvent: MutableLiveData<Event<MessageModel>> by lazy {
MutableLiveData<Event<MessageModel>>()
}
val scrollToRepliedMessageEvent: MutableLiveData<Event<ChatMessageModel>> by lazy {
MutableLiveData<Event<ChatMessageModel>>()
val scrollToRepliedMessageEvent: MutableLiveData<Event<MessageModel>> by lazy {
MutableLiveData<Event<MessageModel>>()
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
@ -70,7 +70,7 @@ class ConversationEventAdapter : ListAdapter<EventLogModel, RecyclerView.ViewHol
val data = getItem(position)
if (data.isEvent) return EVENT
if ((data.model as ChatMessageModel).isOutgoing) {
if ((data.model as MessageModel).isOutgoing) {
return OUTGOING_CHAT_MESSAGE
}
return INCOMING_CHAT_MESSAGE
@ -148,8 +148,8 @@ class ConversationEventAdapter : ListAdapter<EventLogModel, RecyclerView.ViewHol
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
val eventLog = getItem(position)
when (holder) {
is IncomingBubbleViewHolder -> holder.bind(eventLog.model as ChatMessageModel)
is OutgoingBubbleViewHolder -> holder.bind(eventLog.model as ChatMessageModel)
is IncomingBubbleViewHolder -> holder.bind(eventLog.model as MessageModel)
is OutgoingBubbleViewHolder -> holder.bind(eventLog.model as MessageModel)
is EventViewHolder -> holder.bind(eventLog.model as EventModel)
}
}
@ -157,7 +157,7 @@ class ConversationEventAdapter : ListAdapter<EventLogModel, RecyclerView.ViewHol
inner class IncomingBubbleViewHolder(
val binding: ChatBubbleIncomingBinding
) : RecyclerView.ViewHolder(binding.root) {
fun bind(message: ChatMessageModel) {
fun bind(message: MessageModel) {
with(binding) {
model = message
executePendingBindings()
@ -170,7 +170,7 @@ class ConversationEventAdapter : ListAdapter<EventLogModel, RecyclerView.ViewHol
inner class OutgoingBubbleViewHolder(
val binding: ChatBubbleOutgoingBinding
) : RecyclerView.ViewHolder(binding.root) {
fun bind(message: ChatMessageModel) {
fun bind(message: MessageModel) {
with(binding) {
model = message
executePendingBindings()
@ -193,8 +193,8 @@ class ConversationEventAdapter : ListAdapter<EventLogModel, RecyclerView.ViewHol
private class EventLogDiffCallback : DiffUtil.ItemCallback<EventLogModel>() {
override fun areItemsTheSame(oldItem: EventLogModel, newItem: EventLogModel): Boolean {
return if (!oldItem.isEvent && !newItem.isEvent) {
val oldData = (oldItem.model as ChatMessageModel)
val newData = (newItem.model as ChatMessageModel)
val oldData = (oldItem.model as MessageModel)
val newData = (newItem.model as MessageModel)
oldData.id == newData.id &&
oldData.timestamp == newData.timestamp &&
oldData.isOutgoing == newData.isOutgoing
@ -207,8 +207,8 @@ class ConversationEventAdapter : ListAdapter<EventLogModel, RecyclerView.ViewHol
return if (oldItem.isEvent && newItem.isEvent) {
true
} else if (!oldItem.isEvent && !newItem.isEvent) {
val oldModel = (oldItem.model as ChatMessageModel)
val newModel = (newItem.model as ChatMessageModel)
val oldModel = (oldItem.model as MessageModel)
val newModel = (newItem.model as MessageModel)
oldModel.statusIcon.value == newModel.statusIcon.value
} else {
false

View file

@ -10,9 +10,9 @@ import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
import org.linphone.R
import org.linphone.databinding.ChatMessageBottomSheetListCellBinding
import org.linphone.ui.main.chat.model.ChatMessageBottomSheetParticipantModel
import org.linphone.ui.main.chat.model.MessageBottomSheetParticipantModel
class ChatMessageBottomSheetAdapter : ListAdapter<ChatMessageBottomSheetParticipantModel, RecyclerView.ViewHolder>(
class MessageBottomSheetAdapter : ListAdapter<MessageBottomSheetParticipantModel, RecyclerView.ViewHolder>(
ParticipantDiffCallback()
) {
@ -35,7 +35,7 @@ class ChatMessageBottomSheetAdapter : ListAdapter<ChatMessageBottomSheetParticip
val binding: ChatMessageBottomSheetListCellBinding
) : RecyclerView.ViewHolder(binding.root) {
@UiThread
fun bind(bottomSheetModel: ChatMessageBottomSheetParticipantModel) {
fun bind(bottomSheetModel: MessageBottomSheetParticipantModel) {
with(binding) {
model = bottomSheetModel
executePendingBindings()
@ -43,17 +43,17 @@ class ChatMessageBottomSheetAdapter : ListAdapter<ChatMessageBottomSheetParticip
}
}
private class ParticipantDiffCallback : DiffUtil.ItemCallback<ChatMessageBottomSheetParticipantModel>() {
private class ParticipantDiffCallback : DiffUtil.ItemCallback<MessageBottomSheetParticipantModel>() {
override fun areItemsTheSame(
oldItem: ChatMessageBottomSheetParticipantModel,
newItem: ChatMessageBottomSheetParticipantModel
oldItem: MessageBottomSheetParticipantModel,
newItem: MessageBottomSheetParticipantModel
): Boolean {
return oldItem.sipUri == newItem.sipUri && oldItem.value == newItem.value
}
override fun areContentsTheSame(
oldItem: ChatMessageBottomSheetParticipantModel,
newItem: ChatMessageBottomSheetParticipantModel
oldItem: MessageBottomSheetParticipantModel,
newItem: MessageBottomSheetParticipantModel
): Boolean {
return true
}

View file

@ -63,11 +63,11 @@ import org.linphone.core.tools.Log
import org.linphone.databinding.ChatBubbleLongPressMenuBinding
import org.linphone.databinding.ChatConversationFragmentBinding
import org.linphone.ui.main.MainActivity
import org.linphone.ui.main.chat.adapter.ChatMessageBottomSheetAdapter
import org.linphone.ui.main.chat.adapter.ConversationEventAdapter
import org.linphone.ui.main.chat.model.ChatMessageDeliveryModel
import org.linphone.ui.main.chat.model.ChatMessageModel
import org.linphone.ui.main.chat.model.ChatMessageReactionsModel
import org.linphone.ui.main.chat.adapter.MessageBottomSheetAdapter
import org.linphone.ui.main.chat.model.MessageDeliveryModel
import org.linphone.ui.main.chat.model.MessageModel
import org.linphone.ui.main.chat.model.MessageReactionsModel
import org.linphone.ui.main.chat.view.RichEditText
import org.linphone.ui.main.chat.viewmodel.ConversationViewModel
import org.linphone.ui.main.chat.viewmodel.ConversationViewModel.Companion.SCROLLING_POSITION_NOT_SET
@ -98,7 +98,7 @@ class ConversationFragment : GenericFragment() {
private lateinit var adapter: ConversationEventAdapter
private lateinit var bottomSheetAdapter: ChatMessageBottomSheetAdapter
private lateinit var bottomSheetAdapter: MessageBottomSheetAdapter
private val args: ConversationFragmentArgs by navArgs()
@ -157,7 +157,7 @@ class ConversationFragment : GenericFragment() {
}
}
private var currentChatMessageModelForBottomSheet: ChatMessageModel? = null
private var currentChatMessageModelForBottomSheet: MessageModel? = null
private val bottomSheetCallback = object : BottomSheetCallback() {
override fun onStateChanged(bottomSheet: View, newState: Int) {
Log.i("$TAG Bottom sheet state is [$newState]")
@ -180,15 +180,15 @@ class ConversationFragment : GenericFragment() {
}
}
private var bottomSheetDeliveryModel: ChatMessageDeliveryModel? = null
private var bottomSheetDeliveryModel: MessageDeliveryModel? = null
private var bottomSheetReactionsModel: ChatMessageReactionsModel? = null
private var bottomSheetReactionsModel: MessageReactionsModel? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
adapter = ConversationEventAdapter()
bottomSheetAdapter = ChatMessageBottomSheetAdapter()
bottomSheetAdapter = MessageBottomSheetAdapter()
}
override fun onCreateView(
@ -244,7 +244,7 @@ class ConversationFragment : GenericFragment() {
adapter.notifyItemChanged(index)
val chatMessageEventLog = adapter.currentList[index]
val chatMessageModel = (chatMessageEventLog.model as? ChatMessageModel)
val chatMessageModel = (chatMessageEventLog.model as? MessageModel)
if (chatMessageModel != null) {
sendMessageViewModel.replyToMessage(chatMessageModel)
// Open keyboard & focus edit text
@ -324,10 +324,10 @@ class ConversationFragment : GenericFragment() {
it.consume { model ->
val repliedMessageId = model.replyToMessageId
if (repliedMessageId.isNullOrEmpty()) {
Log.w("$TAG Chat message [${model.id}] doesn't have a reply to ID!")
Log.w("$TAG Message [${model.id}] doesn't have a reply to ID!")
} else {
val originalMessage = adapter.currentList.find { eventLog ->
!eventLog.isEvent && (eventLog.model as ChatMessageModel).id == repliedMessageId
!eventLog.isEvent && (eventLog.model as MessageModel).id == repliedMessageId
}
if (originalMessage != null) {
val position = adapter.currentList.indexOf(originalMessage)
@ -417,7 +417,7 @@ class ConversationFragment : GenericFragment() {
viewModel.isGroup.observe(viewLifecycleOwner) { group ->
if (group) {
Log.i("$TAG Adding text observer to chat message sending area")
Log.i("$TAG Adding text observer to message sending area")
binding.sendArea.messageToSend.addTextChangedListener(textObserver)
}
}
@ -491,7 +491,7 @@ class ConversationFragment : GenericFragment() {
sharedViewModel.forceRefreshConversationEvents.observe(viewLifecycleOwner) {
it.consume {
Log.i("$TAG Force refreshing chat messages list")
Log.i("$TAG Force refreshing messages list")
viewModel.applyFilter("")
}
}
@ -519,7 +519,7 @@ class ConversationFragment : GenericFragment() {
val id = LinphoneUtils.getChatRoomId(args.localSipUri, args.remoteSipUri)
Log.i(
"$TAG Asking notifications manager not to notify chat messages for conversation [$id]"
"$TAG Asking notifications manager not to notify messages for conversation [$id]"
)
coreContext.notificationsManager.setCurrentlyDisplayedChatRoomId(id)
@ -566,7 +566,7 @@ class ConversationFragment : GenericFragment() {
super.onPause()
}
private fun showChatMessageLongPressMenu(chatMessageModel: ChatMessageModel) {
private fun showChatMessageLongPressMenu(chatMessageModel: MessageModel) {
Compatibility.setBlurRenderEffect(binding.root)
val dialog = Dialog(requireContext(), R.style.Theme_LinphoneDialog)
@ -606,7 +606,7 @@ class ConversationFragment : GenericFragment() {
}
layout.setResendClickListener {
Log.i("$TAG Re-sending chat message in error state")
Log.i("$TAG Re-sending message in error state")
chatMessageModel.resend()
dialog.dismiss()
}
@ -645,7 +645,7 @@ class ConversationFragment : GenericFragment() {
@UiThread
private fun showBottomSheetDialog(
chatMessageModel: ChatMessageModel,
chatMessageModel: MessageModel,
showDelivery: Boolean = false,
showReactions: Boolean = false
) {
@ -683,11 +683,11 @@ class ConversationFragment : GenericFragment() {
}
@UiThread
private fun prepareBottomSheetForDeliveryStatus(chatMessageModel: ChatMessageModel) {
private fun prepareBottomSheetForDeliveryStatus(chatMessageModel: MessageModel) {
coreContext.postOnCoreThread {
bottomSheetDeliveryModel?.destroy()
val model = ChatMessageDeliveryModel(chatMessageModel.chatMessage) { deliveryModel ->
val model = MessageDeliveryModel(chatMessageModel.chatMessage) { deliveryModel ->
coreContext.postOnMainThread {
displayDeliveryStatuses(deliveryModel)
}
@ -697,11 +697,11 @@ class ConversationFragment : GenericFragment() {
}
@UiThread
private fun prepareBottomSheetForReactions(chatMessageModel: ChatMessageModel) {
private fun prepareBottomSheetForReactions(chatMessageModel: MessageModel) {
coreContext.postOnCoreThread {
bottomSheetReactionsModel?.destroy()
val model = ChatMessageReactionsModel(chatMessageModel.chatMessage) { reactionsModel ->
val model = MessageReactionsModel(chatMessageModel.chatMessage) { reactionsModel ->
coreContext.postOnMainThread {
if (reactionsModel.allReactions.isEmpty()) {
Log.i("$TAG No reaction to display, closing bottom sheet")
@ -719,7 +719,7 @@ class ConversationFragment : GenericFragment() {
}
@UiThread
private fun displayDeliveryStatuses(model: ChatMessageDeliveryModel) {
private fun displayDeliveryStatuses(model: MessageDeliveryModel) {
val tabs = binding.messageBottomSheet.tabs
tabs.removeAllTabs()
tabs.addTab(
@ -768,7 +768,7 @@ class ConversationFragment : GenericFragment() {
}
@UiThread
private fun displayReactions(model: ChatMessageReactionsModel) {
private fun displayReactions(model: MessageReactionsModel) {
val totalCount = model.allReactions.size
val label = getString(R.string.message_reactions_info_all_title, totalCount.toString())

View file

@ -202,7 +202,7 @@ class ConversationInfoFragment : GenericFragment() {
sharedViewModel.newChatMessageEphemeralLifetimeToSet.observe(viewLifecycleOwner) {
it.consume { ephemeralLifetime ->
Log.i(
"$TAG Setting [$ephemeralLifetime] as new ephemeral lifetime for chat messages"
"$TAG Setting [$ephemeralLifetime] as new ephemeral lifetime for messages"
)
viewModel.updateEphemeralLifetime(ephemeralLifetime)
}

View file

@ -166,7 +166,7 @@ class ConversationModel @WorkerThread constructor(val chatRoom: ChatRoom) {
isMuted.postValue(chatRoom.muted)
isEphemeral.postValue(chatRoom.isEphemeralEnabled)
Log.i(
"$TAG Ephemeral chat messages are [${if (chatRoom.isEphemeralEnabled) "enabled" else "disabled"}], lifetime is [${chatRoom.ephemeralLifetime}]"
"$TAG Ephemeral messages are [${if (chatRoom.isEphemeralEnabled) "enabled" else "disabled"}], lifetime is [${chatRoom.ephemeralLifetime}]"
)
updateLastMessage()

View file

@ -70,7 +70,7 @@ class EventLogModel @WorkerThread constructor(
""
}
ChatMessageModel(
MessageModel(
chatMessage,
avatarModel,
isFromGroup,
@ -90,6 +90,6 @@ class EventLogModel @WorkerThread constructor(
@WorkerThread
fun destroy() {
(model as? ChatMessageModel)?.destroy()
(model as? MessageModel)?.destroy()
}
}

View file

@ -5,7 +5,7 @@ import androidx.annotation.WorkerThread
import org.linphone.LinphoneApplication.Companion.coreContext
import org.linphone.core.Address
class ChatMessageBottomSheetParticipantModel @WorkerThread constructor(
class MessageBottomSheetParticipantModel @WorkerThread constructor(
address: Address,
val value: String,
val isOurOwnReaction: Boolean = false,

View file

@ -12,12 +12,12 @@ import org.linphone.core.tools.Log
import org.linphone.utils.AppUtils
import org.linphone.utils.TimestampUtils
class ChatMessageDeliveryModel @WorkerThread constructor(
class MessageDeliveryModel @WorkerThread constructor(
private val chatMessage: ChatMessage,
private val onDeliveryUpdated: ((model: ChatMessageDeliveryModel) -> Unit)? = null
private val onDeliveryUpdated: ((model: MessageDeliveryModel) -> Unit)? = null
) {
companion object {
private const val TAG = "[Chat Message Delivery Model]"
private const val TAG = "[Message Delivery Model]"
}
val readLabel = MutableLiveData<String>()
@ -28,13 +28,13 @@ class ChatMessageDeliveryModel @WorkerThread constructor(
val errorLabel = MutableLiveData<String>()
val displayedModels = arrayListOf<ChatMessageBottomSheetParticipantModel>()
val displayedModels = arrayListOf<MessageBottomSheetParticipantModel>()
private val deliveredModels = arrayListOf<ChatMessageBottomSheetParticipantModel>()
private val deliveredModels = arrayListOf<MessageBottomSheetParticipantModel>()
private val sentModels = arrayListOf<ChatMessageBottomSheetParticipantModel>()
private val sentModels = arrayListOf<MessageBottomSheetParticipantModel>()
private val errorModels = arrayListOf<ChatMessageBottomSheetParticipantModel>()
private val errorModels = arrayListOf<MessageBottomSheetParticipantModel>()
private val chatMessageListener = object : ChatMessageListenerStub() {
@WorkerThread
@ -57,7 +57,7 @@ class ChatMessageDeliveryModel @WorkerThread constructor(
}
@UiThread
fun computeListForState(state: State): ArrayList<ChatMessageBottomSheetParticipantModel> {
fun computeListForState(state: State): ArrayList<MessageBottomSheetParticipantModel> {
return when (state) {
State.DeliveredToUser -> {
deliveredModels
@ -83,7 +83,7 @@ class ChatMessageDeliveryModel @WorkerThread constructor(
for (participant in chatMessage.getParticipantsByImdnState(State.Displayed)) {
displayedModels.add(
ChatMessageBottomSheetParticipantModel(
MessageBottomSheetParticipantModel(
participant.participant.address,
TimestampUtils.toString(participant.stateChangeTime)
)
@ -92,7 +92,7 @@ class ChatMessageDeliveryModel @WorkerThread constructor(
if (!chatMessage.isOutgoing) {
// Always add ourselves to prevent empty list
displayedModels.add(
ChatMessageBottomSheetParticipantModel(
MessageBottomSheetParticipantModel(
chatMessage.localAddress,
TimestampUtils.toString(chatMessage.time)
)
@ -108,7 +108,7 @@ class ChatMessageDeliveryModel @WorkerThread constructor(
for (participant in chatMessage.getParticipantsByImdnState(State.DeliveredToUser)) {
deliveredModels.add(
ChatMessageBottomSheetParticipantModel(
MessageBottomSheetParticipantModel(
participant.participant.address,
TimestampUtils.toString(participant.stateChangeTime)
)
@ -124,7 +124,7 @@ class ChatMessageDeliveryModel @WorkerThread constructor(
for (participant in chatMessage.getParticipantsByImdnState(State.Delivered)) {
sentModels.add(
ChatMessageBottomSheetParticipantModel(
MessageBottomSheetParticipantModel(
participant.participant.address,
TimestampUtils.toString(participant.stateChangeTime)
)
@ -140,7 +140,7 @@ class ChatMessageDeliveryModel @WorkerThread constructor(
for (participant in chatMessage.getParticipantsByImdnState(State.NotDelivered)) {
errorModels.add(
ChatMessageBottomSheetParticipantModel(
MessageBottomSheetParticipantModel(
participant.participant.address,
TimestampUtils.toString(participant.stateChangeTime)
)

View file

@ -58,7 +58,7 @@ import org.linphone.utils.PatternClickableSpan
import org.linphone.utils.SpannableClickedListener
import org.linphone.utils.TimestampUtils
class ChatMessageModel @WorkerThread constructor(
class MessageModel @WorkerThread constructor(
val chatMessage: ChatMessage,
val avatarModel: ContactAvatarModel,
val isFromGroup: Boolean,
@ -73,7 +73,7 @@ class ChatMessageModel @WorkerThread constructor(
private val onWebUrlClicked: ((url: String) -> Unit)? = null
) {
companion object {
private const val TAG = "[Chat Message Model]"
private const val TAG = "[Message Model]"
private const val SIP_URI_REGEXP = "(?:<?sips?:)[a-zA-Z0-9+_.\\-]+(?:@([a-zA-Z0-9+_.\\-;=~]+))+(>)?"
private const val HTTP_LINK_REGEXP = "https?:\\/\\/(www\\.)?[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_\\+.~#?&//=]*)"
@ -171,14 +171,14 @@ class ChatMessageModel @WorkerThread constructor(
@WorkerThread
override fun onNewMessageReaction(message: ChatMessage, reaction: ChatMessageReaction) {
Log.i(
"$TAG New reaction [${reaction.body}] from [${reaction.fromAddress.asStringUriOnly()}] for chat message with ID [$id]"
"$TAG New reaction [${reaction.body}] from [${reaction.fromAddress.asStringUriOnly()}] for 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]")
Log.i("$TAG A reaction was removed for message with ID [$id]")
updateReactionsList()
}
@ -235,7 +235,7 @@ class ChatMessageModel @WorkerThread constructor(
@UiThread
fun sendReaction(emoji: String) {
coreContext.postOnCoreThread {
Log.i("$TAG Sending reaction [$emoji] to chat message with ID [$id]")
Log.i("$TAG Sending reaction [$emoji] to message with ID [$id]")
val reaction = chatMessage.createReaction(emoji)
reaction.send()
dismissLongPressMenuEvent.postValue(Event(true))
@ -275,7 +275,7 @@ class ChatMessageModel @WorkerThread constructor(
@WorkerThread
private fun computeContentsList() {
Log.d("$TAG Computing chat message contents list")
Log.d("$TAG Computing message contents list")
var displayableContentFound = false
var filesContentCount = 0
val filesPath = arrayListOf<FileModel>()

View file

@ -9,15 +9,15 @@ import org.linphone.core.ChatMessageListenerStub
import org.linphone.core.ChatMessageReaction
import org.linphone.core.tools.Log
class ChatMessageReactionsModel @WorkerThread constructor(
class MessageReactionsModel @WorkerThread constructor(
private val chatMessage: ChatMessage,
private val onReactionsUpdated: ((model: ChatMessageReactionsModel) -> Unit)? = null
private val onReactionsUpdated: ((model: MessageReactionsModel) -> Unit)? = null
) {
companion object {
private const val TAG = "[Chat Message Reactions Model]"
private const val TAG = "[Message Reactions Model]"
}
val allReactions = arrayListOf<ChatMessageBottomSheetParticipantModel>()
val allReactions = arrayListOf<MessageBottomSheetParticipantModel>()
val differentReactions = MutableLiveData<ArrayList<String>>()
@ -47,8 +47,8 @@ class ChatMessageReactionsModel @WorkerThread constructor(
chatMessage.removeListener(chatMessageListener)
}
fun filterReactions(emoji: String): ArrayList<ChatMessageBottomSheetParticipantModel> {
val filteredList = arrayListOf<ChatMessageBottomSheetParticipantModel>()
fun filterReactions(emoji: String): ArrayList<MessageBottomSheetParticipantModel> {
val filteredList = arrayListOf<MessageBottomSheetParticipantModel>()
for (reaction in allReactions) {
if (reaction.value == emoji) {
@ -72,7 +72,7 @@ class ChatMessageReactionsModel @WorkerThread constructor(
val isOurOwn = reaction.fromAddress.weakEqual(chatMessage.chatRoom.localAddress)
allReactions.add(
ChatMessageBottomSheetParticipantModel(
MessageBottomSheetParticipantModel(
reaction.fromAddress,
body,
isOurOwn
@ -80,7 +80,7 @@ class ChatMessageReactionsModel @WorkerThread constructor(
if (isOurOwn) {
coreContext.postOnCoreThread {
Log.i(
"$TAG Removing our own reaction for chat message [${chatMessage.messageId}]"
"$TAG Removing our own reaction for message [${chatMessage.messageId}]"
)
val removeReaction = chatMessage.createReaction("")
removeReaction.send()

View file

@ -460,7 +460,7 @@ class ConversationInfoViewModel @UiThread constructor() : ViewModel() {
if (!chatRoom.isEphemeralEnabled) 0L else chatRoom.ephemeralLifetime
)
Log.i(
"$TAG Ephemeral chat messages are [${if (chatRoom.isEphemeralEnabled) "enabled" else "disabled"}], lifetime is [${chatRoom.ephemeralLifetime}]"
"$TAG Ephemeral messages are [${if (chatRoom.isEphemeralEnabled) "enabled" else "disabled"}], lifetime is [${chatRoom.ephemeralLifetime}]"
)
}
}

View file

@ -32,8 +32,8 @@ import org.linphone.core.EventLog
import org.linphone.core.Factory
import org.linphone.core.Friend
import org.linphone.core.tools.Log
import org.linphone.ui.main.chat.model.ChatMessageModel
import org.linphone.ui.main.chat.model.EventLogModel
import org.linphone.ui.main.chat.model.MessageModel
import org.linphone.ui.main.contacts.model.ContactAvatarModel
import org.linphone.utils.AppUtils
import org.linphone.utils.Event
@ -99,7 +99,7 @@ class ConversationViewModel @UiThread constructor() : ViewModel() {
@WorkerThread
override fun onChatMessageSending(chatRoom: ChatRoom, eventLog: EventLog) {
val message = eventLog.chatMessage
Log.i("$TAG Chat message [$message] is being sent")
Log.i("$TAG Message [$message] is being sent")
val list = arrayListOf<EventLogModel>()
list.addAll(events.value.orEmpty())
@ -130,7 +130,7 @@ class ConversationViewModel @UiThread constructor() : ViewModel() {
@WorkerThread
override fun onChatMessageSent(chatRoom: ChatRoom, eventLog: EventLog) {
val message = eventLog.chatMessage
Log.i("$TAG Chat message [$message] has been sent")
Log.i("$TAG Message [$message] has been sent")
}
@WorkerThread
@ -203,7 +203,7 @@ class ConversationViewModel @UiThread constructor() : ViewModel() {
Log.i("$TAG Message [${message?.messageId}] ephemeral lifetime has expired")
val found = eventsLogs.find {
(it.model as? ChatMessageModel)?.chatMessage == message
(it.model as? MessageModel)?.chatMessage == message
}
if (found != null) {
val list = arrayListOf<EventLogModel>()
@ -322,7 +322,7 @@ class ConversationViewModel @UiThread constructor() : ViewModel() {
}
@UiThread
fun deleteChatMessage(chatMessageModel: ChatMessageModel) {
fun deleteChatMessage(chatMessageModel: MessageModel) {
coreContext.postOnCoreThread {
val eventsLogs = events.value.orEmpty()
val found = eventsLogs.find {

View file

@ -47,8 +47,8 @@ import org.linphone.core.Player
import org.linphone.core.PlayerListener
import org.linphone.core.Recorder
import org.linphone.core.tools.Log
import org.linphone.ui.main.chat.model.ChatMessageModel
import org.linphone.ui.main.chat.model.FileModel
import org.linphone.ui.main.chat.model.MessageModel
import org.linphone.ui.main.chat.model.ParticipantModel
import org.linphone.utils.AppUtils
import org.linphone.utils.AudioUtils
@ -193,10 +193,10 @@ class SendMessageInConversationViewModel @UiThread constructor() : ViewModel() {
}
@UiThread
fun replyToMessage(model: ChatMessageModel) {
fun replyToMessage(model: MessageModel) {
coreContext.postOnCoreThread {
val message = model.chatMessage
Log.i("$TAG Pending reply to chat message [${message.messageId}]")
Log.i("$TAG Pending reply to message [${message.messageId}]")
chatMessageToReplyTo = message
isReplyingTo.postValue(model.avatarModel.friend.name)
isReplyingToMessage.postValue(LinphoneUtils.getTextDescribingMessage(message))

View file

@ -6,7 +6,7 @@
<import type="android.view.View" />
<variable
name="model"
type="org.linphone.ui.main.chat.model.ChatMessageModel" />
type="org.linphone.ui.main.chat.model.MessageModel" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout

View file

@ -22,7 +22,7 @@
type="View.OnClickListener" />
<variable
name="model"
type="org.linphone.ui.main.chat.model.ChatMessageModel" />
type="org.linphone.ui.main.chat.model.MessageModel" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout

View file

@ -25,7 +25,7 @@
type="View.OnClickListener" />
<variable
name="model"
type="org.linphone.ui.main.chat.model.ChatMessageModel" />
type="org.linphone.ui.main.chat.model.MessageModel" />
</data>
<androidx.coordinatorlayout.widget.CoordinatorLayout

View file

@ -6,7 +6,7 @@
<import type="android.view.View" />
<variable
name="model"
type="org.linphone.ui.main.chat.model.ChatMessageModel" />
type="org.linphone.ui.main.chat.model.MessageModel" />
<variable
name="inflatedVisibility"
type="Integer" />

View file

@ -22,7 +22,7 @@
type="View.OnClickListener" />
<variable
name="model"
type="org.linphone.ui.main.chat.model.ChatMessageModel" />
type="org.linphone.ui.main.chat.model.MessageModel" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout

View file

@ -7,7 +7,7 @@
<import type="android.view.View" />
<variable
name="model"
type="org.linphone.ui.main.chat.model.ChatMessageModel" />
type="org.linphone.ui.main.chat.model.MessageModel" />
<variable
name="inflatedVisibility"
type="Integer" />

View file

@ -9,7 +9,7 @@
<import type="org.linphone.core.ChatRoom.SecurityLevel" />
<variable
name="model"
type="org.linphone.ui.main.chat.model.ChatMessageBottomSheetParticipantModel" />
type="org.linphone.ui.main.chat.model.MessageBottomSheetParticipantModel" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout