mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 03:18:06 +00:00
Fixed group chat room security level indicator over avatar
This commit is contained in:
parent
5b80833f30
commit
c7586feebc
4 changed files with 41 additions and 0 deletions
|
|
@ -335,6 +335,7 @@ class ConversationModel @WorkerThread constructor(val chatRoom: ChatRoom) {
|
|||
fakeFriend.name = chatRoom.subject
|
||||
val model = ContactAvatarModel(fakeFriend)
|
||||
model.defaultToConversationIcon.postValue(true)
|
||||
model.updateSecurityLevelUsingConversation(chatRoom)
|
||||
avatarModel.postValue(model)
|
||||
} else {
|
||||
avatarModel.postValue(
|
||||
|
|
|
|||
|
|
@ -601,6 +601,7 @@ class ConversationInfoViewModel @UiThread constructor() : AbstractConversationVi
|
|||
fakeFriend.name = chatRoom.subject
|
||||
val model = ContactAvatarModel(fakeFriend)
|
||||
model.defaultToConversationIcon.postValue(true)
|
||||
model.updateSecurityLevelUsingConversation(chatRoom)
|
||||
model
|
||||
} else {
|
||||
participantsList.first().avatarModel
|
||||
|
|
|
|||
|
|
@ -563,6 +563,7 @@ class ConversationViewModel @UiThread constructor() : AbstractConversationViewMo
|
|||
val fakeFriend = coreContext.core.createFriend()
|
||||
fakeFriend.name = chatRoom.subject
|
||||
val model = ContactAvatarModel(fakeFriend)
|
||||
model.updateSecurityLevelUsingConversation(chatRoom)
|
||||
model
|
||||
} else {
|
||||
coreContext.contactsManager.getContactAvatarModelForAddress(address)
|
||||
|
|
|
|||
|
|
@ -22,13 +22,16 @@ package org.linphone.ui.main.contacts.model
|
|||
import android.net.Uri
|
||||
import androidx.annotation.WorkerThread
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.R
|
||||
import org.linphone.contacts.AbstractAvatarModel
|
||||
import org.linphone.contacts.getNativeContactPictureUri
|
||||
import org.linphone.core.Address
|
||||
import org.linphone.core.ChatRoom
|
||||
import org.linphone.core.ConsolidatedPresence
|
||||
import org.linphone.core.Friend
|
||||
import org.linphone.core.FriendListenerStub
|
||||
import org.linphone.core.SecurityLevel
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.utils.AppUtils
|
||||
import org.linphone.utils.TimestampUtils
|
||||
|
|
@ -92,6 +95,41 @@ class ContactAvatarModel @WorkerThread constructor(val friend: Friend, val addre
|
|||
computePresence(address)
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
fun updateSecurityLevelUsingConversation(chatRoom: ChatRoom) {
|
||||
/*
|
||||
// Don't do that, as chatRoom securityLevel is taking into account the security level
|
||||
// between the device and the other devices that shares the same SIP identity
|
||||
val securityLevel = when (chatRoom.securityLevel) {
|
||||
ChatRoom.SecurityLevel.Unsafe -> {
|
||||
SecurityLevel.Unsafe
|
||||
}
|
||||
ChatRoom.SecurityLevel.Encrypted -> {
|
||||
SecurityLevel.EndToEndEncrypted
|
||||
}
|
||||
ChatRoom.SecurityLevel.Safe -> {
|
||||
SecurityLevel.EndToEndEncryptedAndVerified
|
||||
}
|
||||
else -> SecurityLevel.None
|
||||
}*/
|
||||
|
||||
var lowestSecurityLevel = SecurityLevel.EndToEndEncryptedAndVerified
|
||||
for (participant in chatRoom.participants) {
|
||||
val friend = coreContext.contactsManager.findContactByAddress(participant.address)
|
||||
if (friend == null || friend.securityLevel == SecurityLevel.None) {
|
||||
lowestSecurityLevel = SecurityLevel.None
|
||||
} else if (friend.securityLevel == SecurityLevel.Unsafe) {
|
||||
lowestSecurityLevel = SecurityLevel.Unsafe
|
||||
break
|
||||
} else if (friend.securityLevel == SecurityLevel.EndToEndEncrypted || friend.securityLevel == SecurityLevel.PointToPointEncrypted) {
|
||||
if (lowestSecurityLevel != SecurityLevel.None) {
|
||||
lowestSecurityLevel = SecurityLevel.EndToEndEncrypted
|
||||
}
|
||||
}
|
||||
}
|
||||
trust.postValue(lowestSecurityLevel)
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
fun updateSecurityLevel(address: Address?) {
|
||||
if (address == null) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue