mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Hide zrtp dialog alert try again button after second failed attempt + added landscape layout + fixed security level update on avatar
This commit is contained in:
parent
af6cfdfc18
commit
ce3c37ad15
5 changed files with 172 additions and 19 deletions
|
|
@ -239,7 +239,8 @@ class ActiveCallFragment : GenericCallFragment() {
|
|||
doNotTint = true
|
||||
)
|
||||
} else {
|
||||
showZrtpAlertDialog()
|
||||
// Only allow "trying again" once
|
||||
showZrtpAlertDialog(callViewModel.zrtpSasValidationAttempts == 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -444,8 +445,8 @@ class ActiveCallFragment : GenericCallFragment() {
|
|||
zrtpSasDialog = dialog
|
||||
}
|
||||
|
||||
private fun showZrtpAlertDialog() {
|
||||
val model = ZrtpAlertDialogModel()
|
||||
private fun showZrtpAlertDialog(allowTryAgain: Boolean = true) {
|
||||
val model = ZrtpAlertDialogModel(allowTryAgain)
|
||||
val dialog = DialogUtils.getZrtpAlertDialog(requireActivity(), model)
|
||||
|
||||
model.tryAgainEvent.observe(viewLifecycleOwner) { event ->
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import androidx.lifecycle.MutableLiveData
|
|||
import org.linphone.ui.GenericViewModel
|
||||
import org.linphone.utils.Event
|
||||
|
||||
class ZrtpAlertDialogModel @UiThread constructor() : GenericViewModel() {
|
||||
class ZrtpAlertDialogModel @UiThread constructor(val allowTryAgain: Boolean) : GenericViewModel() {
|
||||
companion object {
|
||||
private const val TAG = "[ZRTP Alert Dialog]"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -177,6 +177,8 @@ class CurrentCallViewModel @UiThread constructor() : GenericViewModel() {
|
|||
MutableLiveData<Event<Boolean>>()
|
||||
}
|
||||
|
||||
var zrtpSasValidationAttempts = 0
|
||||
|
||||
// Chat
|
||||
|
||||
val operationInProgress = MutableLiveData<Boolean>()
|
||||
|
|
@ -243,11 +245,14 @@ class CurrentCallViewModel @UiThread constructor() : GenericViewModel() {
|
|||
Log.w(
|
||||
"$TAG Notified that authentication token is [${if (verified) "verified" else "not verified!"}]"
|
||||
)
|
||||
zrtpSasValidationAttempts += 1
|
||||
isZrtpSasValidationRequired.postValue(!verified)
|
||||
zrtpAuthTokenVerifiedEvent.postValue(Event(verified))
|
||||
if (verified) {
|
||||
isMediaEncrypted.postValue(true)
|
||||
}
|
||||
|
||||
updateAvatarModelSecurityLevel(verified)
|
||||
}
|
||||
|
||||
override fun onRemoteRecording(call: Call, recording: Boolean) {
|
||||
|
|
@ -991,21 +996,7 @@ class CurrentCallViewModel @UiThread constructor() : GenericViewModel() {
|
|||
"$TAG Current call media encryption is ZRTP, auth token is [${if (isDeviceTrusted) "trusted" else "not trusted yet"}], cache mismatch is [$cacheMismatch]"
|
||||
)
|
||||
|
||||
val securityLevel = if (isDeviceTrusted) SecurityLevel.EndToEndEncryptedAndVerified else SecurityLevel.EndToEndEncrypted
|
||||
val avatarModel = contact.value
|
||||
if (avatarModel != null && currentCall.conference == null) { // Don't do it for conferences
|
||||
avatarModel.trust.postValue(securityLevel)
|
||||
contact.postValue(avatarModel!!)
|
||||
|
||||
// Also update avatar contact model if any for the rest of the app
|
||||
val address = currentCall.remoteAddress
|
||||
val storedModel = coreContext.contactsManager.getContactAvatarModelForAddress(
|
||||
address
|
||||
)
|
||||
storedModel.updateSecurityLevel(address)
|
||||
} else {
|
||||
Log.e("$TAG No avatar model found!")
|
||||
}
|
||||
updateAvatarModelSecurityLevel(isDeviceTrusted && !cacheMismatch)
|
||||
|
||||
isMediaEncrypted.postValue(true)
|
||||
isZrtp.postValue(true)
|
||||
|
|
@ -1053,6 +1044,7 @@ class CurrentCallViewModel @UiThread constructor() : GenericViewModel() {
|
|||
isMediaEncrypted.postValue(false)
|
||||
|
||||
terminatedByUsed = false
|
||||
zrtpSasValidationAttempts = 0
|
||||
currentCall = call
|
||||
callStatsModel.update(call, call.audioStats)
|
||||
callMediaEncryptionModel.update(call)
|
||||
|
|
@ -1231,4 +1223,23 @@ class CurrentCallViewModel @UiThread constructor() : GenericViewModel() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
private fun updateAvatarModelSecurityLevel(trusted: Boolean) {
|
||||
val securityLevel = if (trusted) SecurityLevel.EndToEndEncryptedAndVerified else SecurityLevel.EndToEndEncrypted
|
||||
val avatarModel = contact.value
|
||||
if (avatarModel != null && currentCall.conference == null) { // Don't do it for conferences
|
||||
avatarModel.trust.postValue(securityLevel)
|
||||
contact.postValue(avatarModel!!)
|
||||
} else {
|
||||
Log.e("$TAG No avatar model found!")
|
||||
}
|
||||
|
||||
// Also update avatar contact model if any for the rest of the app
|
||||
val address = currentCall.remoteAddress
|
||||
val storedModel = coreContext.contactsManager.getContactAvatarModelForAddress(
|
||||
address
|
||||
)
|
||||
storedModel.updateSecurityLevel(address)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
140
app/src/main/res/layout-land/dialog_zrtp_security_alert.xml
Normal file
140
app/src/main/res/layout-land/dialog_zrtp_security_alert.xml
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<data>
|
||||
<import type="android.view.View" />
|
||||
<import type="android.graphics.Typeface" />
|
||||
<variable
|
||||
name="viewModel"
|
||||
type="org.linphone.ui.call.model.ZrtpAlertDialogModel" />
|
||||
</data>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginEnd="10dp">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/header"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/shape_zrtp_dialog_error_header_background"
|
||||
app:layout_constraintVertical_chainStyle="packed"
|
||||
app:layout_constraintWidth_max="@dimen/dialog_max_width"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@id/body"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/header_icon"
|
||||
android:layout_width="@dimen/icon_size"
|
||||
android:layout_height="@dimen/icon_size"
|
||||
android:layout_marginTop="10dp"
|
||||
android:src="@drawable/shield_warning"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:tint="@color/white" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/default_text_style_700"
|
||||
android:id="@id/header_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:text="@string/call_dialog_zrtp_security_alert_title"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/white"
|
||||
app:layout_constraintTop_toBottomOf="@id/header_icon"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/body"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/shape_zrtp_dialog_error_background"
|
||||
app:layout_constraintWidth_max="@dimen/dialog_max_width"
|
||||
app:layout_constraintTop_toBottomOf="@id/header"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/default_text_style"
|
||||
android:id="@+id/message"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="15dp"
|
||||
android:layout_marginEnd="15dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:text="@string/call_dialog_zrtp_security_alert_message"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/gray_main2_600"
|
||||
android:gravity="center"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/default_text_style_600"
|
||||
android:id="@+id/try_again"
|
||||
android:onClick="@{() -> viewModel.tryAgain()}"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="15dp"
|
||||
android:layout_marginStart="30dp"
|
||||
android:layout_marginEnd="30dp"
|
||||
android:paddingBottom="@dimen/primary_secondary_buttons_label_padding"
|
||||
android:paddingTop="@dimen/primary_secondary_buttons_label_padding"
|
||||
android:gravity="center"
|
||||
android:background="@drawable/shape_red_outlined_button_background"
|
||||
android:text="@string/call_dialog_zrtp_security_alert_try_again"
|
||||
android:textSize="18sp"
|
||||
android:textColor="?attr/color_danger_500"
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
android:visibility="@{viewModel.allowTryAgain ? View.VISIBLE : View.GONE, default=gone}"
|
||||
app:layout_constraintWidth_max="@dimen/button_max_width"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/message"
|
||||
app:layout_constraintBottom_toTopOf="@id/hang_up"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/default_text_style_600"
|
||||
android:id="@+id/hang_up"
|
||||
android:onClick="@{() -> viewModel.hangUp()}"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="15dp"
|
||||
android:layout_marginBottom="15dp"
|
||||
android:layout_marginStart="30dp"
|
||||
android:layout_marginEnd="30dp"
|
||||
android:paddingBottom="@dimen/primary_secondary_buttons_label_padding"
|
||||
android:paddingTop="@dimen/primary_secondary_buttons_label_padding"
|
||||
android:gravity="center"
|
||||
android:background="@drawable/shape_red_button_background"
|
||||
android:text="@string/call_action_hang_up"
|
||||
android:textSize="18sp"
|
||||
android:textColor="@color/white"
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
app:layout_constraintWidth_max="@dimen/button_max_width"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/try_again"
|
||||
app:layout_constraintBottom_toBottomOf="parent"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</layout>
|
||||
|
|
@ -95,6 +95,7 @@
|
|||
android:textColor="?attr/color_danger_500"
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
android:visibility="@{viewModel.allowTryAgain ? View.VISIBLE : View.GONE, default=gone}"
|
||||
app:layout_constraintWidth_max="@dimen/button_max_width"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue