mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Hidden change mode area & child fragment in account profile, moved IM encryption mandatory to account settings
This commit is contained in:
parent
3060af3940
commit
7cff514c3a
7 changed files with 59 additions and 78 deletions
|
|
@ -54,8 +54,6 @@ class AccountProfileViewModel @UiThread constructor() : GenericViewModel() {
|
|||
|
||||
val registerEnabled = MutableLiveData<Boolean>()
|
||||
|
||||
val showModeSelection = MutableLiveData<Boolean>()
|
||||
|
||||
val isCurrentlySelectedModeSecure = MutableLiveData<Boolean>()
|
||||
|
||||
val devices = MutableLiveData<ArrayList<AccountDeviceModel>>()
|
||||
|
|
@ -117,16 +115,6 @@ class AccountProfileViewModel @UiThread constructor() : GenericViewModel() {
|
|||
sipAddress.postValue(account.params.identityAddress?.asStringUriOnly())
|
||||
displayName.postValue(account.params.identityAddress?.displayName)
|
||||
|
||||
val limeServerUrl = account.params.limeServerUrl
|
||||
val conferenceFactoryUri = account.params.conferenceFactoryUri
|
||||
val showMode = limeServerUrl.orEmpty().isNotEmpty() && conferenceFactoryUri.orEmpty().isNotEmpty()
|
||||
if (!showMode) {
|
||||
Log.i(
|
||||
"$TAG Either LIME server URL or conference factory URI isn't set, hiding end-to-end encrypted/interop mode selection"
|
||||
)
|
||||
}
|
||||
showModeSelection.postValue(showMode)
|
||||
|
||||
val devicesList = arrayListOf<AccountDeviceModel>()
|
||||
// TODO FIXME: use real devices list from API, not implemented yet
|
||||
devices.postValue(devicesList)
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
package org.linphone.ui.main.settings.viewmodel
|
||||
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.lifecycle.MediatorLiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import java.util.Locale
|
||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
|
|
@ -29,7 +30,6 @@ import org.linphone.core.NatPolicy
|
|||
import org.linphone.core.TransportType
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.ui.GenericViewModel
|
||||
import org.linphone.ui.main.model.isEndToEndEncryptionMandatory
|
||||
import org.linphone.utils.Event
|
||||
|
||||
class AccountSettingsViewModel @UiThread constructor() : GenericViewModel() {
|
||||
|
|
@ -37,12 +37,14 @@ class AccountSettingsViewModel @UiThread constructor() : GenericViewModel() {
|
|||
private const val TAG = "[Account Settings ViewModel]"
|
||||
}
|
||||
|
||||
val isAccountInSecureMode = MutableLiveData<Boolean>()
|
||||
|
||||
val pushNotificationsAvailable = MutableLiveData<Boolean>()
|
||||
|
||||
val pushNotificationsEnabled = MutableLiveData<Boolean>()
|
||||
|
||||
val imEncryptionMandatoryAvailable = MediatorLiveData<Boolean>()
|
||||
|
||||
val imEncryptionMandatory = MutableLiveData<Boolean>()
|
||||
|
||||
val availableTransports = arrayListOf<String>()
|
||||
|
||||
val selectedTransport = MutableLiveData<TransportType>()
|
||||
|
|
@ -78,6 +80,13 @@ class AccountSettingsViewModel @UiThread constructor() : GenericViewModel() {
|
|||
availableTransports.add(TransportType.Udp.name.uppercase(Locale.getDefault()))
|
||||
availableTransports.add(TransportType.Tcp.name.uppercase(Locale.getDefault()))
|
||||
availableTransports.add(TransportType.Tls.name.uppercase(Locale.getDefault()))
|
||||
|
||||
imEncryptionMandatoryAvailable.addSource(limeServerUrl) {
|
||||
imEncryptionMandatoryAvailable.value = isImEncrptionMandatoryAvailable()
|
||||
}
|
||||
imEncryptionMandatoryAvailable.addSource(conferenceFactoryUri) {
|
||||
imEncryptionMandatoryAvailable.value = isImEncrptionMandatoryAvailable()
|
||||
}
|
||||
}
|
||||
|
||||
@UiThread
|
||||
|
|
@ -90,8 +99,6 @@ class AccountSettingsViewModel @UiThread constructor() : GenericViewModel() {
|
|||
Log.i("$TAG Found matching account [$found]")
|
||||
account = found
|
||||
|
||||
isAccountInSecureMode.postValue(account.isEndToEndEncryptionMandatory())
|
||||
|
||||
val params = account.params
|
||||
|
||||
pushNotificationsAvailable.postValue(core.isPushNotificationAvailable)
|
||||
|
|
@ -99,6 +106,8 @@ class AccountSettingsViewModel @UiThread constructor() : GenericViewModel() {
|
|||
core.isPushNotificationAvailable && params.pushNotificationAllowed
|
||||
)
|
||||
|
||||
imEncryptionMandatory.postValue(params.instantMessagingEncryptionMandatory)
|
||||
|
||||
val transportType = params.serverAddress?.transport ?: TransportType.Tls
|
||||
selectedTransport.postValue(transportType)
|
||||
|
||||
|
|
@ -142,6 +151,8 @@ class AccountSettingsViewModel @UiThread constructor() : GenericViewModel() {
|
|||
val newParams = account.params.clone()
|
||||
newParams.pushNotificationAllowed = pushNotificationsEnabled.value == true
|
||||
|
||||
newParams.instantMessagingEncryptionMandatory = imEncryptionMandatory.value == true
|
||||
|
||||
val server = sipProxyServer.value.orEmpty()
|
||||
if (server.isNotEmpty()) {
|
||||
val serverAddress = core.interpretUrl(server, false)
|
||||
|
|
@ -187,4 +198,9 @@ class AccountSettingsViewModel @UiThread constructor() : GenericViewModel() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@UiThread
|
||||
fun isImEncrptionMandatoryAvailable(): Boolean {
|
||||
return limeServerUrl.value.orEmpty().isNotEmpty() && conferenceFactoryUri.value.orEmpty().isNotEmpty()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
|
||||
<corners android:radius="63dp" />
|
||||
<solid android:color="?attr/color_main2_000"/>
|
||||
<stroke android:width="1dp" android:color="?attr/color_main2_600" />
|
||||
<solid android:color="?attr/color_grey_200"/>
|
||||
<stroke android:width="1dp" android:color="?attr/color_grey_200" />
|
||||
</shape>
|
||||
|
|
@ -86,12 +86,6 @@
|
|||
app:constraint_referenced_ids="details_background, sip_address, sip_address_label, display_name, display_name_label, prefix, prefix_caret, prefix_label, prefix_label_tooltip"
|
||||
android:visibility="@{viewModel.expandDetails ? View.VISIBLE : View.GONE}" />
|
||||
|
||||
<androidx.constraintlayout.widget.Group
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:constraint_referenced_ids="mode_background, current_mode, change_mode"
|
||||
android:visibility="@{viewModel.showModeSelection ? View.VISIBLE : View.GONE}" />
|
||||
|
||||
<include
|
||||
android:id="@+id/avatar"
|
||||
android:onClick="@{pickImageClickListener}"
|
||||
|
|
@ -367,55 +361,6 @@
|
|||
app:layout_constraintEnd_toEndOf="@id/connection_background"
|
||||
app:layout_constraintTop_toBottomOf="@id/connected_label" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/mode_background"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:contentDescription="@null"
|
||||
android:src="@drawable/shape_squircle_white_background"
|
||||
android:visibility="@{viewModel.showModeSelection ? View.VISIBLE : View.GONE}"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/connection_background"
|
||||
app:layout_constraintBottom_toBottomOf="@id/change_mode"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/header_style"
|
||||
android:id="@+id/current_mode"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@{viewModel.isCurrentlySelectedModeSecure ? @string/manage_account_e2e_encrypted_mode_default_title : @string/manage_account_e2e_encrypted_mode_interoperable_title, default=@string/manage_account_e2e_encrypted_mode_default_title}"
|
||||
android:visibility="@{viewModel.showModeSelection ? View.VISIBLE : View.GONE}"
|
||||
app:layout_constraintTop_toTopOf="@id/mode_background"
|
||||
app:layout_constraintStart_toStartOf="@id/mode_background"
|
||||
app:layout_constraintBottom_toBottomOf="@id/mode_background"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:onClick="@{changeModeClickListener}"
|
||||
style="@style/tertiary_button_label_style"
|
||||
android:id="@+id/change_mode"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:background="@drawable/tertiary_button_background"
|
||||
android:paddingStart="12dp"
|
||||
android:paddingEnd="12dp"
|
||||
android:paddingTop="6dp"
|
||||
android:paddingBottom="6dp"
|
||||
android:gravity="center"
|
||||
android:text="@string/manage_account_change_mode"
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
android:visibility="@{viewModel.showModeSelection ? View.VISIBLE : View.GONE}"
|
||||
app:layout_constraintEnd_toEndOf="@id/mode_background"
|
||||
app:layout_constraintTop_toTopOf="@id/mode_background"
|
||||
app:layout_constraintBottom_toBottomOf="@id/mode_background"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/section_header_style"
|
||||
android:onClick="@{() -> viewModel.toggleDevicesExpand()}"
|
||||
|
|
@ -432,7 +377,7 @@
|
|||
android:visibility="gone"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/mode_background"/>
|
||||
app:layout_constraintTop_toBottomOf="@id/connection_background"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/devices_list"
|
||||
|
|
|
|||
|
|
@ -89,6 +89,34 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/push_notifications_switch"/>
|
||||
|
||||
<com.google.android.material.materialswitch.MaterialSwitch
|
||||
style="@style/material_switch_style"
|
||||
android:id="@+id/im_encryption_mandatory_switch"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:checked="@={viewModel.imEncryptionMandatory}"
|
||||
android:visibility="@{viewModel.imEncryptionMandatoryAvailable ? View.VISIBLE : View.GONE}"
|
||||
app:layout_constraintTop_toBottomOf="@id/push_notifications_switch"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/settings_title_style"
|
||||
android:id="@+id/im_encryption_mandatory_title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:text="@string/account_settings_im_encryption_mandatory_title"
|
||||
android:maxLines="2"
|
||||
android:ellipsize="end"
|
||||
android:visibility="@{viewModel.imEncryptionMandatoryAvailable ? View.VISIBLE : View.GONE}"
|
||||
app:layout_constraintTop_toTopOf="@id/im_encryption_mandatory_switch"
|
||||
app:layout_constraintBottom_toBottomOf="@id/im_encryption_mandatory_switch"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/im_encryption_mandatory_switch"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/settings_title_style"
|
||||
android:id="@+id/transport_title"
|
||||
|
|
@ -100,7 +128,7 @@
|
|||
android:text="@string/assistant_sip_account_transport_protocol"
|
||||
android:maxLines="2"
|
||||
android:ellipsize="end"
|
||||
app:layout_constraintTop_toBottomOf="@id/push_notifications_switch"
|
||||
app:layout_constraintTop_toBottomOf="@id/im_encryption_mandatory_switch"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
|
|
@ -303,7 +331,7 @@
|
|||
android:layout_marginTop="20dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:checked="@={viewModel.cpimInBasicChatRooms}"
|
||||
android:visibility="@{viewModel.isAccountInSecureMode ? View.GONE : View.VISIBLE}"
|
||||
android:visibility="@{viewModel.imEncryptionMandatory ? View.GONE : View.VISIBLE}"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/bundle_mode_switch" />
|
||||
|
||||
|
|
@ -317,7 +345,7 @@
|
|||
android:text="@string/account_settings_cpim_in_basic_conversations_title"
|
||||
android:maxLines="2"
|
||||
android:ellipsize="end"
|
||||
android:visibility="@{viewModel.isAccountInSecureMode ? View.GONE : View.VISIBLE}"
|
||||
android:visibility="@{viewModel.imEncryptionMandatory ? View.GONE : View.VISIBLE}"
|
||||
app:layout_constraintTop_toTopOf="@id/cpim_basic_chat_room_switch"
|
||||
app:layout_constraintBottom_toBottomOf="@id/cpim_basic_chat_room_switch"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
|
@ -380,6 +408,7 @@
|
|||
android:background="@drawable/edit_text_background"
|
||||
android:paddingStart="20dp"
|
||||
android:paddingEnd="20dp"
|
||||
android:enabled="@{!viewModel.imEncryptionMandatory}"
|
||||
android:text="@={viewModel.conferenceFactoryUri}"
|
||||
android:inputType="text|textUri"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
|
@ -443,6 +472,7 @@
|
|||
android:background="@drawable/edit_text_background"
|
||||
android:paddingStart="20dp"
|
||||
android:paddingEnd="20dp"
|
||||
android:enabled="@{!viewModel.imEncryptionMandatory}"
|
||||
android:text="@={viewModel.limeServerUrl}"
|
||||
android:inputType="text|textUri"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
|
|
|||
|
|
@ -312,6 +312,7 @@
|
|||
<string name="account_settings_title">Paramètres de compte</string>
|
||||
<string name="account_settings_push_notification_title">Autoriser les notifications poussées</string>
|
||||
<string name="account_settings_push_notification_not_available_title">Les notifications poussées ne sont pas disponibles !</string>
|
||||
<string name="account_settings_im_encryption_mandatory_title">Chiffrement obligatoire des conversations</string>
|
||||
<string name="account_settings_sip_proxy_url_title">URL du serveur mandataire</string>
|
||||
<string name="account_settings_outbound_proxy_title">Serveur mandataire sortant</string>
|
||||
<string name="account_settings_stun_server_url_title">URL du serveur STUN</string>
|
||||
|
|
|
|||
|
|
@ -347,6 +347,7 @@
|
|||
<string name="account_settings_title">Account settings</string>
|
||||
<string name="account_settings_push_notification_title">Allow push notifications</string>
|
||||
<string name="account_settings_push_notification_not_available_title">Push notifications aren\'t available!</string>
|
||||
<string name="account_settings_im_encryption_mandatory_title">IM encryption mandatory</string>
|
||||
<string name="account_settings_sip_proxy_url_title">SIP proxy server URL</string>
|
||||
<string name="account_settings_outbound_proxy_title">Outbound proxy</string>
|
||||
<string name="account_settings_stun_server_url_title">STUN server URL</string>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue