diff --git a/app/src/main/java/org/linphone/ui/main/settings/viewmodel/AccountProfileViewModel.kt b/app/src/main/java/org/linphone/ui/main/settings/viewmodel/AccountProfileViewModel.kt index c24da66b3..719605c1f 100644 --- a/app/src/main/java/org/linphone/ui/main/settings/viewmodel/AccountProfileViewModel.kt +++ b/app/src/main/java/org/linphone/ui/main/settings/viewmodel/AccountProfileViewModel.kt @@ -52,10 +52,6 @@ class AccountProfileViewModel @UiThread constructor() : GenericViewModel() { val selectedDialPlan = MutableLiveData() - val pushNotificationsAvailable = MutableLiveData() - - val pushNotificationsEnabled = MutableLiveData() - val registerEnabled = MutableLiveData() val showModeSelection = MutableLiveData() @@ -83,7 +79,6 @@ class AccountProfileViewModel @UiThread constructor() : GenericViewModel() { expandDevices.value = false // TODO: set to true when feature will be available coreContext.postOnCoreThread { core -> - pushNotificationsAvailable.postValue(core.isPushNotificationAvailable) hideAccountSettings.postValue(corePreferences.hideAccountSettings) dialPlansLabelList.add("") // To allow removing selected dial plan @@ -118,9 +113,6 @@ class AccountProfileViewModel @UiThread constructor() : GenericViewModel() { accountModel.postValue(AccountModel(account)) isCurrentlySelectedModeSecure.postValue(account.isEndToEndEncryptionMandatory()) registerEnabled.postValue(account.params.isRegisterEnabled) - pushNotificationsEnabled.postValue( - core.isPushNotificationAvailable && account.params.pushNotificationAllowed - ) sipAddress.postValue(account.params.identityAddress?.asStringUriOnly()) displayName.postValue(account.params.identityAddress?.displayName) @@ -217,7 +209,6 @@ class AccountProfileViewModel @UiThread constructor() : GenericViewModel() { if (::account.isInitialized) { val params = account.params val copy = params.clone() - copy.pushNotificationAllowed = pushNotificationsEnabled.value == true val address = params.identityAddress?.clone() if (address != null) { diff --git a/app/src/main/java/org/linphone/ui/main/settings/viewmodel/AccountSettingsViewModel.kt b/app/src/main/java/org/linphone/ui/main/settings/viewmodel/AccountSettingsViewModel.kt index 9974d5de6..ed1c0faba 100644 --- a/app/src/main/java/org/linphone/ui/main/settings/viewmodel/AccountSettingsViewModel.kt +++ b/app/src/main/java/org/linphone/ui/main/settings/viewmodel/AccountSettingsViewModel.kt @@ -39,6 +39,10 @@ class AccountSettingsViewModel @UiThread constructor() : GenericViewModel() { val isAccountInSecureMode = MutableLiveData() + val pushNotificationsAvailable = MutableLiveData() + + val pushNotificationsEnabled = MutableLiveData() + val availableTransports = arrayListOf() val selectedTransport = MutableLiveData() @@ -90,6 +94,11 @@ class AccountSettingsViewModel @UiThread constructor() : GenericViewModel() { val params = account.params + pushNotificationsAvailable.postValue(core.isPushNotificationAvailable) + pushNotificationsEnabled.postValue( + core.isPushNotificationAvailable && params.pushNotificationAllowed + ) + val transportType = params.serverAddress?.transport ?: TransportType.Tls selectedTransport.postValue(transportType) @@ -131,6 +140,7 @@ class AccountSettingsViewModel @UiThread constructor() : GenericViewModel() { if (::account.isInitialized) { val newParams = account.params.clone() + newParams.pushNotificationAllowed = pushNotificationsEnabled.value == true val server = sipProxyServer.value.orEmpty() if (server.isNotEmpty()) { diff --git a/app/src/main/res/layout/account_profile_fragment.xml b/app/src/main/res/layout/account_profile_fragment.xml index b3c665909..b05737de6 100644 --- a/app/src/main/res/layout/account_profile_fragment.xml +++ b/app/src/main/res/layout/account_profile_fragment.xml @@ -83,7 +83,7 @@ + app:layout_constraintBottom_toBottomOf="@id/prefix"/> - - - - + + + +