diff --git a/app/src/main/java/org/linphone/ui/main/contacts/fragment/ContactFragment.kt b/app/src/main/java/org/linphone/ui/main/contacts/fragment/ContactFragment.kt
index 5f75a79d1..69cc5958f 100644
--- a/app/src/main/java/org/linphone/ui/main/contacts/fragment/ContactFragment.kt
+++ b/app/src/main/java/org/linphone/ui/main/contacts/fragment/ContactFragment.kt
@@ -41,6 +41,7 @@ import org.linphone.core.tools.Log
import org.linphone.databinding.ContactFragmentBinding
import org.linphone.ui.main.MainActivity
import org.linphone.ui.main.contacts.model.NumberOrAddressPickerDialogModel
+import org.linphone.ui.main.contacts.model.TrustCallDialogModel
import org.linphone.ui.main.contacts.viewmodel.ContactViewModel
import org.linphone.ui.main.fragment.GenericFragment
import org.linphone.utils.DialogUtils
@@ -178,6 +179,12 @@ class ContactFragment : GenericFragment() {
showTrustProcessDialog()
}
}
+
+ viewModel.startCallToDeviceToIncreaseTrustEvent.observe(viewLifecycleOwner) {
+ it.consume { pair ->
+ showConfirmTrustCallDialog(pair.first, pair.second)
+ }
+ }
}
private fun copyNumberOrAddressToClipboard(value: String, isSip: Boolean) {
@@ -225,4 +232,27 @@ class ContactFragment : GenericFragment() {
val dialog = DialogUtils.getContactTrustProcessExplanationDialog(requireActivity())
dialog.show()
}
+
+ private fun showConfirmTrustCallDialog(contact: String, device: String) {
+ val model = TrustCallDialogModel(contact, device)
+ val dialog = DialogUtils.getContactTrustCallConfirmationDialog(requireActivity(), model)
+
+ model.dismissEvent.observe(viewLifecycleOwner) {
+ it.consume {
+ dialog.dismiss()
+ }
+ }
+
+ model.confirmCallEvent.observe(viewLifecycleOwner) {
+ it.consume {
+ if (model.doNotShowAnymore.value == true) {
+ // TODO: never display this anymore
+ }
+ // TODO: start call
+ dialog.dismiss()
+ }
+ }
+
+ dialog.show()
+ }
}
diff --git a/app/src/main/java/org/linphone/ui/main/contacts/model/ContactDeviceModel.kt b/app/src/main/java/org/linphone/ui/main/contacts/model/ContactDeviceModel.kt
index 9fd2e3e9d..9360d7120 100644
--- a/app/src/main/java/org/linphone/ui/main/contacts/model/ContactDeviceModel.kt
+++ b/app/src/main/java/org/linphone/ui/main/contacts/model/ContactDeviceModel.kt
@@ -23,10 +23,11 @@ import androidx.annotation.UiThread
class ContactDeviceModel @UiThread constructor(
val name: String,
- val trusted: Boolean
+ val trusted: Boolean,
+ private val onCall: ((model: ContactDeviceModel) -> Unit)? = null
) {
@UiThread
fun startCallToDevice() {
- // TODO
+ onCall?.invoke(this)
}
}
diff --git a/app/src/main/java/org/linphone/ui/main/contacts/model/TrustCallDialogModel.kt b/app/src/main/java/org/linphone/ui/main/contacts/model/TrustCallDialogModel.kt
new file mode 100644
index 000000000..6a30a984d
--- /dev/null
+++ b/app/src/main/java/org/linphone/ui/main/contacts/model/TrustCallDialogModel.kt
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2010-2023 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 .
+ */
+package org.linphone.ui.main.contacts.model
+
+import androidx.annotation.UiThread
+import androidx.lifecycle.MutableLiveData
+import org.linphone.utils.Event
+
+class TrustCallDialogModel @UiThread constructor(contact: String, device: String) {
+ val message = MutableLiveData()
+
+ val doNotShowAnymore = MutableLiveData()
+
+ val dismissEvent = MutableLiveData>()
+
+ val confirmCallEvent = MutableLiveData>()
+
+ init {
+ message.value = "You're about to call $contact's device $device.\nAre you sure you want to make a call now?"
+ }
+
+ @UiThread
+ fun dismiss() {
+ dismissEvent.value = Event(true)
+ }
+
+ @UiThread
+ fun confirmCall() {
+ confirmCallEvent.value = Event(true)
+ }
+}
diff --git a/app/src/main/java/org/linphone/ui/main/contacts/viewmodel/ContactViewModel.kt b/app/src/main/java/org/linphone/ui/main/contacts/viewmodel/ContactViewModel.kt
index 3c4609086..6679bef13 100644
--- a/app/src/main/java/org/linphone/ui/main/contacts/viewmodel/ContactViewModel.kt
+++ b/app/src/main/java/org/linphone/ui/main/contacts/viewmodel/ContactViewModel.kt
@@ -88,6 +88,10 @@ class ContactViewModel @UiThread constructor() : ViewModel() {
MutableLiveData>()
}
+ val startCallToDeviceToIncreaseTrustEvent: MutableLiveData>> by lazy {
+ MutableLiveData>>()
+ }
+
private val listener = object : ContactNumberOrAddressClickListener {
@UiThread
override fun onClicked(model: ContactNumberOrAddressModel) {
@@ -219,7 +223,15 @@ class ContactViewModel @UiThread constructor() : ViewModel() {
// TODO FIXME: use real devices list from API
devicesList.add(ContactDeviceModel("Pixel 6 Pro de Sylvain", true))
devicesList.add(ContactDeviceModel("Sylvain Galaxy Tab S9 Pro+ Ultra", true))
- devicesList.add(ContactDeviceModel("MacBook Pro de Marcel", false))
+ devicesList.add(
+ ContactDeviceModel("MacBook Pro de Marcel", false) {
+ // TODO: check if do not show dialog anymore setting is set
+ if (::friend.isInitialized) {
+ startCallToDeviceToIncreaseTrustEvent.value =
+ Event(Pair(friend.name.orEmpty(), it.name))
+ }
+ }
+ )
devicesList.add(ContactDeviceModel("sylvain@fedora-linux-38", true))
devices.postValue(devicesList)
diff --git a/app/src/main/java/org/linphone/utils/DialogUtils.kt b/app/src/main/java/org/linphone/utils/DialogUtils.kt
index 35b597d04..8aa58ac98 100644
--- a/app/src/main/java/org/linphone/utils/DialogUtils.kt
+++ b/app/src/main/java/org/linphone/utils/DialogUtils.kt
@@ -33,11 +33,13 @@ import androidx.databinding.ViewDataBinding
import org.linphone.R
import org.linphone.databinding.DialogCancelContactChangesBinding
import org.linphone.databinding.DialogConfirmZrtpSasBinding
+import org.linphone.databinding.DialogContactConfirmTrustCallBinding
import org.linphone.databinding.DialogContactTrustProcessBinding
import org.linphone.databinding.DialogPickNumberOrAddressBinding
import org.linphone.databinding.DialogRemoveAllCallLogsBinding
import org.linphone.ui.main.calls.model.ConfirmationDialogModel
import org.linphone.ui.main.contacts.model.NumberOrAddressPickerDialogModel
+import org.linphone.ui.main.contacts.model.TrustCallDialogModel
import org.linphone.ui.voip.model.ZrtpSasConfirmationDialogModel
class DialogUtils {
@@ -58,6 +60,23 @@ class DialogUtils {
return getDialog(context, binding)
}
+ @UiThread
+ fun getContactTrustCallConfirmationDialog(
+ context: Context,
+ viewModel: TrustCallDialogModel
+ ): Dialog {
+ val binding: DialogContactConfirmTrustCallBinding = DataBindingUtil.inflate(
+ LayoutInflater.from(context),
+ R.layout.dialog_contact_confirm_trust_call,
+ null,
+ false
+ )
+ binding.viewModel = viewModel
+
+ return getDialog(context, binding)
+ }
+
+ @UiThread
fun getContactTrustProcessExplanationDialog(context: Context): Dialog {
val binding: DialogContactTrustProcessBinding = DataBindingUtil.inflate(
LayoutInflater.from(context),
diff --git a/app/src/main/res/layout/assistant_login_fragment.xml b/app/src/main/res/layout/assistant_login_fragment.xml
index 10de92365..4d36fd424 100644
--- a/app/src/main/res/layout/assistant_login_fragment.xml
+++ b/app/src/main/res/layout/assistant_login_fragment.xml
@@ -137,8 +137,8 @@
android:layout_marginTop="32dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
- android:paddingTop="13dp"
- android:paddingBottom="13dp"
+ android:paddingTop="@dimen/primary_secondary_buttons_label_padding"
+ android:paddingBottom="@dimen/primary_secondary_buttons_label_padding"
android:paddingStart="20dp"
android:paddingEnd="20dp"
android:text="Login"
@@ -210,8 +210,8 @@
android:layout_marginTop="22dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
- android:paddingTop="13dp"
- android:paddingBottom="13dp"
+ android:paddingTop="@dimen/primary_secondary_buttons_label_padding"
+ android:paddingBottom="@dimen/primary_secondary_buttons_label_padding"
android:paddingStart="20dp"
android:paddingEnd="20dp"
android:text="Scan QR code"
@@ -234,8 +234,8 @@
android:layout_marginTop="16dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
- android:paddingTop="13dp"
- android:paddingBottom="13dp"
+ android:paddingTop="@dimen/primary_secondary_buttons_label_padding"
+ android:paddingBottom="@dimen/primary_secondary_buttons_label_padding"
android:paddingStart="20dp"
android:paddingEnd="20dp"
android:text="Use third party SIP account"
@@ -252,8 +252,6 @@
android:id="@+id/no_account_yet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:paddingTop="13dp"
- android:paddingBottom="13dp"
android:paddingStart="20dp"
android:paddingEnd="20dp"
android:text="No account yet?"
@@ -274,8 +272,8 @@
android:layout_marginTop="40dp"
android:layout_marginStart="20dp"
android:layout_marginBottom="20dp"
- android:paddingTop="13dp"
- android:paddingBottom="13dp"
+ android:paddingTop="@dimen/primary_secondary_buttons_label_padding"
+ android:paddingBottom="@dimen/primary_secondary_buttons_label_padding"
android:paddingStart="20dp"
android:paddingEnd="20dp"
android:text="Register"
diff --git a/app/src/main/res/layout/assistant_register_fragment.xml b/app/src/main/res/layout/assistant_register_fragment.xml
index dee1362cd..ea8ad16fe 100644
--- a/app/src/main/res/layout/assistant_register_fragment.xml
+++ b/app/src/main/res/layout/assistant_register_fragment.xml
@@ -149,8 +149,8 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
- android:paddingTop="13dp"
- android:paddingBottom="13dp"
+ android:paddingTop="@dimen/primary_secondary_buttons_label_padding"
+ android:paddingBottom="@dimen/primary_secondary_buttons_label_padding"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:text="Create"
@@ -200,8 +200,6 @@
android:id="@+id/already_an_account"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:paddingTop="13dp"
- android:paddingBottom="13dp"
android:paddingStart="20dp"
android:paddingEnd="20dp"
android:text="Already an account?"
@@ -222,8 +220,8 @@
android:layout_marginTop="34dp"
android:layout_marginStart="20dp"
android:layout_marginBottom="20dp"
- android:paddingTop="13dp"
- android:paddingBottom="13dp"
+ android:paddingTop="@dimen/primary_secondary_buttons_label_padding"
+ android:paddingBottom="@dimen/primary_secondary_buttons_label_padding"
android:paddingStart="20dp"
android:paddingEnd="20dp"
android:text="Login"
diff --git a/app/src/main/res/layout/dialog_cancel_contact_changes.xml b/app/src/main/res/layout/dialog_cancel_contact_changes.xml
index d9d1cf1ef..a21fe4fca 100644
--- a/app/src/main/res/layout/dialog_cancel_contact_changes.xml
+++ b/app/src/main/res/layout/dialog_cancel_contact_changes.xml
@@ -47,7 +47,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
- android:paddingTop="25dp"
+ android:paddingTop="@dimen/dialog_top_bottom_margin"
android:text="Don't save changes?"
android:textSize="16sp"
app:layout_constraintVertical_chainStyle="packed"
@@ -101,8 +101,8 @@
android:layout_marginTop="16dp"
android:layout_marginStart="15dp"
android:layout_marginEnd="15dp"
- android:paddingBottom="13dp"
- android:paddingTop="13dp"
+ android:paddingBottom="@dimen/primary_secondary_buttons_label_padding"
+ android:paddingTop="@dimen/primary_secondary_buttons_label_padding"
android:gravity="center"
android:background="@drawable/primary_button_background"
android:text="Ok"
@@ -116,7 +116,7 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/dialog_contact_trust_process.xml b/app/src/main/res/layout/dialog_contact_trust_process.xml
index d79670620..9538dd7b7 100644
--- a/app/src/main/res/layout/dialog_contact_trust_process.xml
+++ b/app/src/main/res/layout/dialog_contact_trust_process.xml
@@ -46,7 +46,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
- android:paddingTop="25dp"
+ android:paddingTop="@dimen/dialog_top_bottom_margin"
android:text="What does it mean?"
android:textSize="16sp"
app:layout_constraintVertical_chainStyle="packed"
@@ -79,8 +79,8 @@
android:layout_marginTop="32dp"
android:layout_marginStart="15dp"
android:layout_marginEnd="15dp"
- android:paddingBottom="13dp"
- android:paddingTop="13dp"
+ android:paddingBottom="@dimen/primary_secondary_buttons_label_padding"
+ android:paddingTop="@dimen/primary_secondary_buttons_label_padding"
android:gravity="center"
android:background="@drawable/primary_button_background"
android:text="Ok"
@@ -94,7 +94,7 @@
@@ -36,7 +36,7 @@
android:layout_marginEnd="12dp"
android:layout_marginBottom="2dp"
android:src="@drawable/shape_dialog_background"
- app:layout_constraintBottom_toBottomOf="@id/numbers_and_addresses"
+ app:layout_constraintBottom_toBottomOf="@id/anchor"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/title" />
@@ -47,7 +47,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
- android:paddingTop="25dp"
+ android:paddingTop="@dimen/dialog_top_bottom_margin"
android:text="Which canal do you choose?"
android:textSize="16sp"
app:layout_constraintVertical_chainStyle="packed"
@@ -64,14 +64,22 @@
android:layout_marginTop="16dp"
android:layout_marginEnd="15dp"
android:orientation="vertical"
- android:paddingBottom="20dp"
app:entries="@{viewModel.sipAddressesAndPhoneNumbers}"
app:layout="@{@layout/dialog_number_address_list_cell}"
- app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintBottom_toTopOf="@id/anchor"
app:layout_constraintStart_toStartOf="@id/dialog_background"
app:layout_constraintEnd_toEndOf="@id/dialog_background"
app:layout_constraintTop_toBottomOf="@id/title" />
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/dialog_remove_all_call_logs.xml b/app/src/main/res/layout/dialog_remove_all_call_logs.xml
index 30428de4b..c55568c8b 100644
--- a/app/src/main/res/layout/dialog_remove_all_call_logs.xml
+++ b/app/src/main/res/layout/dialog_remove_all_call_logs.xml
@@ -47,7 +47,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
- android:paddingTop="25dp"
+ android:paddingTop="@dimen/dialog_top_bottom_margin"
android:text="Do you really want to delete all calls history?"
android:textSize="16sp"
app:layout_constraintVertical_chainStyle="packed"
@@ -80,8 +80,8 @@
android:layout_marginTop="32dp"
android:layout_marginStart="15dp"
android:layout_marginEnd="15dp"
- android:paddingBottom="13dp"
- android:paddingTop="13dp"
+ android:paddingBottom="@dimen/primary_secondary_buttons_label_padding"
+ android:paddingTop="@dimen/primary_secondary_buttons_label_padding"
android:gravity="center"
android:background="@drawable/secondary_button_background"
android:text="Cancel"
@@ -101,8 +101,8 @@
android:layout_marginTop="16dp"
android:layout_marginStart="15dp"
android:layout_marginEnd="15dp"
- android:paddingBottom="13dp"
- android:paddingTop="13dp"
+ android:paddingBottom="@dimen/primary_secondary_buttons_label_padding"
+ android:paddingTop="@dimen/primary_secondary_buttons_label_padding"
android:gravity="center"
android:background="@drawable/primary_button_background"
android:text="Ok"
@@ -116,7 +116,7 @@
5dp
2dp
+ 11dp
+ 20dp
+
55dp
70dp