mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 19:38:08 +00:00
Added trust explanation dialog in contact detail + improved DialogUtils class
This commit is contained in:
parent
cc99d4f93f
commit
7016afa6f8
6 changed files with 173 additions and 53 deletions
|
|
@ -30,7 +30,6 @@ import androidx.navigation.navGraphViewModels
|
|||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.R
|
||||
import org.linphone.core.Address
|
||||
import org.linphone.databinding.CallStartFragmentBinding
|
||||
import org.linphone.ui.main.calls.adapter.SuggestionsListAdapter
|
||||
import org.linphone.ui.main.calls.viewmodel.StartCallViewModel
|
||||
|
|
@ -66,7 +65,8 @@ class StartCallFragment : GenericFragment() {
|
|||
|
||||
private val listener = object : ContactNumberOrAddressClickListener {
|
||||
@UiThread
|
||||
override fun onClicked(address: Address?) {
|
||||
override fun onClicked(model: ContactNumberOrAddressModel) {
|
||||
val address = model.address
|
||||
if (address != null) {
|
||||
coreContext.postOnCoreThread {
|
||||
coreContext.startCall(address)
|
||||
|
|
|
|||
|
|
@ -172,6 +172,12 @@ class ContactFragment : GenericFragment() {
|
|||
shareContact(file)
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.displayTrustProcessDialogEvent.observe(viewLifecycleOwner) {
|
||||
it.consume {
|
||||
showTrustProcessDialog()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun copyNumberOrAddressToClipboard(value: String, isSip: Boolean) {
|
||||
|
|
@ -214,4 +220,9 @@ class ContactFragment : GenericFragment() {
|
|||
}
|
||||
startActivity(smsIntent)
|
||||
}
|
||||
|
||||
private fun showTrustProcessDialog() {
|
||||
val dialog = DialogUtils.getContactTrustProcessExplanationDialog(requireActivity())
|
||||
dialog.show()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,6 +84,10 @@ class ContactViewModel @UiThread constructor() : ViewModel() {
|
|||
MutableLiveData<Event<File>>()
|
||||
}
|
||||
|
||||
val displayTrustProcessDialogEvent: MutableLiveData<Event<Boolean>> by lazy {
|
||||
MutableLiveData<Event<Boolean>>()
|
||||
}
|
||||
|
||||
private val listener = object : ContactNumberOrAddressClickListener {
|
||||
@UiThread
|
||||
override fun onClicked(model: ContactNumberOrAddressModel) {
|
||||
|
|
@ -234,6 +238,11 @@ class ContactViewModel @UiThread constructor() : ViewModel() {
|
|||
expandDevicesTrust.value = expandDevicesTrust.value == false
|
||||
}
|
||||
|
||||
@UiThread
|
||||
fun displayTrustDialog() {
|
||||
displayTrustProcessDialogEvent.value = Event(true)
|
||||
}
|
||||
|
||||
@UiThread
|
||||
fun editContact() {
|
||||
coreContext.postOnCoreThread {
|
||||
|
|
|
|||
|
|
@ -29,9 +29,11 @@ import android.view.WindowManager
|
|||
import androidx.annotation.UiThread
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.databinding.ViewDataBinding
|
||||
import org.linphone.R
|
||||
import org.linphone.databinding.DialogCancelContactChangesBinding
|
||||
import org.linphone.databinding.DialogConfirmZrtpSasBinding
|
||||
import org.linphone.databinding.DialogContactTrustProcessBinding
|
||||
import org.linphone.databinding.DialogPickNumberOrAddressBinding
|
||||
import org.linphone.databinding.DialogRemoveAllCallLogsBinding
|
||||
import org.linphone.ui.main.calls.model.ConfirmationDialogModel
|
||||
|
|
@ -45,9 +47,6 @@ class DialogUtils {
|
|||
context: Context,
|
||||
viewModel: NumberOrAddressPickerDialogModel
|
||||
): Dialog {
|
||||
val dialog = Dialog(context, R.style.Theme_LinphoneDialog)
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE)
|
||||
|
||||
val binding: DialogPickNumberOrAddressBinding = DataBindingUtil.inflate(
|
||||
LayoutInflater.from(context),
|
||||
R.layout.dialog_pick_number_or_address,
|
||||
|
|
@ -55,18 +54,23 @@ class DialogUtils {
|
|||
false
|
||||
)
|
||||
binding.viewModel = viewModel
|
||||
dialog.setContentView(binding.root)
|
||||
|
||||
val d: Drawable = ColorDrawable(
|
||||
ContextCompat.getColor(dialog.context, R.color.dialog_background)
|
||||
return getDialog(context, binding)
|
||||
}
|
||||
|
||||
fun getContactTrustProcessExplanationDialog(context: Context): Dialog {
|
||||
val binding: DialogContactTrustProcessBinding = DataBindingUtil.inflate(
|
||||
LayoutInflater.from(context),
|
||||
R.layout.dialog_contact_trust_process,
|
||||
null,
|
||||
false
|
||||
)
|
||||
d.alpha = 166
|
||||
dialog.window
|
||||
?.setLayout(
|
||||
WindowManager.LayoutParams.MATCH_PARENT,
|
||||
WindowManager.LayoutParams.MATCH_PARENT
|
||||
)
|
||||
dialog.window?.setBackgroundDrawable(d)
|
||||
val dialog = getDialog(context, binding)
|
||||
|
||||
binding.setDismissClickListener {
|
||||
dialog.dismiss()
|
||||
}
|
||||
|
||||
return dialog
|
||||
}
|
||||
|
||||
|
|
@ -75,9 +79,6 @@ class DialogUtils {
|
|||
context: Context,
|
||||
model: ConfirmationDialogModel
|
||||
): Dialog {
|
||||
val dialog = Dialog(context, R.style.Theme_LinphoneDialog)
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE)
|
||||
|
||||
val binding: DialogRemoveAllCallLogsBinding = DataBindingUtil.inflate(
|
||||
LayoutInflater.from(context),
|
||||
R.layout.dialog_remove_all_call_logs,
|
||||
|
|
@ -85,19 +86,8 @@ class DialogUtils {
|
|||
false
|
||||
)
|
||||
binding.viewModel = model
|
||||
dialog.setContentView(binding.root)
|
||||
|
||||
val d: Drawable = ColorDrawable(
|
||||
ContextCompat.getColor(dialog.context, R.color.dialog_background)
|
||||
)
|
||||
d.alpha = 166
|
||||
dialog.window
|
||||
?.setLayout(
|
||||
WindowManager.LayoutParams.MATCH_PARENT,
|
||||
WindowManager.LayoutParams.MATCH_PARENT
|
||||
)
|
||||
dialog.window?.setBackgroundDrawable(d)
|
||||
return dialog
|
||||
return getDialog(context, binding)
|
||||
}
|
||||
|
||||
@UiThread
|
||||
|
|
@ -105,9 +95,6 @@ class DialogUtils {
|
|||
context: Context,
|
||||
model: ConfirmationDialogModel
|
||||
): Dialog {
|
||||
val dialog = Dialog(context, R.style.Theme_LinphoneDialog)
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE)
|
||||
|
||||
val binding: DialogCancelContactChangesBinding = DataBindingUtil.inflate(
|
||||
LayoutInflater.from(context),
|
||||
R.layout.dialog_cancel_contact_changes,
|
||||
|
|
@ -115,19 +102,8 @@ class DialogUtils {
|
|||
false
|
||||
)
|
||||
binding.viewModel = model
|
||||
dialog.setContentView(binding.root)
|
||||
|
||||
val d: Drawable = ColorDrawable(
|
||||
ContextCompat.getColor(dialog.context, R.color.dialog_background)
|
||||
)
|
||||
d.alpha = 166
|
||||
dialog.window
|
||||
?.setLayout(
|
||||
WindowManager.LayoutParams.MATCH_PARENT,
|
||||
WindowManager.LayoutParams.MATCH_PARENT
|
||||
)
|
||||
dialog.window?.setBackgroundDrawable(d)
|
||||
return dialog
|
||||
return getDialog(context, binding)
|
||||
}
|
||||
|
||||
@UiThread
|
||||
|
|
@ -135,9 +111,6 @@ class DialogUtils {
|
|||
context: Context,
|
||||
viewModel: ZrtpSasConfirmationDialogModel
|
||||
): Dialog {
|
||||
val dialog = Dialog(context, R.style.Theme_LinphoneDialog)
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE)
|
||||
|
||||
val binding: DialogConfirmZrtpSasBinding = DataBindingUtil.inflate(
|
||||
LayoutInflater.from(context),
|
||||
R.layout.dialog_confirm_zrtp_sas,
|
||||
|
|
@ -145,6 +118,13 @@ class DialogUtils {
|
|||
false
|
||||
)
|
||||
binding.viewModel = viewModel
|
||||
|
||||
return getDialog(context, binding)
|
||||
}
|
||||
|
||||
private fun getDialog(context: Context, binding: ViewDataBinding): Dialog {
|
||||
val dialog = Dialog(context, R.style.Theme_LinphoneDialog)
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE)
|
||||
dialog.setContentView(binding.root)
|
||||
|
||||
val d: Drawable = ColorDrawable(
|
||||
|
|
|
|||
|
|
@ -346,19 +346,34 @@
|
|||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/default_text_style_800"
|
||||
android:onClick="@{() -> viewModel.toggleDevicesTrustExpand()}"
|
||||
android:onClick="@{() -> viewModel.displayTrustDialog()}"
|
||||
android:id="@+id/trust_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="26dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:padding="5dp"
|
||||
android:text="Trust"
|
||||
android:textSize="16sp"
|
||||
android:drawableEnd="@drawable/question"
|
||||
android:drawableTint="@color/gray_9"
|
||||
android:drawablePadding="8dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/info_background"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/default_text_style_800"
|
||||
android:onClick="@{() -> viewModel.toggleDevicesTrustExpand()}"
|
||||
android:id="@+id/trust_toggle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="5dp"
|
||||
android:layout_marginStart="26dp"
|
||||
android:layout_marginEnd="26dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:text="Trust"
|
||||
android:padding="5dp"
|
||||
android:drawableEnd="@{viewModel.expandDevicesTrust ? @drawable/caret_up : @drawable/caret_down, default=@drawable/caret_up}"
|
||||
android:drawableTint="@color/gray_9"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/trust_label"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/info_background"/>
|
||||
|
||||
|
|
|
|||
105
app/src/main/res/layout/dialog_contact_trust_process.xml
Normal file
105
app/src/main/res/layout/dialog_contact_trust_process.xml
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
<?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" />
|
||||
<variable
|
||||
name="dismissClickListener"
|
||||
type="View.OnClickListener" />
|
||||
</data>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:onClick="@{dismissClickListener}"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clickable="true"
|
||||
android:focusable="true">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/dialog_background_shadow"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:src="@drawable/shape_dialog_orange_shadow"
|
||||
app:layout_constraintBottom_toBottomOf="@id/anchor"
|
||||
app:layout_constraintEnd_toEndOf="@id/dialog_background"
|
||||
app:layout_constraintStart_toStartOf="@id/dialog_background"
|
||||
app:layout_constraintTop_toTopOf="@id/dialog_background" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/dialog_background"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginEnd="12dp"
|
||||
android:layout_marginBottom="2dp"
|
||||
android:src="@drawable/shape_dialog_background"
|
||||
app:layout_constraintBottom_toBottomOf="@id/anchor"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/title" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/default_text_style_800"
|
||||
android:id="@+id/title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="15dp"
|
||||
android:paddingTop="25dp"
|
||||
android:text="What does it mean?"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintVertical_chainStyle="packed"
|
||||
app:layout_constraintBottom_toTopOf="@id/message"
|
||||
app:layout_constraintStart_toStartOf="@id/dialog_background"
|
||||
app:layout_constraintEnd_toEndOf="@id/dialog_background"
|
||||
app:layout_constraintTop_toTopOf="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="Lorem ipsum dolot sit amet"
|
||||
android:textSize="14sp"
|
||||
app:layout_constraintBottom_toTopOf="@id/confirm"
|
||||
app:layout_constraintStart_toStartOf="@id/dialog_background"
|
||||
app:layout_constraintEnd_toEndOf="@id/dialog_background"
|
||||
app:layout_constraintTop_toBottomOf="@id/title" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:onClick="@{dismissClickListener}"
|
||||
style="@style/default_text_style_600"
|
||||
android:id="@+id/confirm"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="32dp"
|
||||
android:layout_marginStart="15dp"
|
||||
android:layout_marginEnd="15dp"
|
||||
android:paddingBottom="13dp"
|
||||
android:paddingTop="13dp"
|
||||
android:gravity="center"
|
||||
android:background="@drawable/primary_button_background"
|
||||
android:text="Ok"
|
||||
android:textSize="18sp"
|
||||
android:textColor="@color/primary_button_label_color"
|
||||
app:layout_constraintStart_toStartOf="@id/dialog_background"
|
||||
app:layout_constraintEnd_toEndOf="@id/dialog_background"
|
||||
app:layout_constraintTop_toBottomOf="@id/message"
|
||||
app:layout_constraintBottom_toTopOf="@id/anchor"/>
|
||||
|
||||
<View
|
||||
android:id="@+id/anchor"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="20dp"
|
||||
app:layout_constraintTop_toBottomOf="@id/confirm"
|
||||
app:layout_constraintStart_toStartOf="@id/dialog_background"
|
||||
app:layout_constraintEnd_toEndOf="@id/dialog_background"
|
||||
app:layout_constraintBottom_toBottomOf="parent"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</layout>
|
||||
Loading…
Add table
Reference in a new issue