Fixed trust icon not visible when leaving & going back into call

This commit is contained in:
Sylvain Berfini 2023-08-25 11:12:19 +02:00
parent cb9c43c2e7
commit 424d805def
3 changed files with 19 additions and 10 deletions

View file

@ -344,7 +344,7 @@ class CurrentCallViewModel @UiThread constructor() : ViewModel() {
}
@WorkerThread
private fun updateEncryption() {
private fun updateEncryption(): Boolean {
when (call.currentParams.mediaEncryption) {
MediaEncryption.ZRTP -> {
val authToken = call.authenticationToken
@ -359,12 +359,15 @@ class CurrentCallViewModel @UiThread constructor() : ViewModel() {
Log.i("$TAG Showing ZRTP SAS confirmation dialog")
showZrtpSasDialog(authToken!!.uppercase(Locale.getDefault()))
}
return deviceIsTrusted
}
MediaEncryption.SRTP, MediaEncryption.DTLS -> {
}
else -> {
}
}
return false
}
@WorkerThread
@ -387,19 +390,23 @@ class CurrentCallViewModel @UiThread constructor() : ViewModel() {
address.clean()
displayedAddress.postValue(address.asStringUriOnly())
val isDeviceTrusted = updateEncryption()
val friend = call.core.findFriend(address)
if (friend != null) {
displayedName.postValue(friend.name)
contact.postValue(ContactAvatarModel(friend))
val model = ContactAvatarModel(friend)
model.showTrust.postValue(isDeviceTrusted)
contact.postValue(model)
} else {
val fakeFriend = coreContext.core.createFriend()
fakeFriend.name = LinphoneUtils.getDisplayName(address)
fakeFriend.addAddress(address)
contact.postValue(ContactAvatarModel(fakeFriend))
val model = ContactAvatarModel(fakeFriend)
model.showTrust.postValue(isDeviceTrusted)
contact.postValue(model)
displayedName.postValue(fakeFriend.name)
}
updateEncryption()
callDuration.postValue(call.duration)
}

View file

@ -32,19 +32,20 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginTop="7dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:text="Incoming call"
android:textColor="@color/white"
android:textSize="16sp"
app:layout_constraintStart_toEndOf="@id/call_direction_icon"
app:layout_constraintTop_toTopOf="parent"/>
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/background"/>
<ImageView
android:id="@+id/background"
android:src="@drawable/shape_round_in_call_gray_background"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="17dp"
android:layout_marginStart="12dp"
android:layout_marginEnd="12dp"
app:layout_constraintTop_toBottomOf="@id/call_direction_label"

View file

@ -32,12 +32,14 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginTop="7dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:text="Outgoing call"
android:textColor="@color/white"
android:textSize="16sp"
app:layout_constraintStart_toEndOf="@id/call_direction_icon"
app:layout_constraintTop_toTopOf="parent"/>
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/background"/>
<ImageView
android:onClick="@{() -> viewModel.switchCamera()}"
@ -58,7 +60,6 @@
android:src="@drawable/shape_round_in_call_gray_background"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="17dp"
android:layout_marginStart="12dp"
android:layout_marginEnd="12dp"
app:layout_constraintTop_toBottomOf="@id/call_direction_label"