From d325203e8b05c6a4053d84c1a50e81a636e1239c Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Sat, 18 Nov 2023 15:46:03 +0100 Subject: [PATCH] Fixed in-call avatar not updated when ZRTP SAS is validated + scroll to top of calls logs history on resume --- .../ui/call/viewmodel/CurrentCallViewModel.kt | 28 ++++++++++++++----- .../history/fragment/HistoryListFragment.kt | 3 ++ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/org/linphone/ui/call/viewmodel/CurrentCallViewModel.kt b/app/src/main/java/org/linphone/ui/call/viewmodel/CurrentCallViewModel.kt index 9358810cd..cf022c0cb 100644 --- a/app/src/main/java/org/linphone/ui/call/viewmodel/CurrentCallViewModel.kt +++ b/app/src/main/java/org/linphone/ui/call/viewmodel/CurrentCallViewModel.kt @@ -705,8 +705,14 @@ class CurrentCallViewModel @UiThread constructor() : ViewModel() { "$TAG Current call media encryption is ZRTP, auth token is ${if (isDeviceTrusted) "trusted" else "not trusted yet"}" ) isRemoteDeviceTrusted.postValue(isDeviceTrusted) - val securityLevel = if (isDeviceTrusted) SecurityLevel.Encrypted else SecurityLevel.Safe - contact.value?.trust?.postValue(securityLevel) + val securityLevel = if (isDeviceTrusted) SecurityLevel.Safe else SecurityLevel.Encrypted + val avatarModel = contact.value + if (avatarModel != null) { + avatarModel.trust.postValue(securityLevel) + contact.postValue(avatarModel) + } else { + Log.e("$TAG No avatar model found!") + } isMediaEncrypted.postValue(true) // When Post Quantum is available, ZRTP is Post Quantum @@ -779,18 +785,26 @@ class CurrentCallViewModel @UiThread constructor() : ViewModel() { address.clean() displayedAddress.postValue(address.asStringUriOnly()) - val isDeviceTrusted = updateEncryption() - val securityLevel = if (isDeviceTrusted) SecurityLevel.Encrypted else SecurityLevel.Safe - val conferenceInfo = coreContext.core.findConferenceInformationFromUri( call.remoteAddress ) val model = if (conferenceInfo != null) { coreContext.contactsManager.getContactAvatarModelForConferenceInfo(conferenceInfo) } else { - coreContext.contactsManager.getContactAvatarModelForAddress(call.remoteAddress) + // Do not use contact avatar model from ContactsManager + // coreContext.contactsManager.getContactAvatarModelForAddress(call.remoteAddress) + val friend = coreContext.contactsManager.findContactByAddress(call.remoteAddress) + if (friend != null) { + ContactAvatarModel(friend) + } else { + val fakeFriend = coreContext.core.createFriend() + fakeFriend.name = LinphoneUtils.getDisplayName(address) + fakeFriend.address = call.remoteAddress + ContactAvatarModel(fakeFriend) + } } - model.trust.postValue(securityLevel) + updateEncryption() + contact.postValue(model) displayedName.postValue(model.friend.name) diff --git a/app/src/main/java/org/linphone/ui/main/history/fragment/HistoryListFragment.kt b/app/src/main/java/org/linphone/ui/main/history/fragment/HistoryListFragment.kt index e2f68031d..ffe52bbd2 100644 --- a/app/src/main/java/org/linphone/ui/main/history/fragment/HistoryListFragment.kt +++ b/app/src/main/java/org/linphone/ui/main/history/fragment/HistoryListFragment.kt @@ -240,6 +240,9 @@ class HistoryListFragment : AbstractTopBarFragment() { Log.i("$TAG Fragment is resumed, resetting missed calls count") sharedViewModel.resetMissedCallsCountEvent.value = Event(true) + + // Scroll to top to display latest call logs + binding.historyList.scrollToPosition(0) } private fun copyNumberOrAddressToClipboard(value: String) {