mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-25 17:27:45 +00:00
Updated UserView
This commit is contained in:
parent
361dab24d6
commit
dd9b134dab
@ -53,7 +53,7 @@ class ContactSelectionListAdapter(private val context: Context, private val isMu
|
|||||||
item as ContactSelectionListLoaderItem.Contact
|
item as ContactSelectionListLoaderItem.Contact
|
||||||
viewHolder.view.setOnClickListener { contactClickListener?.onContactClick(item.recipient) }
|
viewHolder.view.setOnClickListener { contactClickListener?.onContactClick(item.recipient) }
|
||||||
val isSelected = selectedContacts.contains(item.recipient)
|
val isSelected = selectedContacts.contains(item.recipient)
|
||||||
viewHolder.view.bind(item.recipient.address.serialize(), isSelected, glide)
|
viewHolder.view.bind(item.recipient, isSelected, glide)
|
||||||
} else if (viewHolder is DividerViewHolder) {
|
} else if (viewHolder is DividerViewHolder) {
|
||||||
item as ContactSelectionListLoaderItem.Header
|
item as ContactSelectionListLoaderItem.Header
|
||||||
viewHolder.view.label.text = item.name
|
viewHolder.view.label.text = item.name
|
||||||
|
@ -3,8 +3,10 @@ package org.thoughtcrime.securesms.loki.redesign.activities
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.support.v7.widget.RecyclerView
|
import android.support.v7.widget.RecyclerView
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import org.thoughtcrime.securesms.database.Address
|
||||||
import org.thoughtcrime.securesms.loki.redesign.views.UserView
|
import org.thoughtcrime.securesms.loki.redesign.views.UserView
|
||||||
import org.thoughtcrime.securesms.mms.GlideRequests
|
import org.thoughtcrime.securesms.mms.GlideRequests
|
||||||
|
import org.thoughtcrime.securesms.recipients.Recipient
|
||||||
|
|
||||||
class CreateClosedGroupAdapter(private val context: Context) : RecyclerView.Adapter<CreateClosedGroupAdapter.ViewHolder>() {
|
class CreateClosedGroupAdapter(private val context: Context) : RecyclerView.Adapter<CreateClosedGroupAdapter.ViewHolder>() {
|
||||||
lateinit var glide: GlideRequests
|
lateinit var glide: GlideRequests
|
||||||
@ -28,7 +30,7 @@ class CreateClosedGroupAdapter(private val context: Context) : RecyclerView.Adap
|
|||||||
val member = members[position]
|
val member = members[position]
|
||||||
viewHolder.view.setOnClickListener { memberClickListener?.onMemberClick(member) }
|
viewHolder.view.setOnClickListener { memberClickListener?.onMemberClick(member) }
|
||||||
val isSelected = selectedMembers.contains(member)
|
val isSelected = selectedMembers.contains(member)
|
||||||
viewHolder.view.bind(member, isSelected, glide)
|
viewHolder.view.bind(Recipient.from(context, Address.fromSerialized(member), false), isSelected, glide)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onMemberClick(member: String) {
|
fun onMemberClick(member: String) {
|
||||||
|
@ -7,9 +7,10 @@ import android.widget.LinearLayout
|
|||||||
import kotlinx.android.synthetic.main.view_conversation.view.profilePictureView
|
import kotlinx.android.synthetic.main.view_conversation.view.profilePictureView
|
||||||
import kotlinx.android.synthetic.main.view_user.view.*
|
import kotlinx.android.synthetic.main.view_user.view.*
|
||||||
import network.loki.messenger.R
|
import network.loki.messenger.R
|
||||||
import org.thoughtcrime.securesms.database.Address
|
import org.thoughtcrime.securesms.groups.GroupManager
|
||||||
import org.thoughtcrime.securesms.mms.GlideRequests
|
import org.thoughtcrime.securesms.mms.GlideRequests
|
||||||
import org.thoughtcrime.securesms.recipients.Recipient
|
import org.thoughtcrime.securesms.recipients.Recipient
|
||||||
|
import org.whispersystems.signalservice.loki.api.LokiAPI
|
||||||
|
|
||||||
class UserView : LinearLayout {
|
class UserView : LinearLayout {
|
||||||
var user: String? = null
|
var user: String? = null
|
||||||
@ -39,13 +40,29 @@ class UserView : LinearLayout {
|
|||||||
// endregion
|
// endregion
|
||||||
|
|
||||||
// region Updating
|
// region Updating
|
||||||
fun bind(user: String, isSelected: Boolean, glide: GlideRequests) {
|
fun bind(user: Recipient, isSelected: Boolean, glide: GlideRequests) {
|
||||||
profilePictureView.hexEncodedPublicKey = user
|
val address = user.address.serialize()
|
||||||
|
if (user.isGroupRecipient) {
|
||||||
|
if (user.address.isPublicChat || user.address.isRSSFeed) {
|
||||||
|
profilePictureView.hexEncodedPublicKey = ""
|
||||||
|
profilePictureView.additionalHexEncodedPublicKey = null
|
||||||
|
profilePictureView.isRSSFeed = true
|
||||||
|
} else {
|
||||||
|
val threadId = GroupManager.getThreadIdFromGroupId(address, context)
|
||||||
|
val users = LokiAPI.userHexEncodedPublicKeyCache[threadId]?.toList() ?: listOf()
|
||||||
|
val randomUsers = users.sorted() // Sort to provide a level of stability
|
||||||
|
profilePictureView.hexEncodedPublicKey = randomUsers.getOrNull(0) ?: ""
|
||||||
|
profilePictureView.additionalHexEncodedPublicKey = randomUsers.getOrNull(1) ?: ""
|
||||||
|
profilePictureView.isRSSFeed = false
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
profilePictureView.hexEncodedPublicKey = address
|
||||||
profilePictureView.additionalHexEncodedPublicKey = null
|
profilePictureView.additionalHexEncodedPublicKey = null
|
||||||
profilePictureView.isRSSFeed = false
|
profilePictureView.isRSSFeed = false
|
||||||
|
}
|
||||||
profilePictureView.glide = glide
|
profilePictureView.glide = glide
|
||||||
profilePictureView.update()
|
profilePictureView.update()
|
||||||
nameTextView.text = Recipient.from(context, Address.fromSerialized(user), false).name ?: "Unknown Contact"
|
nameTextView.text = user.name ?: "Unknown Contact"
|
||||||
tickImageView.setImageResource(if (isSelected) R.drawable.ic_circle_check else R.drawable.ic_circle)
|
tickImageView.setImageResource(if (isSelected) R.drawable.ic_circle_check else R.drawable.ic_circle)
|
||||||
}
|
}
|
||||||
// endregion
|
// endregion
|
||||||
|
Loading…
x
Reference in New Issue
Block a user