mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Update friends lists subscription when switching default account
This commit is contained in:
parent
b08aa2ae1f
commit
8057e9d0af
4 changed files with 17 additions and 2 deletions
|
|
@ -151,8 +151,8 @@ class ContactLoader : LoaderManager.LoaderCallbacks<Cursor> {
|
|||
friend.nativeUri =
|
||||
"${ContactsContract.Contacts.CONTENT_LOOKUP_URI}/$lookupKey"
|
||||
|
||||
// Disable short term presence
|
||||
friend.isSubscribesEnabled = false
|
||||
// Disable peer to peer short term presence
|
||||
friend.incSubscribePolicy = SubscribePolicy.SPDeny
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -69,7 +69,6 @@ class ContactsManager @UiThread constructor(context: Context) {
|
|||
override fun onFriendListCreated(core: Core, friendList: FriendList) {
|
||||
Log.i("$TAG Friend list [${friendList.displayName}] created")
|
||||
friendList.addListener(friendListListener)
|
||||
friendList.updateSubscriptions()
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import org.linphone.LinphoneApplication.Companion.coreContext
|
|||
import org.linphone.contacts.ContactLoader.Companion.LINPHONE_ADDRESS_BOOK_FRIEND_LIST
|
||||
import org.linphone.core.Friend
|
||||
import org.linphone.core.FriendList.Status
|
||||
import org.linphone.core.SubscribePolicy
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.ui.main.contacts.model.NewOrEditNumberOrAddressModel
|
||||
import org.linphone.utils.Event
|
||||
|
|
@ -128,6 +129,9 @@ class ContactNewOrEditViewModel @UiThread constructor() : ViewModel() {
|
|||
|
||||
if (!::friend.isInitialized) {
|
||||
friend = core.createFriend()
|
||||
friend.isSubscribesEnabled = false
|
||||
// Disable peer to peer short term presence
|
||||
friend.incSubscribePolicy = SubscribePolicy.SPDeny
|
||||
}
|
||||
friend.name = "${firstName.value.orEmpty().trim()} ${lastName.value.orEmpty().trim()}"
|
||||
|
||||
|
|
|
|||
|
|
@ -88,7 +88,19 @@ class AccountModel @WorkerThread constructor(
|
|||
fun setAsDefault() {
|
||||
coreContext.postOnCoreThread { core ->
|
||||
core.defaultAccount = account
|
||||
|
||||
for (friendList in core.friendsLists) {
|
||||
if (friendList.isSubscriptionsEnabled) {
|
||||
Log.i(
|
||||
"$TAG Default account has changed, refreshing friend list [${friendList.displayName}] subscriptions"
|
||||
)
|
||||
// friendList.updateSubscriptions() won't trigger a refresh unless a friend has changed
|
||||
friendList.isSubscriptionsEnabled = false
|
||||
friendList.isSubscriptionsEnabled = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
isDefault.value = true
|
||||
onSetAsDefault?.invoke(account)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue