mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Show toast & un-toggle setting when VFS fails to be enabled + show dialog to confirm before turning it on
This commit is contained in:
parent
8b183fd347
commit
2e89f4d101
10 changed files with 218 additions and 1 deletions
|
|
@ -24,6 +24,7 @@ import androidx.lifecycle.ViewModel
|
|||
import org.linphone.utils.Event
|
||||
|
||||
open class GenericViewModel : ViewModel() {
|
||||
// Message res id, icon
|
||||
val showGreenToastEvent: MutableLiveData<Event<Pair<Int, Int>>> by lazy {
|
||||
MutableLiveData<Event<Pair<Int, Int>>>()
|
||||
}
|
||||
|
|
@ -32,6 +33,7 @@ open class GenericViewModel : ViewModel() {
|
|||
MutableLiveData<Event<Pair<String, Int>>>()
|
||||
}
|
||||
|
||||
// Message res id, icon
|
||||
val showRedToastEvent: MutableLiveData<Event<Pair<Int, Int>>> by lazy {
|
||||
MutableLiveData<Event<Pair<Int, Int>>>()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,9 @@ import org.linphone.compatibility.Compatibility
|
|||
import org.linphone.core.tools.Log
|
||||
import org.linphone.databinding.SettingsFragmentBinding
|
||||
import org.linphone.ui.main.fragment.GenericMainFragment
|
||||
import org.linphone.ui.main.settings.model.ConfirmVfsDialogModel
|
||||
import org.linphone.ui.main.settings.viewmodel.SettingsViewModel
|
||||
import org.linphone.utils.DialogUtils
|
||||
|
||||
@UiThread
|
||||
class SettingsFragment : GenericMainFragment() {
|
||||
|
|
@ -263,6 +265,10 @@ class SettingsFragment : GenericMainFragment() {
|
|||
binding.tunnelSettings.tunnelModeSpinner.setSelection(index)
|
||||
}
|
||||
|
||||
binding.setTurnOnVfsClickListener {
|
||||
showConfirmVfsDialog()
|
||||
}
|
||||
|
||||
startPostponedEnterTransition()
|
||||
}
|
||||
|
||||
|
|
@ -280,4 +286,31 @@ class SettingsFragment : GenericMainFragment() {
|
|||
|
||||
super.onPause()
|
||||
}
|
||||
|
||||
private fun showConfirmVfsDialog() {
|
||||
val model = ConfirmVfsDialogModel()
|
||||
val dialog = DialogUtils.getConfirmTurningOnVfsDialog(
|
||||
requireActivity(),
|
||||
model
|
||||
)
|
||||
|
||||
model.cancelEvent.observe(viewLifecycleOwner) {
|
||||
it.consume {
|
||||
viewModel.isVfsEnabled.value = false
|
||||
dialog.dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
model.confirmEvent.observe(viewLifecycleOwner) {
|
||||
it.consume {
|
||||
Log.w("$TAG Try turning on VFS")
|
||||
viewModel.enableVfs()
|
||||
|
||||
dialog.dismiss()
|
||||
findNavController().popBackStack()
|
||||
}
|
||||
}
|
||||
|
||||
dialog.show()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright (c) 2010-2025 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.settings.model
|
||||
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import org.linphone.utils.Event
|
||||
|
||||
class ConfirmVfsDialogModel
|
||||
@UiThread
|
||||
constructor() {
|
||||
val cancelEvent = MutableLiveData<Event<Boolean>>()
|
||||
|
||||
val confirmEvent = MutableLiveData<Event<Boolean>>()
|
||||
|
||||
@UiThread
|
||||
fun cancel() {
|
||||
cancelEvent.value = Event(true)
|
||||
}
|
||||
|
||||
@UiThread
|
||||
fun confirm() {
|
||||
confirmEvent.value = Event(true)
|
||||
}
|
||||
}
|
||||
|
|
@ -332,6 +332,8 @@ class SettingsViewModel
|
|||
Log.i("$TAG VFS has been enabled")
|
||||
}
|
||||
} else {
|
||||
showRedToastEvent.postValue(Event(Pair(R.string.settings_security_enable_vfs_failure_toast, R.drawable.warning_circle)))
|
||||
isVfsEnabled.postValue(false)
|
||||
Log.e("$TAG Failed to enable VFS!")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ import org.linphone.databinding.DialogAssistantCreateAccountConfirmPhoneNumberBi
|
|||
import org.linphone.databinding.DialogCallConfirmTransferBinding
|
||||
import org.linphone.databinding.DialogCancelContactChangesBinding
|
||||
import org.linphone.databinding.DialogCancelMeetingBinding
|
||||
import org.linphone.databinding.DialogConfirmTurningOnVfsBinding
|
||||
import org.linphone.databinding.DialogContactConfirmTrustCallBinding
|
||||
import org.linphone.databinding.DialogContactTrustProcessBinding
|
||||
import org.linphone.databinding.DialogDeleteContactBinding
|
||||
|
|
@ -69,6 +70,7 @@ import org.linphone.ui.main.contacts.model.TrustCallDialogModel
|
|||
import org.linphone.ui.main.history.model.ConfirmationDialogModel
|
||||
import org.linphone.ui.main.model.AuthRequestedDialogModel
|
||||
import org.linphone.ui.main.model.GroupSetOrEditSubjectDialogModel
|
||||
import org.linphone.ui.main.settings.model.ConfirmVfsDialogModel
|
||||
import org.linphone.ui.main.settings.model.UpdatePasswordDialogModel
|
||||
|
||||
class DialogUtils {
|
||||
|
|
@ -141,6 +143,22 @@ class DialogUtils {
|
|||
return getDialog(context, binding)
|
||||
}
|
||||
|
||||
@UiThread
|
||||
fun getConfirmTurningOnVfsDialog(
|
||||
context: Context,
|
||||
viewModel: ConfirmVfsDialogModel
|
||||
): Dialog {
|
||||
val binding: DialogConfirmTurningOnVfsBinding = DataBindingUtil.inflate(
|
||||
LayoutInflater.from(context),
|
||||
R.layout.dialog_confirm_turning_on_vfs,
|
||||
null,
|
||||
false
|
||||
)
|
||||
binding.viewModel = viewModel
|
||||
|
||||
return getDialog(context, binding)
|
||||
}
|
||||
|
||||
@UiThread
|
||||
fun getNumberOrAddressPickerDialog(
|
||||
context: Context,
|
||||
|
|
|
|||
103
app/src/main/res/layout/dialog_confirm_turning_on_vfs.xml
Normal file
103
app/src/main/res/layout/dialog_confirm_turning_on_vfs.xml
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
<?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="viewModel"
|
||||
type="org.linphone.ui.main.settings.model.ConfirmVfsDialogModel" />
|
||||
</data>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:onClick="@{() -> viewModel.cancel()}"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<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"
|
||||
android:contentDescription="@null"
|
||||
app:layout_constraintWidth_max="@dimen/dialog_max_width"
|
||||
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/section_header_style"
|
||||
android:id="@+id/title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="15dp"
|
||||
android:paddingTop="@dimen/dialog_top_bottom_margin"
|
||||
android:text="@string/settings_security_enable_vfs_dialog_confirmation_title"
|
||||
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="@string/settings_security_enable_vfs_dialog_confirmation_message"
|
||||
android:textSize="14sp"
|
||||
app:layout_constraintBottom_toTopOf="@id/cancel"
|
||||
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="@{() -> viewModel.cancel()}"
|
||||
style="@style/secondary_button_label_style"
|
||||
android:id="@+id/cancel"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="32dp"
|
||||
android:layout_marginStart="15dp"
|
||||
android:layout_marginEnd="15dp"
|
||||
android:text="@string/dialog_cancel"
|
||||
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/confirm"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:onClick="@{() -> viewModel.confirm()}"
|
||||
style="@style/primary_button_label_style"
|
||||
android:id="@+id/confirm"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginStart="15dp"
|
||||
android:layout_marginEnd="15dp"
|
||||
android:text="@string/dialog_confirm"
|
||||
app:layout_constraintStart_toStartOf="@id/dialog_background"
|
||||
app:layout_constraintEnd_toEndOf="@id/dialog_background"
|
||||
app:layout_constraintTop_toBottomOf="@id/cancel"
|
||||
app:layout_constraintBottom_toTopOf="@id/anchor"/>
|
||||
|
||||
<View
|
||||
android:id="@+id/anchor"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/dialog_top_bottom_margin"
|
||||
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>
|
||||
|
|
@ -8,6 +8,9 @@
|
|||
<variable
|
||||
name="backClickListener"
|
||||
type="View.OnClickListener" />
|
||||
<variable
|
||||
name="turnOnVfsClickListener"
|
||||
type="View.OnClickListener" />
|
||||
<variable
|
||||
name="advancedSettingsClickListener"
|
||||
type="View.OnClickListener" />
|
||||
|
|
@ -88,6 +91,7 @@
|
|||
android:layout_marginEnd="16dp"
|
||||
android:visibility="@{viewModel.expandSecurity ? View.VISIBLE : View.GONE, default=gone}"
|
||||
app:layout_constraintTop_toBottomOf="@id/security"
|
||||
bind:turnOnVfsClickListener="@{turnOnVfsClickListener}"
|
||||
bind:viewModel="@{viewModel}"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@
|
|||
|
||||
<data>
|
||||
<import type="android.view.View" />
|
||||
<variable
|
||||
name="turnOnVfsClickListener"
|
||||
type="View.OnClickListener" />
|
||||
<variable
|
||||
name="viewModel"
|
||||
type="org.linphone.ui.main.settings.viewmodel.SettingsViewModel" />
|
||||
|
|
@ -18,11 +21,13 @@
|
|||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/settings_title_style"
|
||||
android:onClick="@{turnOnVfsClickListener}"
|
||||
android:id="@+id/enable_vfs_title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:enabled="@{!viewModel.isVfsEnabled}"
|
||||
android:text="@string/settings_security_enable_vfs_title"
|
||||
android:maxLines="2"
|
||||
android:ellipsize="end"
|
||||
|
|
@ -34,10 +39,12 @@
|
|||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/settings_subtitle_style"
|
||||
android:id="@+id/enable_vfs_subtitle"
|
||||
android:onClick="@{turnOnVfsClickListener}"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:enabled="@{!viewModel.isVfsEnabled}"
|
||||
android:text="@string/settings_security_enable_vfs_subtitle"
|
||||
app:layout_constraintTop_toBottomOf="@id/enable_vfs_title"
|
||||
app:layout_constraintBottom_toBottomOf="@id/enable_vfs_switch"
|
||||
|
|
@ -47,7 +54,7 @@
|
|||
<com.google.android.material.materialswitch.MaterialSwitch
|
||||
style="@style/material_switch_style"
|
||||
android:id="@+id/enable_vfs_switch"
|
||||
android:onClick="@{() -> viewModel.enableVfs()}"
|
||||
android:onClick="@{turnOnVfsClickListener}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
|
|
|
|||
|
|
@ -178,6 +178,9 @@
|
|||
<string name="settings_security_title">Securité</string>
|
||||
<string name="settings_security_enable_vfs_title">Chiffrer tous les fichiers</string>
|
||||
<string name="settings_security_enable_vfs_subtitle">Attention, vous ne pourrez pas revenir en arrière !</string>
|
||||
<string name="settings_security_enable_vfs_failure_toast">Échec à l\'activation du module d\'encryption</string>
|
||||
<string name="settings_security_enable_vfs_dialog_confirmation_title">Confirmer l\'activation du chiffrement</string>
|
||||
<string name="settings_security_enable_vfs_dialog_confirmation_message">Une fois la fonctionnalité activée, toutes les données de l\'application seront chiffrées et accessibles uniquement via celle-ci.\n\nCe changement est irréversible.</string>
|
||||
<string name="settings_security_prevent_screenshots_title">Empêcher l\'interface d\'être enregistrée</string>
|
||||
<string name="settings_calls_title">Appels</string>
|
||||
<string name="settings_calls_echo_canceller_title">Utiliser l\'annulateur d\'écho logiciel</string>
|
||||
|
|
|
|||
|
|
@ -217,6 +217,9 @@
|
|||
<string name="settings_security_title">Security</string>
|
||||
<string name="settings_security_enable_vfs_title">Encrypt everything</string>
|
||||
<string name="settings_security_enable_vfs_subtitle">Warning: once enabled it can\'t be disabled!</string>
|
||||
<string name="settings_security_enable_vfs_failure_toast">Failed to enable encryption module!</string>
|
||||
<string name="settings_security_enable_vfs_dialog_confirmation_title">Do you really want to encrypt everything?</string>
|
||||
<string name="settings_security_enable_vfs_dialog_confirmation_message">Be careful, it can\'t be undone!</string>
|
||||
<string name="settings_security_prevent_screenshots_title">Prevent interface from being recorded</string>
|
||||
<string name="settings_calls_title">Calls</string>
|
||||
<string name="settings_calls_echo_canceller_title">Use software echo canceller</string>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue