From 28cae1fca16eb70ee741bd2c2be7de1ae264f559 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Wed, 1 Oct 2025 10:01:48 +0200 Subject: [PATCH] Fixed contacts presence subscribe being only enabled for default domain account, added setting to disable presence --- .../java/org/linphone/core/CoreContext.kt | 17 ---------- .../settings/viewmodel/SettingsViewModel.kt | 13 ++++++++ .../ui/main/viewmodel/MainViewModel.kt | 1 - app/src/main/res/layout/settings_contacts.xml | 31 ++++++++++++++++++- app/src/main/res/values-fr/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 6 files changed, 45 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/org/linphone/core/CoreContext.kt b/app/src/main/java/org/linphone/core/CoreContext.kt index 4beabe28b..08d0b34d5 100644 --- a/app/src/main/java/org/linphone/core/CoreContext.kt +++ b/app/src/main/java/org/linphone/core/CoreContext.kt @@ -606,7 +606,6 @@ class CoreContext @WorkerThread fun startCore() { Log.i("$TAG Starting Core") - updateFriendListsSubscriptionDependingOnDefaultAccount() val audioManager = context.getSystemService(Context.AUDIO_SERVICE) as AudioManager audioManager.registerAudioDeviceCallback(audioDeviceCallback, coreThread) @@ -1038,22 +1037,6 @@ class CoreContext keepAliveServiceStarted = false } - @WorkerThread - fun updateFriendListsSubscriptionDependingOnDefaultAccount() { - val account = core.defaultAccount - if (account != null) { - val enabled = account.params.domain == corePreferences.defaultDomain - if (enabled != core.isFriendListSubscriptionEnabled) { - core.isFriendListSubscriptionEnabled = enabled - Log.i( - "$TAG Friend list(s) subscription are now ${if (enabled) "enabled" else "disabled"}" - ) - } - } else { - Log.e("$TAG Default account is null, do not touch friend lists subscription") - } - } - @WorkerThread fun playDtmf(character: Char, duration: Int = 200, ignoreSystemPolicy: Boolean = false) { try { diff --git a/app/src/main/java/org/linphone/ui/main/settings/viewmodel/SettingsViewModel.kt b/app/src/main/java/org/linphone/ui/main/settings/viewmodel/SettingsViewModel.kt index 7360848cb..bbbe3685a 100644 --- a/app/src/main/java/org/linphone/ui/main/settings/viewmodel/SettingsViewModel.kt +++ b/app/src/main/java/org/linphone/ui/main/settings/viewmodel/SettingsViewModel.kt @@ -109,6 +109,8 @@ class SettingsViewModel val cardDavFriendsLists = MutableLiveData>() + val presenceSubscribe = MutableLiveData() + val addLdapServerEvent: MutableLiveData> by lazy { MutableLiveData>() } @@ -325,6 +327,8 @@ class SettingsViewModel corePreferences.markConversationAsReadWhenDismissingMessageNotification ) + presenceSubscribe.postValue(core.isFriendListSubscriptionEnabled) + defaultLayout.postValue(core.defaultConferenceLayout.toInt()) autoShowDialpad.postValue(corePreferences.automaticallyShowDialpad) @@ -594,6 +598,15 @@ class SettingsViewModel } } + @UiThread + fun togglePresenceSubscribe() { + val newValue = presenceSubscribe.value == false + coreContext.postOnCoreThread { core -> + core.isFriendListSubscriptionEnabled = newValue + presenceSubscribe.postValue(newValue) + } + } + @UiThread fun toggleMeetingsExpand() { expandMeetings.value = expandMeetings.value == false diff --git a/app/src/main/java/org/linphone/ui/main/viewmodel/MainViewModel.kt b/app/src/main/java/org/linphone/ui/main/viewmodel/MainViewModel.kt index cf78e132e..bd9ac52cb 100644 --- a/app/src/main/java/org/linphone/ui/main/viewmodel/MainViewModel.kt +++ b/app/src/main/java/org/linphone/ui/main/viewmodel/MainViewModel.kt @@ -282,7 +282,6 @@ class MainViewModel Log.i( "$TAG Default account changed, now is [${account.params.identityAddress?.asStringUriOnly()}]" ) - coreContext.updateFriendListsSubscriptionDependingOnDefaultAccount() removeAlert(DEFAULT_ACCOUNT_DISABLED) removeAlert(NON_DEFAULT_ACCOUNT_NOT_CONNECTED) diff --git a/app/src/main/res/layout/settings_contacts.xml b/app/src/main/res/layout/settings_contacts.xml index 733ca61b9..34110315d 100644 --- a/app/src/main/res/layout/settings_contacts.xml +++ b/app/src/main/res/layout/settings_contacts.xml @@ -82,10 +82,39 @@ app:entries="@{viewModel.cardDavFriendsLists}" app:layout="@{@layout/settings_contacts_carddav_ldap_list_cell}" app:layout_constraintTop_toBottomOf="@id/add_carddav_server" - app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" /> + + + + \ No newline at end of file diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 89ee9c11f..f225df99d 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -210,6 +210,7 @@ Rendre visible dans la galerie les médias téléchargés Marquer la conversation comme lue lorsqu\'une notification de message est supprimée Contacts + Souscrire aux informations de présence Ajouter un serveur LDAP Editer le serveur LDAP Ajouter un carnet d\'adresse CardDAV diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1df8ba1ef..ed5160f7a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -261,6 +261,7 @@ Make downloaded media public Mark conversation as read when dismissing message notification Contacts + Subscribe to presence info Add LDAP server Edit LDAP server Add CardDAV address book