Hidden for now account mode selection, moved push notification toggle from account settings to account profile

This commit is contained in:
Sylvain Berfini 2024-01-16 10:31:16 +01:00
parent 8c7ca490c8
commit 43c22b8ed5
5 changed files with 44 additions and 54 deletions

View file

@ -122,9 +122,11 @@ class LoginFragment : Fragment() {
viewModel.accountLoggedInEvent.observe(viewLifecycleOwner) {
it.consume {
Log.i("$TAG Account successfully logged-in, go to profile mode fragment")
// TODO FIXME: uncomment when mode secure/interop will work
/*Log.i("$TAG Account successfully logged-in, go to profile mode fragment")
val action = LoginFragmentDirections.actionLoginFragmentToProfileModeFragment()
findNavController().navigate(action)
findNavController().navigate(action)*/
requireActivity().finish()
}
}

View file

@ -30,6 +30,8 @@ class AccountProfileViewModel @UiThread constructor() : ViewModel() {
val selectedDialPlan = MutableLiveData<Int>()
val pushNotificationsEnabled = MutableLiveData<Boolean>()
val registerEnabled = MutableLiveData<Boolean>()
val isCurrentlySelectedModeSecure = MutableLiveData<Boolean>()
@ -86,6 +88,7 @@ class AccountProfileViewModel @UiThread constructor() : ViewModel() {
accountModel.postValue(AccountModel(account))
isCurrentlySelectedModeSecure.postValue(account.isInSecureMode())
registerEnabled.postValue(account.params.isRegisterEnabled)
pushNotificationsEnabled.postValue(account.params.pushNotificationAllowed)
sipAddress.postValue(account.params.identityAddress?.asStringUriOnly())
displayName.postValue(account.params.identityAddress?.displayName)
@ -192,6 +195,7 @@ class AccountProfileViewModel @UiThread constructor() : ViewModel() {
if (::account.isInitialized) {
val params = account.params
val copy = params.clone()
copy.pushNotificationAllowed = pushNotificationsEnabled.value == true
val address = params.identityAddress?.clone()
if (address != null) {

View file

@ -41,8 +41,6 @@ class AccountSettingsViewModel @UiThread constructor() : ViewModel() {
val selectedTransport = MutableLiveData<TransportType>()
val pushNotificationsEnabled = MutableLiveData<Boolean>()
val sipProxyServer = MutableLiveData<String>()
val outboundProxyEnabled = MutableLiveData<Boolean>()
@ -84,8 +82,6 @@ class AccountSettingsViewModel @UiThread constructor() : ViewModel() {
val params = account.params
pushNotificationsEnabled.postValue(params.pushNotificationAllowed)
val transportType = params.serverAddress?.transport ?: TransportType.Tls
selectedTransport.postValue(transportType)
@ -124,8 +120,6 @@ class AccountSettingsViewModel @UiThread constructor() : ViewModel() {
if (::account.isInitialized) {
val newParams = account.params.clone()
newParams.pushNotificationAllowed = pushNotificationsEnabled.value == true
val server = sipProxyServer.value.orEmpty()
if (server.isNotEmpty()) {
val serverAddress = Factory.instance().createAddress(server)

View file

@ -77,12 +77,13 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:paddingBottom="@dimen/screen_bottom_margin">
<androidx.constraintlayout.widget.Group
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:constraint_referenced_ids="sip_address, sip_address_label, display_name, display_name_label, details_background"
app:constraint_referenced_ids="details_background, sip_address, sip_address_label, display_name, display_name_label, prefix, prefix_caret, prefix_label, prefix_label_tooltip, push_notifications_switch, push_notifications_title"
android:visibility="@{viewModel.expandDetails ? View.VISIBLE : View.GONE}" />
<com.google.android.material.imageview.ShapeableImageView
@ -188,11 +189,12 @@
android:layout_marginTop="8dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="-20dp"
android:src="@drawable/shape_squircle_white_background"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/details"
app:layout_constraintBottom_toBottomOf="@id/details_bottom_anchor"/>
app:layout_constraintBottom_toBottomOf="@id/push_notifications_switch"/>
<androidx.appcompat.widget.AppCompatTextView
style="@style/header_style"
@ -200,6 +202,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="20dp"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:text="@string/sip_address"
@ -313,14 +316,32 @@
app:layout_constraintBottom_toBottomOf="@id/prefix"
app:layout_constraintEnd_toEndOf="@id/prefix"/>
<View
android:id="@+id/details_bottom_anchor"
android:layout_width="1dp"
android:layout_height="1dp"
android:layout_marginTop="20dp"
app:layout_constraintStart_toStartOf="parent"
<com.google.android.material.materialswitch.MaterialSwitch
style="@style/material_switch_style"
android:id="@+id/push_notifications_switch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:checked="@={viewModel.pushNotificationsEnabled}"
app:layout_constraintEnd_toEndOf="@id/details_background"
app:layout_constraintTop_toBottomOf="@id/prefix"/>
<androidx.appcompat.widget.AppCompatTextView
style="@style/settings_title_style"
android:id="@+id/push_notifications_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="10dp"
android:text="@string/account_settings_push_notification_title"
android:maxLines="2"
android:ellipsize="end"
app:layout_constraintTop_toTopOf="@id/push_notifications_switch"
app:layout_constraintBottom_toBottomOf="@id/push_notifications_switch"
app:layout_constraintStart_toStartOf="@id/details_background"
app:layout_constraintEnd_toStartOf="@id/push_notifications_switch"/>
<ImageView
android:id="@+id/connection_background"
android:layout_width="0dp"
@ -332,7 +353,7 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/details_background"
app:layout_constraintBottom_toBottomOf="@id/connection_bottom_anchor"/>
app:layout_constraintBottom_toBottomOf="@id/connected_summary"/>
<com.google.android.material.materialswitch.MaterialSwitch
style="@style/material_switch_style"
@ -366,19 +387,12 @@
android:layout_marginEnd="16dp"
android:layout_marginTop="16dp"
android:textSize="14sp"
android:paddingBottom="20dp"
android:text="@{viewModel.accountModel.registrationStateSummary, default=@string/manage_account_status_connected_summary}"
app:layout_constraintStart_toStartOf="@id/connection_background"
app:layout_constraintEnd_toEndOf="@id/connection_background"
app:layout_constraintTop_toBottomOf="@id/connected_label" />
<View
android:id="@+id/connection_bottom_anchor"
android:layout_width="1dp"
android:layout_height="1dp"
android:layout_marginTop="20dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/connected_summary"/>
<ImageView
android:id="@+id/mode_background"
android:layout_width="0dp"
@ -387,6 +401,7 @@
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:src="@drawable/shape_squircle_white_background"
android:visibility="gone"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/connection_background"
@ -400,6 +415,7 @@
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:text="@{viewModel.isCurrentlySelectedModeSecure ? @string/manage_account_secure_mode_default_title : @string/manage_account_secure_mode_interoperable_title, default=@string/manage_account_secure_mode_default_title}"
android:visibility="gone"
app:layout_constraintTop_toTopOf="@id/mode_background"
app:layout_constraintStart_toStartOf="@id/mode_background"
app:layout_constraintBottom_toBottomOf="@id/mode_background"/>
@ -420,6 +436,7 @@
android:text="@string/manage_account_change_mode"
android:maxLines="1"
android:ellipsize="end"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="@id/mode_background"
app:layout_constraintTop_toTopOf="@id/mode_background"
app:layout_constraintBottom_toBottomOf="@id/mode_background"/>
@ -527,7 +544,6 @@
android:text="@string/manage_account_delete"
android:drawableStart="@drawable/trash_simple"
app:layout_constraintTop_toBottomOf="@id/action_settings"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="@id/actions_background"
app:layout_constraintEnd_toEndOf="@id/actions_background"/>

View file

@ -60,32 +60,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.materialswitch.MaterialSwitch
style="@style/material_switch_style"
android:id="@+id/push_notifications_switch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginEnd="16dp"
android:checked="@={viewModel.pushNotificationsEnabled}"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.appcompat.widget.AppCompatTextView
style="@style/settings_title_style"
android:id="@+id/push_notifications_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="10dp"
android:text="@string/account_settings_push_notification_title"
android:maxLines="2"
android:ellipsize="end"
app:layout_constraintTop_toTopOf="@id/push_notifications_switch"
app:layout_constraintBottom_toBottomOf="@id/push_notifications_switch"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/push_notifications_switch"/>
<androidx.appcompat.widget.AppCompatTextView
style="@style/settings_title_style"
android:id="@+id/transport_title"
@ -97,7 +71,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_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>