2021-07-09 03:14:21 +02:00
|
|
|
package org.thoughtcrime.securesms.conversation.v2.components
|
2019-10-10 04:53:02 +02:00
|
|
|
|
|
|
|
import android.content.Context
|
|
|
|
import android.util.AttributeSet
|
|
|
|
import android.view.LayoutInflater
|
|
|
|
import android.view.View
|
|
|
|
import android.widget.LinearLayout
|
2022-01-14 06:56:15 +01:00
|
|
|
import network.loki.messenger.databinding.ViewMentionCandidateBinding
|
2021-05-18 01:50:16 +02:00
|
|
|
import org.session.libsession.messaging.mentions.Mention
|
2022-08-10 10:17:48 +02:00
|
|
|
import org.thoughtcrime.securesms.groups.OpenGroupManager
|
2021-03-31 06:15:50 +02:00
|
|
|
import org.thoughtcrime.securesms.mms.GlideRequests
|
2019-10-10 04:53:02 +02:00
|
|
|
|
2022-01-14 06:56:15 +01:00
|
|
|
class MentionCandidateView : LinearLayout {
|
|
|
|
private lateinit var binding: ViewMentionCandidateBinding
|
2019-10-11 07:37:28 +02:00
|
|
|
var mentionCandidate = Mention("", "")
|
2019-10-10 04:53:02 +02:00
|
|
|
set(newValue) { field = newValue; update() }
|
2020-01-16 05:15:08 +01:00
|
|
|
var glide: GlideRequests? = null
|
2021-05-21 07:02:34 +02:00
|
|
|
var openGroupServer: String? = null
|
|
|
|
var openGroupRoom: String? = null
|
2019-10-10 04:53:02 +02:00
|
|
|
|
|
|
|
constructor(context: Context) : this(context, null)
|
2022-01-14 06:56:15 +01:00
|
|
|
constructor(context: Context, attrs: AttributeSet?) : this(context, attrs, 0)
|
|
|
|
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { initialize() }
|
2019-10-10 04:53:02 +02:00
|
|
|
|
2022-01-14 06:56:15 +01:00
|
|
|
private fun initialize() {
|
|
|
|
binding = ViewMentionCandidateBinding.inflate(LayoutInflater.from(context), this, true)
|
2019-10-10 04:53:02 +02:00
|
|
|
}
|
|
|
|
|
2022-01-14 06:56:15 +01:00
|
|
|
private fun update() = with(binding) {
|
2021-06-18 03:00:52 +02:00
|
|
|
mentionCandidateNameTextView.text = mentionCandidate.displayName
|
2023-06-30 03:31:57 +02:00
|
|
|
profilePictureView.publicKey = mentionCandidate.publicKey
|
|
|
|
profilePictureView.displayName = mentionCandidate.displayName
|
|
|
|
profilePictureView.additionalPublicKey = null
|
|
|
|
profilePictureView.update()
|
2021-05-21 07:02:34 +02:00
|
|
|
if (openGroupServer != null && openGroupRoom != null) {
|
2022-08-10 10:17:48 +02:00
|
|
|
val isUserModerator = OpenGroupManager.isUserModerator(context, "$openGroupRoom.$openGroupServer", mentionCandidate.publicKey)
|
2019-10-15 04:39:17 +02:00
|
|
|
moderatorIconImageView.visibility = if (isUserModerator) View.VISIBLE else View.GONE
|
|
|
|
} else {
|
|
|
|
moderatorIconImageView.visibility = View.GONE
|
|
|
|
}
|
2019-10-10 04:53:02 +02:00
|
|
|
}
|
|
|
|
}
|