mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-17 14:28:25 +00:00
Populate profile pic
This commit is contained in:
parent
92fae3d6bf
commit
f68c01b2ee
@ -20,13 +20,14 @@ import org.session.libsession.utilities.Address
|
||||
import org.session.libsession.utilities.GroupUtil
|
||||
import org.session.libsession.utilities.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.dependencies.DatabaseComponent
|
||||
import org.thoughtcrime.securesms.mms.GlideApp
|
||||
import org.thoughtcrime.securesms.mms.GlideRequests
|
||||
|
||||
class ProfilePictureView @JvmOverloads constructor(
|
||||
context: Context, attrs: AttributeSet? = null
|
||||
) : RelativeLayout(context, attrs) {
|
||||
private val binding = ViewProfilePictureBinding.inflate(LayoutInflater.from(context), this)
|
||||
lateinit var glide: GlideRequests
|
||||
private val glide: GlideRequests = GlideApp.with(this)
|
||||
var publicKey: String? = null
|
||||
var displayName: String? = null
|
||||
var additionalPublicKey: String? = null
|
||||
@ -76,7 +77,6 @@ class ProfilePictureView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
fun update() {
|
||||
if (!this::glide.isInitialized) return
|
||||
val publicKey = publicKey ?: return
|
||||
val additionalPublicKey = additionalPublicKey
|
||||
if (additionalPublicKey != null) {
|
||||
|
@ -54,7 +54,6 @@ class UserView : LinearLayout {
|
||||
val threadID = DatabaseComponent.get(context).threadDatabase().getOrCreateThreadIdFor(user)
|
||||
MentionManagerUtilities.populateUserPublicKeyCacheIfNeeded(threadID, context) // FIXME: This is a bad place to do this
|
||||
val address = user.address.serialize()
|
||||
binding.profilePictureView.glide = glide
|
||||
binding.profilePictureView.update(user)
|
||||
binding.actionIndicatorImageView.setImageResource(R.drawable.ic_baseline_edit_24)
|
||||
binding.nameTextView.text = if (user.isGroupRecipient) user.name else getUserDisplayName(address)
|
||||
|
@ -32,7 +32,6 @@ class ContactListAdapter(
|
||||
|
||||
class ContactViewHolder(private val binding: ViewContactBinding) : RecyclerView.ViewHolder(binding.root) {
|
||||
fun bind(contact: ContactListItem.Contact, glide: GlideRequests, listener: (Recipient) -> Unit) {
|
||||
binding.profilePictureView.glide = glide
|
||||
binding.profilePictureView.update(contact.recipient)
|
||||
binding.nameTextView.text = contact.displayName
|
||||
binding.root.setOnClickListener { listener(contact.recipient) }
|
||||
|
@ -468,7 +468,6 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
||||
}
|
||||
val size = resources.getDimension(sizeID).roundToInt()
|
||||
binding.toolbarContent.profilePictureView.layoutParams = LinearLayout.LayoutParams(size, size)
|
||||
binding.toolbarContent.profilePictureView.glide = glide
|
||||
MentionManagerUtilities.populateUserPublicKeyCacheIfNeeded(viewModel.threadId, this)
|
||||
val profilePictureView = binding.toolbarContent.profilePictureView
|
||||
viewModel.recipient?.let(profilePictureView::update)
|
||||
|
@ -33,6 +33,7 @@ import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import network.loki.messenger.R
|
||||
import org.session.libsession.utilities.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity
|
||||
import org.thoughtcrime.securesms.components.ProfilePictureView
|
||||
import org.thoughtcrime.securesms.database.Storage
|
||||
@ -76,7 +77,8 @@ class MessageDetailActivity: PassphraseRequiredActionBarActivity() {
|
||||
MessageDetails(
|
||||
sent = dateSent.let(::Date).toString().let { TitledText("Sent:", it) },
|
||||
received = dateReceived.let(::Date).toString().let { TitledText("Received:", it) },
|
||||
user = individualRecipient.run { name?.let { TitledText(it, address.serialize()) } }
|
||||
senderInfo = individualRecipient.run { name?.let { TitledText(it, address.serialize()) } },
|
||||
sender = individualRecipient
|
||||
)
|
||||
} ?: MessageDetails()
|
||||
}
|
||||
@ -133,7 +135,8 @@ class MessageDetailActivity: PassphraseRequiredActionBarActivity() {
|
||||
val fileDetails: List<TitledText>? = null,
|
||||
val sent: TitledText? = null,
|
||||
val received: TitledText? = null,
|
||||
val user: TitledText? = null,
|
||||
val senderInfo: TitledText? = null,
|
||||
val sender: Recipient? = null
|
||||
)
|
||||
|
||||
@Preview
|
||||
@ -149,7 +152,7 @@ class MessageDetailActivity: PassphraseRequiredActionBarActivity() {
|
||||
),
|
||||
sent = TitledText("Sent:", "6:12 AM Tue, 09/08/2022"),
|
||||
received = TitledText("Received:", "6:12 AM Tue, 09/08/2022"),
|
||||
user = TitledText("Connor", "d4f1g54sdf5g1d5f4g65ds4564df65f4g65d54gdfsg")
|
||||
senderInfo = TitledText("Connor", "d4f1g54sdf5g1d5f4g65ds4564df65f4g65d54gdfsg")
|
||||
)
|
||||
}
|
||||
|
||||
@ -179,11 +182,11 @@ class MessageDetailActivity: PassphraseRequiredActionBarActivity() {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sent != null || received != null || user != null) CellWithPadding {
|
||||
if (sent != null || received != null || senderInfo != null) CellWithPadding {
|
||||
Column(verticalArrangement = Arrangement.spacedBy(16.dp)) {
|
||||
sent?.let { titledText(it) }
|
||||
received?.let { titledText(it) }
|
||||
user?.let {
|
||||
senderInfo?.let {
|
||||
titledView("From:") {
|
||||
Row {
|
||||
Box(
|
||||
@ -192,7 +195,7 @@ class MessageDetailActivity: PassphraseRequiredActionBarActivity() {
|
||||
.height(60.dp)
|
||||
) {
|
||||
AndroidView(
|
||||
factory = { ProfilePictureView(it) },
|
||||
factory = { ProfilePictureView(it).apply { sender?.let(::update) } },
|
||||
modifier = Modifier.align(Alignment.Center)
|
||||
.width(46.dp)
|
||||
.height(46.dp)
|
||||
|
@ -31,7 +31,6 @@ class MentionCandidateView : LinearLayout {
|
||||
profilePictureView.publicKey = mentionCandidate.publicKey
|
||||
profilePictureView.displayName = mentionCandidate.displayName
|
||||
profilePictureView.additionalPublicKey = null
|
||||
profilePictureView.glide = glide!!
|
||||
profilePictureView.update()
|
||||
if (openGroupServer != null && openGroupRoom != null) {
|
||||
val isUserModerator = OpenGroupManager.isUserModerator(context, "$openGroupRoom.$openGroupServer", mentionCandidate.publicKey)
|
||||
|
@ -31,7 +31,6 @@ class MentionCandidateView : RelativeLayout {
|
||||
profilePictureView.publicKey = candidate.publicKey
|
||||
profilePictureView.displayName = candidate.displayName
|
||||
profilePictureView.additionalPublicKey = null
|
||||
profilePictureView.glide = glide!!
|
||||
profilePictureView.update()
|
||||
if (openGroupServer != null && openGroupRoom != null) {
|
||||
val isUserModerator = OpenGroupManager.isUserModerator(context, "$openGroupRoom.$openGroupServer", candidate.publicKey)
|
||||
|
@ -158,7 +158,6 @@ class VisibleMessageView : LinearLayout {
|
||||
if (isGroupThread && !message.isOutgoing) {
|
||||
if (isEndOfMessageCluster) {
|
||||
binding.profilePictureView.publicKey = senderSessionID
|
||||
binding.profilePictureView.glide = glide
|
||||
binding.profilePictureView.update(message.individualRecipient)
|
||||
binding.profilePictureView.setOnClickListener {
|
||||
if (thread.isOpenGroupRecipient) {
|
||||
|
@ -58,7 +58,6 @@ class ConversationView : LinearLayout {
|
||||
} else {
|
||||
ContextCompat.getDrawable(context, R.drawable.conversation_view_background)
|
||||
}
|
||||
binding.profilePictureView.glide = glide
|
||||
val unreadCount = thread.unreadCount
|
||||
if (thread.recipient.isBlocked) {
|
||||
binding.accentView.setBackgroundResource(R.color.destructive)
|
||||
|
@ -151,7 +151,6 @@ class HomeActivity : PassphraseRequiredActionBarActivity(),
|
||||
// Set up Glide
|
||||
glide = GlideApp.with(this)
|
||||
// Set up toolbar buttons
|
||||
binding.profileButton.glide = glide
|
||||
binding.profileButton.setOnClickListener { openSettings() }
|
||||
binding.searchViewContainer.setOnClickListener {
|
||||
binding.globalSearchInputLayout.requestFocus()
|
||||
|
@ -56,7 +56,6 @@ class UserDetailsBottomSheet: BottomSheetDialogFragment() {
|
||||
val threadRecipient = threadDb.getRecipientForThreadId(threadID) ?: return dismiss()
|
||||
with(binding) {
|
||||
profilePictureView.publicKey = publicKey
|
||||
profilePictureView.glide = GlideApp.with(this@UserDetailsBottomSheet)
|
||||
profilePictureView.isLarge = true
|
||||
profilePictureView.update(recipient)
|
||||
nameTextViewContainer.visibility = View.VISIBLE
|
||||
|
@ -89,9 +89,7 @@ class GlobalSearchAdapter (private val modelCallback: (Model)->Unit): RecyclerVi
|
||||
|
||||
class ContentView(view: View, private val modelCallback: (Model) -> Unit) : RecyclerView.ViewHolder(view) {
|
||||
|
||||
val binding = ViewGlobalSearchResultBinding.bind(view).apply {
|
||||
searchResultProfilePicture.glide = GlideApp.with(root)
|
||||
}
|
||||
val binding = ViewGlobalSearchResultBinding.bind(view)
|
||||
|
||||
fun bindPayload(newQuery: String, model: Model) {
|
||||
bindQuery(newQuery, model)
|
||||
|
@ -34,7 +34,6 @@ class MessageRequestView : LinearLayout {
|
||||
// region Updating
|
||||
fun bind(thread: ThreadRecord, glide: GlideRequests) {
|
||||
this.thread = thread
|
||||
binding.profilePictureView.glide = glide
|
||||
val senderDisplayName = getUserDisplayName(thread.recipient)
|
||||
?: thread.recipient.address.toString()
|
||||
binding.displayNameTextView.text = senderDisplayName
|
||||
|
@ -49,7 +49,6 @@ class BlockedContactsAdapter(val viewModel: BlockedContactsViewModel) : ListAdap
|
||||
fun bind(selectable: SelectableRecipient, toggle: (SelectableRecipient) -> Unit) {
|
||||
binding.recipientName.text = selectable.item.name
|
||||
with (binding.profilePictureView) {
|
||||
glide = this@ViewHolder.glide
|
||||
update(selectable.item)
|
||||
}
|
||||
binding.root.setOnClickListener { toggle(selectable) }
|
||||
|
@ -101,7 +101,6 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() {
|
||||
TextSecurePreferences.getProfileName(this) ?: truncateIdForDisplay(hexEncodedPublicKey)
|
||||
|
||||
private fun setupProfilePictureView(view: ProfilePictureView) {
|
||||
view.glide = glide
|
||||
view.apply {
|
||||
publicKey = hexEncodedPublicKey
|
||||
displayName = getDisplayName()
|
||||
|
@ -144,7 +144,6 @@ final class ReactionRecipientsAdapter extends RecyclerView.Adapter<ReactionRecip
|
||||
super(itemView);
|
||||
this.callback = callback;
|
||||
avatar = itemView.findViewById(R.id.reactions_bottom_view_avatar);
|
||||
avatar.glide = GlideApp.with(itemView);
|
||||
recipient = itemView.findViewById(R.id.reactions_bottom_view_recipient_name);
|
||||
remove = itemView.findViewById(R.id.reactions_bottom_view_recipient_remove);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user