From 0ca4eba63b06834c64692cb7ede9bafda7dd21ec 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 | 12 +++++++ .../ui/main/viewmodel/MainViewModel.kt | 1 - app/src/main/res/layout/settings_contacts.xml | 33 +++++++++++++++++-- app/src/main/res/values-fr/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 6 files changed, 45 insertions(+), 20 deletions(-) diff --git a/app/src/main/java/org/linphone/core/CoreContext.kt b/app/src/main/java/org/linphone/core/CoreContext.kt index 80486fc6b..e89e6d02d 100644 --- a/app/src/main/java/org/linphone/core/CoreContext.kt +++ b/app/src/main/java/org/linphone/core/CoreContext.kt @@ -607,7 +607,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) @@ -1055,22 +1054,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 4d3e84efc..2a79235a0 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 @@ -119,6 +119,8 @@ class SettingsViewModel val cardDavFriendsLists = MutableLiveData>() + val presenceSubscribe = MutableLiveData() + val addLdapServerEvent: MutableLiveData> by lazy { MutableLiveData>() } @@ -342,6 +344,7 @@ class SettingsViewModel sortContactsBy.postValue(if (corePreferences.sortContactsByFirstName) 0 else 1) hideEmptyContacts.postValue(corePreferences.hideContactsWithoutPhoneNumberOrSipAddress) + presenceSubscribe.postValue(core.isFriendListSubscriptionEnabled) defaultLayout.postValue(core.defaultConferenceLayout.toInt()) @@ -643,6 +646,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 d2c8ec691..0d84839f4 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 2230b8f32..d381c4d73 100644 --- a/app/src/main/res/layout/settings_contacts.xml +++ b/app/src/main/res/layout/settings_contacts.xml @@ -63,7 +63,7 @@ + + + + \ 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 ca7190ba6..6f50c63c4 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -227,6 +227,7 @@ Contacts Trier les contacts par Masquer les contacts sans adresse SIP ni numéro de téléphone + 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 127c587e5..953fd9ac7 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -269,6 +269,7 @@ Contacts Sort contacts by Hide contacts without SIP address nor phone number + Subscribe to presence info Add LDAP server Edit LDAP server Add CardDAV address book