mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Added a list of domain for which to show push notification settings
This commit is contained in:
parent
e2dfd95857
commit
518ecc1823
4 changed files with 17 additions and 11 deletions
|
|
@ -1051,7 +1051,8 @@ class CoreContext
|
|||
private fun disablePushNotificationsFromThirdPartySipAccounts() {
|
||||
for (account in core.accountList) {
|
||||
val params = account.params
|
||||
if (params.identityAddress?.domain != corePreferences.defaultDomain && params.pushNotificationAllowed) {
|
||||
val pushAvailableForDomain = params.identityAddress?.domain in corePreferences.pushNotificationCompatibleDomains
|
||||
if (!pushAvailableForDomain && params.pushNotificationAllowed) {
|
||||
val clone = params.clone()
|
||||
clone.pushNotificationAllowed = false
|
||||
Log.w("$TAG Updating account [${params.identityAddress?.asStringUriOnly()}] params to disable push notifications, they won't work and may cause issues when used with UDP transport protocol")
|
||||
|
|
|
|||
|
|
@ -276,6 +276,15 @@ class CorePreferences
|
|||
config.setString("ui", "theme_main_color", value)
|
||||
}
|
||||
|
||||
// Customization options
|
||||
|
||||
@get:WorkerThread
|
||||
val defaultDomain: String
|
||||
get() = config.getString("app", "default_domain", "sip.linphone.org")!!
|
||||
|
||||
val pushNotificationCompatibleDomains: Array<String>
|
||||
get() = config.getStringList("app", "push_notification_domains", arrayOf("sip.linphone.org"))
|
||||
|
||||
@get:WorkerThread
|
||||
val darkModeAllowed: Boolean
|
||||
get() = config.getBool("ui", "dark_mode_allowed", true)
|
||||
|
|
@ -378,10 +387,6 @@ class CorePreferences
|
|||
|
||||
// Paths
|
||||
|
||||
@get:WorkerThread
|
||||
val defaultDomain: String
|
||||
get() = config.getString("app", "default_domain", "sip.linphone.org")!!
|
||||
|
||||
@get:AnyThread
|
||||
val configPath: String
|
||||
get() = context.filesDir.absolutePath + "/" + CONFIG_FILE_NAME
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ class AccountSettingsViewModel
|
|||
|
||||
val expandNatPolicySettings = MutableLiveData<Boolean>()
|
||||
|
||||
val isOnDefaultDomain = MutableLiveData<Boolean>()
|
||||
val isDomainInPushNotificationCompatibleList = MutableLiveData<Boolean>()
|
||||
|
||||
val pushNotificationsAvailable = MutableLiveData<Boolean>()
|
||||
|
||||
|
|
@ -132,9 +132,9 @@ class AccountSettingsViewModel
|
|||
account = found
|
||||
|
||||
val params = account.params
|
||||
val defaultDomain = params.identityAddress?.domain == corePreferences.defaultDomain
|
||||
isOnDefaultDomain.postValue(defaultDomain)
|
||||
if (defaultDomain) {
|
||||
val pushAvailableForDomain = params.identityAddress?.domain in corePreferences.pushNotificationCompatibleDomains
|
||||
isDomainInPushNotificationCompatibleList.postValue(pushAvailableForDomain)
|
||||
if (pushAvailableForDomain) {
|
||||
pushNotificationsAvailable.postValue(core.isPushNotificationAvailable)
|
||||
pushNotificationsEnabled.postValue(
|
||||
core.isPushNotificationAvailable && params.pushNotificationAllowed
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@
|
|||
android:layout_marginEnd="16dp"
|
||||
android:enabled="@{viewModel.pushNotificationsAvailable}"
|
||||
android:checked="@={viewModel.pushNotificationsEnabled}"
|
||||
android:visibility="@{viewModel.isOnDefaultDomain ? View.VISIBLE : View.GONE}"
|
||||
android:visibility="@{viewModel.isDomainInPushNotificationCompatibleList ? View.VISIBLE : View.GONE}"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
|
||||
|
|
@ -97,7 +97,7 @@
|
|||
android:text="@{viewModel.pushNotificationsAvailable ? @string/account_settings_push_notification_title : @string/account_settings_push_notification_not_available_title, default=@string/account_settings_push_notification_title}"
|
||||
android:maxLines="2"
|
||||
android:ellipsize="end"
|
||||
android:visibility="@{viewModel.isOnDefaultDomain ? View.VISIBLE : View.GONE}"
|
||||
android:visibility="@{viewModel.isDomainInPushNotificationCompatibleList ? View.VISIBLE : View.GONE}"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="@id/push_notifications_switch"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue