Fixed long-term presence icon not refreshed in contacts list
This commit is contained in:
parent
6dba85d41b
commit
e841a8fbc8
3 changed files with 8 additions and 8 deletions
|
@ -34,7 +34,7 @@ import org.linphone.activities.main.contact.data.ContactNumberOrAddressData
|
||||||
import org.linphone.activities.main.viewmodels.MessageNotifierViewModel
|
import org.linphone.activities.main.viewmodels.MessageNotifierViewModel
|
||||||
import org.linphone.contact.ContactDataInterface
|
import org.linphone.contact.ContactDataInterface
|
||||||
import org.linphone.contact.ContactsUpdatedListenerStub
|
import org.linphone.contact.ContactsUpdatedListenerStub
|
||||||
import org.linphone.contact.hasPresence
|
import org.linphone.contact.hasLongTermPresence
|
||||||
import org.linphone.core.*
|
import org.linphone.core.*
|
||||||
import org.linphone.core.tools.Log
|
import org.linphone.core.tools.Log
|
||||||
import org.linphone.utils.Event
|
import org.linphone.utils.Event
|
||||||
|
@ -81,6 +81,8 @@ class ContactViewModel(friend: Friend, async: Boolean = false) : MessageNotifier
|
||||||
|
|
||||||
val readOnlyNativeAddressBook = MutableLiveData<Boolean>()
|
val readOnlyNativeAddressBook = MutableLiveData<Boolean>()
|
||||||
|
|
||||||
|
val hasLongTermPresence = MutableLiveData<Boolean>()
|
||||||
|
|
||||||
private val chatRoomListener = object : ChatRoomListenerStub() {
|
private val chatRoomListener = object : ChatRoomListenerStub() {
|
||||||
override fun onStateChanged(chatRoom: ChatRoom, state: ChatRoom.State) {
|
override fun onStateChanged(chatRoom: ChatRoom, state: ChatRoom.State) {
|
||||||
if (state == ChatRoom.State.Created) {
|
if (state == ChatRoom.State.Created) {
|
||||||
|
@ -147,16 +149,19 @@ class ContactViewModel(friend: Friend, async: Boolean = false) : MessageNotifier
|
||||||
isNativeContact.postValue(friend.refKey != null)
|
isNativeContact.postValue(friend.refKey != null)
|
||||||
presenceStatus.postValue(friend.consolidatedPresence)
|
presenceStatus.postValue(friend.consolidatedPresence)
|
||||||
readOnlyNativeAddressBook.postValue(corePreferences.readOnlyNativeContacts)
|
readOnlyNativeAddressBook.postValue(corePreferences.readOnlyNativeContacts)
|
||||||
|
hasLongTermPresence.postValue(friend.hasLongTermPresence())
|
||||||
} else {
|
} else {
|
||||||
contact.value = friend
|
contact.value = friend
|
||||||
displayName.value = friend.name
|
displayName.value = friend.name
|
||||||
isNativeContact.value = friend.refKey != null
|
isNativeContact.value = friend.refKey != null
|
||||||
presenceStatus.value = friend.consolidatedPresence
|
presenceStatus.value = friend.consolidatedPresence
|
||||||
readOnlyNativeAddressBook.value = corePreferences.readOnlyNativeContacts
|
readOnlyNativeAddressBook.value = corePreferences.readOnlyNativeContacts
|
||||||
|
hasLongTermPresence.value = friend.hasLongTermPresence()
|
||||||
}
|
}
|
||||||
|
|
||||||
friend.addListener {
|
friend.addListener {
|
||||||
presenceStatus.value = it.consolidatedPresence
|
presenceStatus.value = it.consolidatedPresence
|
||||||
|
hasLongTermPresence.value = it.hasLongTermPresence()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,8 +274,4 @@ class ContactViewModel(friend: Friend, async: Boolean = false) : MessageNotifier
|
||||||
}
|
}
|
||||||
numbersAndAddresses.postValue(list)
|
numbersAndAddresses.postValue(list)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun hasPresence(): Boolean {
|
|
||||||
return contact.value?.hasPresence() ?: false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,6 @@ import androidx.core.app.Person
|
||||||
import androidx.core.graphics.drawable.IconCompat
|
import androidx.core.graphics.drawable.IconCompat
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import kotlinx.coroutines.*
|
|
||||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||||
import org.linphone.LinphoneApplication.Companion.corePreferences
|
import org.linphone.LinphoneApplication.Companion.corePreferences
|
||||||
import org.linphone.R
|
import org.linphone.R
|
||||||
|
@ -378,7 +377,7 @@ fun Friend.getContactForPhoneNumberOrAddress(value: String): String? {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Friend.hasPresence(): Boolean {
|
fun Friend.hasLongTermPresence(): Boolean {
|
||||||
for (address in addresses) {
|
for (address in addresses) {
|
||||||
val presenceModel = getPresenceModelForUriOrTel(address.asStringUriOnly())
|
val presenceModel = getPresenceModelForUriOrTel(address.asStringUriOnly())
|
||||||
if (presenceModel != null && presenceModel.basicStatus == PresenceBasicStatus.Open) return true
|
if (presenceModel != null && presenceModel.basicStatus == PresenceBasicStatus.Open) return true
|
||||||
|
|
|
@ -72,7 +72,7 @@
|
||||||
android:src="@drawable/linphone_logo_tinted"
|
android:src="@drawable/linphone_logo_tinted"
|
||||||
android:layout_marginRight="10dp"
|
android:layout_marginRight="10dp"
|
||||||
android:contentDescription="@string/content_description_linphone_user"
|
android:contentDescription="@string/content_description_linphone_user"
|
||||||
android:visibility="@{viewModel.hasPresence() ? View.VISIBLE : View.GONE}" />
|
android:visibility="@{viewModel.hasLongTermPresence ? View.VISIBLE : View.GONE, default=gone}" />
|
||||||
|
|
||||||
<CheckBox
|
<CheckBox
|
||||||
android:onClick="@{() -> selectionListViewModel.onToggleSelect(position)}"
|
android:onClick="@{() -> selectionListViewModel.onToggleSelect(position)}"
|
||||||
|
|
Loading…
Reference in a new issue