Finished contact trust explanation dialog

This commit is contained in:
Sylvain Berfini 2024-07-15 11:26:58 +02:00
parent 6cabf0bdf7
commit 6c757a9637
8 changed files with 117 additions and 12 deletions

View file

@ -45,6 +45,7 @@ import org.linphone.core.Factory
import org.linphone.core.tools.Log
import org.linphone.databinding.ContactFragmentBinding
import org.linphone.ui.GenericActivity
import org.linphone.ui.main.contacts.model.ContactTrustDialogModel
import org.linphone.ui.main.contacts.model.NumberOrAddressPickerDialogModel
import org.linphone.ui.main.contacts.model.TrustCallDialogModel
import org.linphone.ui.main.contacts.viewmodel.ContactViewModel
@ -297,7 +298,10 @@ class ContactFragment : SlidingPaneChildFragment() {
}
private fun showTrustProcessDialog() {
val dialog = DialogUtils.getContactTrustProcessExplanationDialog(requireActivity())
val initials = viewModel.contact.value?.initials?.value ?: "JD"
val picture = viewModel.contact.value?.picturePath?.value.orEmpty()
val model = ContactTrustDialogModel(initials, picture)
val dialog = DialogUtils.getContactTrustProcessExplanationDialog(requireActivity(), model)
dialog.show()
}

View file

