Disable push notification settings if feature isn't available
This commit is contained in:
parent
f00e5c4ed8
commit
ffb04920bb
6 changed files with 10 additions and 5 deletions
|
@ -168,6 +168,7 @@ class AccountSettingsViewModel(val proxyConfig: ProxyConfig) : GenericSettingsVi
|
|||
}
|
||||
}
|
||||
val pushNotification = MutableLiveData<Boolean>()
|
||||
val pushNotificationsAvailable = MutableLiveData<Boolean>()
|
||||
|
||||
val transportListener = object : SettingListenerStub() {
|
||||
override fun onListValueChanged(position: Int) {
|
||||
|
@ -286,6 +287,7 @@ class AccountSettingsViewModel(val proxyConfig: ProxyConfig) : GenericSettingsVi
|
|||
domain.value = proxyConfig.identityAddress.domain
|
||||
disable.value = !proxyConfig.registerEnabled()
|
||||
pushNotification.value = proxyConfig.isPushNotificationAllowed
|
||||
pushNotificationsAvailable.value = core.isPushNotificationAvailable
|
||||
proxy.value = proxyConfig.serverAddr
|
||||
outboundProxy.value = proxyConfig.serverAddr == proxyConfig.route
|
||||
stunServer.value = proxyConfig.natPolicy?.stunServer
|
||||
|
|
|
@ -43,6 +43,7 @@ class NetworkSettingsViewModel : GenericSettingsViewModel() {
|
|||
}
|
||||
}
|
||||
val pushNotifications = MutableLiveData<Boolean>()
|
||||
val pushNotificationsAvailable = MutableLiveData<Boolean>()
|
||||
|
||||
val randomPortsListener = object : SettingListenerStub() {
|
||||
override fun onBoolValueChanged(newValue: Boolean) {
|
||||
|
@ -65,6 +66,7 @@ class NetworkSettingsViewModel : GenericSettingsViewModel() {
|
|||
wifiOnly.value = core.wifiOnlyEnabled()
|
||||
allowIpv6.value = core.ipv6Enabled()
|
||||
pushNotifications.value = core.isPushNotificationEnabled
|
||||
pushNotificationsAvailable.value = core.isPushNotificationAvailable
|
||||
randomPorts.value = getSipPort() == -1
|
||||
sipPort.value = getSipPort()
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ class CorePreferences constructor(private val context: Context) {
|
|||
/* App settings */
|
||||
|
||||
var debugLogs: Boolean
|
||||
get() = config.getBool("app", "debug", true)
|
||||
get() = config.getBool("app", "debug", BuildConfig.DEBUG)
|
||||
set(value) {
|
||||
config.setBool("app", "debug", value)
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ package org.linphone.utils
|
|||
import java.text.DateFormat
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
import org.linphone.core.tools.Log
|
||||
|
||||
class TimestampUtils {
|
||||
companion object {
|
||||
|
@ -80,7 +79,7 @@ class TimestampUtils {
|
|||
if (isSameYear(timestamp, timestampInSecs)) {
|
||||
// Remove the year part of the format
|
||||
dateFormat.applyPattern(
|
||||
dateFormat.toPattern().replace("/?y+/?|\\s?y+\\s?".toRegex(),"")
|
||||
dateFormat.toPattern().replace("/?y+/?|\\s?y+\\s?".toRegex(), "")
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -156,7 +156,8 @@
|
|||
linphone:title="@{@string/account_settings_push_notification_title}"
|
||||
linphone:subtitle="@{@string/account_settings_push_notification_summary}"
|
||||
linphone:listener="@{viewModel.pushNotificationListener}"
|
||||
linphone:checked="@={viewModel.pushNotification}"/>
|
||||
linphone:checked="@={viewModel.pushNotification}"
|
||||
android:visibility="@{viewModel.pushNotificationsAvailable ? View.VISIBLE : View.GONE}"/>
|
||||
|
||||
<include
|
||||
layout="@layout/settings_widget_list"
|
||||
|
|
|
@ -84,7 +84,8 @@
|
|||
linphone:title="@{@string/network_settings_push_notifications_title}"
|
||||
linphone:subtitle="@{@string/advanced_settings_push_notifications_summary}"
|
||||
linphone:listener="@{viewModel.pushNotificationsListener}"
|
||||
linphone:checked="@={viewModel.pushNotifications}"/>
|
||||
linphone:checked="@={viewModel.pushNotifications}"
|
||||
linphone:enabled="@{viewModel.pushNotificationsAvailable}"/>
|
||||
|
||||
<include
|
||||
layout="@layout/settings_widget_switch"
|
||||
|
|
Loading…
Reference in a new issue