Switched to chatRoom.subjectUft8 + fixed notification & shortcut label when group chat room subject is updated

This commit is contained in:
Sylvain Berfini 2026-02-13 15:18:42 +01:00
parent 91f13fe407
commit f5536ba9a6
13 changed files with 46 additions and 36 deletions

View file

@ -492,6 +492,13 @@ class NotificationsManager
Log.i("$TAG A message has been edited, checking if notification should be updated")
updateConversationNotification(chatRoom, message)
}
override fun onChatRoomSubjectChanged(core: Core, chatRoom: ChatRoom) {
if (ShortcutUtils.isShortcutToChatRoomAlreadyCreated(coreContext.context, chatRoom)) {
Log.i("$TAG Updating chat room shortcut with new subject [${chatRoom.subjectUtf8}]")
ShortcutUtils.createOrUpdateChatRoomShortcut(coreContext.context, chatRoom)
}
}
}
val chatMessageListener: ChatMessageListener = object : ChatMessageListenerStub() {
@ -1019,7 +1026,7 @@ class NotificationsManager
notifiable.isGroup = false
} else {
notifiable.isGroup = true
notifiable.groupTitle = chatRoom.subject
notifiable.groupTitle = chatRoom.subjectUtf8
}
for (message in chatRoom.unreadHistory) {
@ -1028,6 +1035,9 @@ class NotificationsManager
notifiable.messages.add(notifiableMessage)
}
} else {
// Update notification subject in case it has changed since last message
notifiable.groupTitle = chatRoom.subjectUtf8
for (message in messages) {
if (message.isRead || message.isOutgoing) continue
val notifiableMessage = getNotifiableForChatMessage(message)
@ -1044,11 +1054,11 @@ class NotificationsManager
val notifiable = getNotifiableForConversation(chatRoom, messages)
if (!chatRoom.hasCapability(ChatRoom.Capabilities.OneToOne.toInt())) {
if (chatRoom.subject != notifiable.groupTitle) {
if (chatRoom.subjectUtf8 != notifiable.groupTitle) {
Log.i(
"$TAG Updating notification subject from [${notifiable.groupTitle}] to [${chatRoom.subject}]"
"$TAG Updating notification subject from [${notifiable.groupTitle}] to [${chatRoom.subjectUtf8}]"
)
notifiable.groupTitle = chatRoom.subject
notifiable.groupTitle = chatRoom.subjectUtf8
}
}

View file

@ -421,7 +421,7 @@ class CurrentCallViewModel
if (state == ChatRoom.State.Instantiated) return
val id = LinphoneUtils.getConversationId(chatRoom)
Log.i("$TAG Conversation [$id] (${chatRoom.subject}) state changed: [$state]")
Log.i("$TAG Conversation [$id] (${chatRoom.subjectUtf8}) state changed: [$state]")
if (state == ChatRoom.State.Created) {
Log.i("$TAG Conversation [$id] successfully created")

View file

@ -101,7 +101,7 @@ class ConversationModel
override fun onStateChanged(chatRoom: ChatRoom, newState: ChatRoom.State?) {
Log.i("$TAG Conversation state changed [${chatRoom.state}]")
if (chatRoom.state == ChatRoom.State.Created) {
subject.postValue(chatRoom.subject)
subject.postValue(chatRoom.subjectUtf8)
computeParticipants()
} else if (chatRoom.state == ChatRoom.State.Deleted) {
Log.i("$TAG Conversation [$id] has been deleted")
@ -113,7 +113,7 @@ class ConversationModel
override fun onConferenceJoined(chatRoom: ChatRoom, eventLog: EventLog) {
// This is required as a Created chat room may not have the participants list yet
Log.i("$TAG Conversation has been joined")
subject.postValue(chatRoom.subject)
subject.postValue(chatRoom.subjectUtf8)
computeParticipants()
}
@ -156,8 +156,8 @@ class ConversationModel
@WorkerThread
override fun onSubjectChanged(chatRoom: ChatRoom, eventLog: EventLog) {
Log.i("$TAG Conversation subject changed [${chatRoom.subject}]")
subject.postValue(chatRoom.subject)
Log.i("$TAG Conversation subject changed [${chatRoom.subjectUtf8}]")
subject.postValue(chatRoom.subjectUtf8)
computeParticipants()
}
@ -201,7 +201,7 @@ class ConversationModel
chatRoom.addListener(chatRoomListener)
computeComposingLabel()
subject.postValue(chatRoom.subject)
subject.postValue(chatRoom.subjectUtf8)
computeParticipants()
isMuted.postValue(chatRoom.muted)
@ -433,9 +433,9 @@ class ConversationModel
}
if (isGroup) {
if (avatarModel.value == null || avatarModel.value?.contactName != chatRoom.subject) {
if (avatarModel.value == null || avatarModel.value?.contactName != chatRoom.subjectUtf8) {
val fakeFriend = coreContext.core.createFriend()
fakeFriend.name = chatRoom.subject
fakeFriend.name = chatRoom.subjectUtf8
val model = ContactAvatarModel(fakeFriend)
model.defaultToConversationIcon.postValue(true)
model.updateSecurityLevelUsingConversation(chatRoom)

View file

@ -169,7 +169,7 @@ abstract class AbstractConversationViewModel : GenericViewModel() {
return@postOnCoreThread
}
val conference = LinphoneUtils.createGroupCall(account, chatRoom.subject.orEmpty())
val conference = LinphoneUtils.createGroupCall(account, chatRoom.subjectUtf8.orEmpty())
if (conference == null) {
Log.e("$TAG Failed to create group call!")
showRedToast(R.string.conference_failed_to_create_group_call_toast, R.drawable.warning_circle)

View file

@ -58,7 +58,7 @@ class ConversationForwardMessageViewModel
if (state == ChatRoom.State.Instantiated) return
val id = LinphoneUtils.getConversationId(chatRoom)
Log.i("$TAG Conversation [$id] (${chatRoom.subject}) state changed: [$state]")
Log.i("$TAG Conversation [$id] (${chatRoom.subjectUtf8}) state changed: [$state]")
if (state == ChatRoom.State.Created) {
Log.i("$TAG Conversation [$id] successfully created")

View file

@ -107,7 +107,7 @@ class ConversationInfoViewModel
private val chatRoomListener = object : ChatRoomListenerStub() {
@WorkerThread
override fun onParticipantAdded(chatRoom: ChatRoom, eventLog: EventLog) {
Log.i("$TAG A participant has been added to the group [${chatRoom.subject}]")
Log.i("$TAG A participant has been added to the group [${chatRoom.subjectUtf8}]")
val message = AppUtils.getFormattedString(
R.string.conversation_info_participant_added_to_conversation_toast,
getParticipant(eventLog)
@ -120,7 +120,7 @@ class ConversationInfoViewModel
@WorkerThread
override fun onParticipantRemoved(chatRoom: ChatRoom, eventLog: EventLog) {
Log.i("$TAG A participant has been removed from the group [${chatRoom.subject}]")
Log.i("$TAG A participant has been removed from the group [${chatRoom.subjectUtf8}]")
val message = AppUtils.getFormattedString(
R.string.conversation_info_participant_removed_from_conversation_toast,
getParticipant(eventLog)
@ -134,7 +134,7 @@ class ConversationInfoViewModel
@WorkerThread
override fun onParticipantAdminStatusChanged(chatRoom: ChatRoom, eventLog: EventLog) {
Log.i(
"$TAG A participant has been given/removed administration rights for group [${chatRoom.subject}]"
"$TAG A participant has been given/removed administration rights for group [${chatRoom.subjectUtf8}]"
)
if (eventLog.type == EventLog.Type.ConferenceParticipantSetAdmin) {
val message = AppUtils.getFormattedString(
@ -156,11 +156,11 @@ class ConversationInfoViewModel
@WorkerThread
override fun onSubjectChanged(chatRoom: ChatRoom, eventLog: EventLog) {
Log.i(
"$TAG Conversation [${LinphoneUtils.getConversationId(chatRoom)}] has a new subject [${chatRoom.subject}]"
"$TAG Conversation [${LinphoneUtils.getConversationId(chatRoom)}] has a new subject [${chatRoom.subjectUtf8}]"
)
showGreenToast(R.string.conversation_subject_changed_toast, R.drawable.check)
subject.postValue(chatRoom.subject)
subject.postValue(chatRoom.subjectUtf8)
computeParticipantsList()
infoChangedEvent.postValue(Event(true))
}
@ -263,7 +263,7 @@ class ConversationInfoViewModel
participantsList.add(participant.address.asStringUriOnly())
}
goToScheduleMeetingEvent.postValue(
Event(Pair(chatRoom.subject.orEmpty(), participantsList))
Event(Pair(chatRoom.subjectUtf8.orEmpty(), participantsList))
)
} else {
val firstParticipant = chatRoom.participants.firstOrNull()
@ -464,10 +464,10 @@ class ConversationInfoViewModel
val readOnly = chatRoom.isReadOnly
isReadOnly.postValue(readOnly)
if (readOnly) {
Log.w("$TAG Conversation with subject [${chatRoom.subject}] is read only!")
Log.w("$TAG Conversation with subject [${chatRoom.subjectUtf8}] is read only!")
}
subject.postValue(chatRoom.subject)
subject.postValue(chatRoom.subjectUtf8)
peerSipUri.postValue(chatRoom.peerAddress.asStringUriOnly())
val firstParticipant = chatRoom.participants.firstOrNull()
@ -558,7 +558,7 @@ class ConversationInfoViewModel
val avatar = if (groupChatRoom) {
val fakeFriend = coreContext.core.createFriend()
fakeFriend.name = chatRoom.subject
fakeFriend.name = chatRoom.subjectUtf8
val model = ContactAvatarModel(fakeFriend)
model.defaultToConversationIcon.postValue(true)
model.updateSecurityLevelUsingConversation(chatRoom)

View file

@ -250,7 +250,7 @@ class ConversationViewModel
@WorkerThread
override fun onSubjectChanged(chatRoom: ChatRoom, eventLog: EventLog) {
Log.i("$TAG Conversation subject changed [${chatRoom.subject}]")
Log.i("$TAG Conversation subject changed [${chatRoom.subjectUtf8}]")
addEvents(arrayOf(eventLog))
}
@ -580,7 +580,7 @@ class ConversationViewModel
if (!chatRoom.hasCapability(ChatRoom.Capabilities.Encrypted.toInt())) {
if (LinphoneUtils.getAccountForAddress(chatRoom.localAddress)?.params?.instantMessagingEncryptionMandatory == true) {
Log.w(
"$TAG Conversation with subject [${chatRoom.subject}] is considered as read-only because it isn't encrypted and default account is in secure mode"
"$TAG Conversation with subject [${chatRoom.subjectUtf8}] is considered as read-only because it isn't encrypted and default account is in secure mode"
)
isDisabledBecauseNotSecured.postValue(true)
} else {
@ -655,12 +655,12 @@ class ConversationViewModel
val readOnly = chatRoom.isReadOnly
isReadOnly.postValue(readOnly)
if (readOnly) {
Log.w("$TAG Conversation with subject [${chatRoom.subject}] is read only!")
Log.w("$TAG Conversation with subject [${chatRoom.subjectUtf8}] is read only!")
}
checkIfConversationShouldBeDisabledForSecurityReasons()
subject.postValue(chatRoom.subject)
subject.postValue(chatRoom.subjectUtf8)
computeParticipantsInfo()
@ -693,7 +693,7 @@ class ConversationViewModel
val avatar = if (LinphoneUtils.isChatRoomAGroup(chatRoom)) {
val fakeFriend = coreContext.core.createFriend()
fakeFriend.name = chatRoom.subject
fakeFriend.name = chatRoom.subjectUtf8
val model = ContactAvatarModel(fakeFriend)
model.updateSecurityLevelUsingConversation(chatRoom)
model

View file

@ -85,7 +85,7 @@ class ConversationsListViewModel
if (state == ChatRoom.State.Instantiated) return
val id = LinphoneUtils.getConversationId(chatRoom)
Log.i("$TAG Conversation [$id] (${chatRoom.subject}) state changed: [$state]")
Log.i("$TAG Conversation [$id] (${chatRoom.subjectUtf8}) state changed: [$state]")
if (state == ChatRoom.State.Created) {
Log.i("$TAG Conversation [$id] successfully created")

View file

@ -63,7 +63,7 @@ class StartConversationViewModel
if (state == ChatRoom.State.Instantiated) return
val id = LinphoneUtils.getConversationId(chatRoom)
Log.i("$TAG Conversation [$id] (${chatRoom.subject}) state changed: [$state]")
Log.i("$TAG Conversation [$id] (${chatRoom.subjectUtf8}) state changed: [$state]")
if (state == ChatRoom.State.Created) {
Log.i("$TAG Conversation [$id] successfully created")

View file

@ -201,7 +201,7 @@ class ContactViewModel
if (state == ChatRoom.State.Instantiated) return
val id = LinphoneUtils.getConversationId(chatRoom)
Log.i("$TAG Conversation [$id] (${chatRoom.subject}) state changed: [$state]")
Log.i("$TAG Conversation [$id] (${chatRoom.subjectUtf8}) state changed: [$state]")
if (state == ChatRoom.State.Created) {
Log.i("$TAG Conversation [$id] successfully created")

View file

@ -110,7 +110,7 @@ class HistoryViewModel
if (state == ChatRoom.State.Instantiated) return
val id = LinphoneUtils.getConversationId(chatRoom)
Log.i("$TAG Conversation [$id] (${chatRoom.subject}) state changed: [$state]")
Log.i("$TAG Conversation [$id] (${chatRoom.subjectUtf8}) state changed: [$state]")
if (state == ChatRoom.State.Created) {
Log.i("$TAG Conversation [$id] successfully created")

View file

@ -448,7 +448,7 @@ abstract class AddressSelectionViewModel
null
}
} else {
if (chatRoom.subject.orEmpty().contains(filter, ignoreCase = true)) {
if (chatRoom.subjectUtf8.orEmpty().contains(filter, ignoreCase = true)) {
chatRoom
} else {
chatRoom.participants.find {
@ -491,7 +491,7 @@ abstract class AddressSelectionViewModel
val subject = if (isOneToOne) {
friend?.name
} else {
chatRoom.subject
chatRoom.subjectUtf8
}
val model = ConversationContactOrSuggestionModel(
remoteAddress,
@ -502,7 +502,7 @@ abstract class AddressSelectionViewModel
val avatarModel = if (!isOneToOne) {
val fakeFriend = coreContext.core.createFriend()
fakeFriend.name = chatRoom.subject
fakeFriend.name = chatRoom.subjectUtf8
val avatarModel = ContactAvatarModel(fakeFriend)
avatarModel.defaultToConversationIcon.postValue(true)
avatarModel

View file

@ -140,7 +140,7 @@ class ShortcutUtils {
).buildIcon()
} else {
isGroup = true
subject = chatRoom.subject.orEmpty()
subject = chatRoom.subjectUtf8.orEmpty()
AvatarGenerator(context).setInitials(AppUtils.getInitials(subject)).buildIcon()
}