@ -0,0 +1,41 @@
/*
* Copyright (c) 2010-2024 Belledonne Communications SARL.
*
* This file is part of linphone-android
* (see https://www.linphone.org).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.linphone.ui.main.contacts.model
import androidx.annotation.UiThread
import org.linphone.contacts.AbstractAvatarModel
import org.linphone.core.SecurityLevel
@UiThread
class ContactTrustDialogModel(initials: String, picturePath: String) {
val avatarModel = FakeAvatarModel(initials, picturePath, false)
val trustedAvatarModel = FakeAvatarModel(initials, picturePath, true)
@UiThread
class FakeAvatarModel(contactInitials: String, contactPicturePath: String, trusted: Boolean) : AbstractAvatarModel() {
init {
initials.value = contactInitials
picturePath.value = contactPicturePath
showTrust.value = trusted
trust.value = SecurityLevel.EndToEndEncryptedAndVerified
}
}
}

View file

@ -425,7 +425,7 @@ private fun loadContactPictureWithCoil(
}
val image = model.picturePath.value.orEmpty()
if (image != null) {
if (image.isNotEmpty()) {
imageView.load(image) {
transformations(CircleCropTransformation())
listener(

View file

@ -58,6 +58,7 @@ import org.linphone.ui.assistant.model.AcceptConditionsAndPolicyDialogModel
import org.linphone.ui.assistant.model.ConfirmPhoneNumberDialogModel
import org.linphone.ui.call.model.ZrtpAlertDialogModel
import org.linphone.ui.call.model.ZrtpSasConfirmationDialogModel
import org.linphone.ui.main.contacts.model.ContactTrustDialogModel
import org.linphone.ui.main.contacts.model.NumberOrAddressPickerDialogModel
import org.linphone.ui.main.contacts.model.TrustCallDialogModel
import org.linphone.ui.main.fragment.AuthRequestedDialogModel
@ -170,13 +171,18 @@ class DialogUtils {
}
@UiThread
fun getContactTrustProcessExplanationDialog(context: Context): Dialog {
fun getContactTrustProcessExplanationDialog(
context: Context,
viewModel: ContactTrustDialogModel
): Dialog {
val binding: DialogContactTrustProcessBinding = DataBindingUtil.inflate(
LayoutInflater.from(context),
R.layout.dialog_contact_trust_process,
null,
false
)
binding.viewModel = viewModel
val dialog = getDialog(context, binding)
binding.setDismissClickListener {

View file

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="256"
android:viewportHeight="256">
<path
android:pathData="M221.66,133.66l-72,72a8,8 0,0 1,-11.32 -11.32L196.69,136H40a8,8 0,0 1,0 -16H196.69L138.34,61.66a8,8 0,0 1,11.32 -11.32l72,72A8,8 0,0 1,221.66 133.66Z"
android:fillColor="#4e6074"/>
</vector>

View file

@ -1,13 +1,16 @@
<?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">
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:bind="http://schemas.android.com/tools">
<data>
<import type="android.view.View" />
<variable
name="dismissClickListener"
type="View.OnClickListener" />
<variable
name="viewModel"
type="org.linphone.ui.main.contacts.model.ContactTrustDialogModel" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
@ -54,11 +57,53 @@
android:layout_marginTop="10dp"
android:text="@string/contact_dialog_devices_trust_help_message"
android:textSize="14sp"
app:layout_constraintBottom_toTopOf="@id/confirm"
app:layout_constraintBottom_toTopOf="@id/image1"
app:layout_constraintStart_toStartOf="@id/dialog_background"
app:layout_constraintEnd_toEndOf="@id/dialog_background"
app:layout_constraintTop_toBottomOf="@id/title" />
<include
android:id="@+id/image1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginTop="32dp"
layout="@layout/contact_avatar"
bind:model="@{viewModel.avatarModel}"
bind:hidePresence="@{true}"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/arrow"
app:layout_constraintTop_toBottomOf="@id/message"
app:layout_constraintBottom_toTopOf="@id/confirm" />
<ImageView
android:id="@+id/arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:src="@drawable/arrow_right"
android:contentDescription="@null"
app:tint="?attr/color_main2_600"
app:layout_constraintStart_toEndOf="@id/image1"
app:layout_constraintEnd_toStartOf="@id/image2"
app:layout_constraintTop_toTopOf="@id/image1"
app:layout_constraintBottom_toBottomOf="@id/image1"/>
<include
android:id="@+id/image2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
layout="@layout/contact_avatar"
bind:model="@{viewModel.trustedAvatarModel}"
bind:hidePresence="@{true}"
app:strokeWidth="@dimen/avatar_trust_border_width"
app:strokeColor="?attr/color_info_500"
app:layout_constraintStart_toEndOf="@id/arrow"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/image1"
app:layout_constraintBottom_toBottomOf="@id/image1"/>
<androidx.appcompat.widget.AppCompatTextView
android:onClick="@{dismissClickListener}"
style="@style/primary_button_label_style"
@ -71,7 +116,7 @@
android:text="@string/dialog_ok"
app:layout_constraintStart_toStartOf="@id/dialog_background"
app:layout_constraintEnd_toEndOf="@id/dialog_background"
app:layout_constraintTop_toBottomOf="@id/message"
app:layout_constraintTop_toBottomOf="@id/image1"
app:layout_constraintBottom_toTopOf="@id/anchor"/>
<View

View file

@ -364,8 +364,8 @@
<string name="contact_dialog_increase_trust_level_title">Augmenter le niveau de confiance</string>
<string name="contact_dialog_increase_trust_level_message">Vous êtes sur le point de passer un appel vers l\'appareil $2%s\ de $1%s.\Voulez-vous démarrer l\'appel ?</string>
<string name="contact_dialog_devices_trust_help_title">What does it mean?</string>
<string name="contact_dialog_devices_trust_help_message">Blah blah blah</string> <!-- TODO FIXME -->
<string name="contact_dialog_devices_trust_help_title">Niveau de confiance</string>
<string name="contact_dialog_devices_trust_help_message">Vérifiez les appareils de votre contact pour confirmer que vos communications seront sécurisées et sans compromission.\nQuand tous seront vérifiés, vous atteindrez le niveau de confiance maximal.</string>
<string name="contact_dialog_delete_title">Supprimer %s ?</string>
<string name="contact_dialog_delete_message">Ce contact sera définitivement supprimé.</string>
<string name="contact_dialog_pick_phone_number_or_sip_address_title">Choisissez un numéro ou adresse SIP</string>

View file

@ -402,8 +402,8 @@
<string name="contact_dialog_increase_trust_level_title">Increase trust level</string>
<string name="contact_dialog_increase_trust_level_message">You\'re about to make a call to $1%s\'s device $2%s.\nDo you want to make the call?</string>
<string name="contact_dialog_devices_trust_help_title">What does it mean?</string>
<string name="contact_dialog_devices_trust_help_message">Blah blah blah</string> <!-- TODO FIXME -->
<string name="contact_dialog_devices_trust_help_title">Trust level</string>
<string name="contact_dialog_devices_trust_help_message">Check all of your contact devices to make sure your communications will be secured an unaltered.\nWhen all will be verified, you\'ll reach maximum trust level.</string>
<string name="contact_dialog_delete_title">Delete %s?</string>
<string name="contact_dialog_delete_message">This contact will be definitively removed.</string>
<string name="contact_dialog_pick_phone_number_or_sip_address_title">Choose a number or a SIP address</string>