Skip to content
Snippets Groups Projects
Commit fa0253e0 authored by Pierre Nicolas's avatar Pierre Nicolas :joy:
Browse files

presence: don't show user presence

`AvatarDrawable.withContact` always display presence.
New function `AvatarDrawable.withUser` will not display presence.

GitLab: #1757
Change-Id: I55f437c6b13eabe4db834c57bbf8e7822db6b587
parent dd34cca9
No related branches found
No related tags found
No related merge requests found
...@@ -220,6 +220,12 @@ class AvatarDrawable : Drawable { ...@@ -220,6 +220,12 @@ class AvatarDrawable : Drawable {
fun withNameData(profileName: String?, username: String?) = fun withNameData(profileName: String?, username: String?) =
withName(if (profileName.isNullOrEmpty()) username else profileName) withName(if (profileName.isNullOrEmpty()) username else profileName)
fun withUser(user: ContactViewModel?) = if (user == null) this else
withPhoto(user.profile.avatar as? Bitmap?)
.withId(user.contact.uri.toString())
.withPresence(false)
.withNameData(user.profile.displayName, user.registeredName)
fun withContact(contact: ContactViewModel?) = if (contact == null) this else fun withContact(contact: ContactViewModel?) = if (contact == null) this else
withPhoto(contact.profile.avatar as? Bitmap?) withPhoto(contact.profile.avatar as? Bitmap?)
.withId(contact.contact.uri.toString()) .withId(contact.contact.uri.toString())
...@@ -237,8 +243,12 @@ class AvatarDrawable : Drawable { ...@@ -237,8 +243,12 @@ class AvatarDrawable : Drawable {
} }
val bitmaps: MutableList<Bitmap> = ArrayList(contacts.size) val bitmaps: MutableList<Bitmap> = ArrayList(contacts.size)
var notTheUser = 0 var notTheUser = 0
var user: ContactViewModel? = null
for (contact in contacts) { for (contact in contacts) {
if (contact.contact.isUser) continue if (contact.contact.isUser) {
user = contact
continue
}
notTheUser++ notTheUser++
val bitmap = contact.profile.avatar as? Bitmap? val bitmap = contact.profile.avatar as? Bitmap?
if (bitmap != null) { if (bitmap != null) {
...@@ -251,13 +261,8 @@ class AvatarDrawable : Drawable { ...@@ -251,13 +261,8 @@ class AvatarDrawable : Drawable {
if (!contact.contact.isUser) return withContact(contact) if (!contact.contact.isUser) return withContact(contact)
} }
} }
if (bitmaps.isEmpty()) { // If alone in group, fallback to the user avatar.
// Fallback to the user avatar return if (bitmaps.isEmpty()) withUser(user) else withPhotos(bitmaps)
for (contact in contacts) return withContact(contact)
} else {
return withPhotos(bitmaps)
}
return this
} }
fun withConversation(conversation: Conversation, profile: Profile, contacts: List<ContactViewModel>): Builder = fun withConversation(conversation: Conversation, profile: Profile, contacts: List<ContactViewModel>): Builder =
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment