Hide right arrow if threepid invite can not be revoked

This commit is contained in:
Benoit Marty 2020-07-10 09:46:34 +02:00
parent 3d68b15e60
commit 4ba1a34f38
2 changed files with 6 additions and 1 deletions

View file

@ -20,6 +20,7 @@ package im.vector.riotx.core.epoxy.profiles
import android.view.View import android.view.View
import android.widget.ImageView import android.widget.ImageView
import android.widget.TextView import android.widget.TextView
import androidx.core.view.isVisible
import com.airbnb.epoxy.EpoxyAttribute import com.airbnb.epoxy.EpoxyAttribute
import com.airbnb.epoxy.EpoxyModelClass import com.airbnb.epoxy.EpoxyModelClass
import im.vector.matrix.android.api.crypto.RoomEncryptionTrustLevel import im.vector.matrix.android.api.crypto.RoomEncryptionTrustLevel
@ -36,6 +37,7 @@ abstract class ProfileMatrixItem : VectorEpoxyModel<ProfileMatrixItem.Holder>()
@EpoxyAttribute lateinit var avatarRenderer: AvatarRenderer @EpoxyAttribute lateinit var avatarRenderer: AvatarRenderer
@EpoxyAttribute lateinit var matrixItem: MatrixItem @EpoxyAttribute lateinit var matrixItem: MatrixItem
@EpoxyAttribute var editable: Boolean = true
@EpoxyAttribute var userEncryptionTrustLevel: RoomEncryptionTrustLevel? = null @EpoxyAttribute var userEncryptionTrustLevel: RoomEncryptionTrustLevel? = null
@EpoxyAttribute var clickListener: View.OnClickListener? = null @EpoxyAttribute var clickListener: View.OnClickListener? = null
@ -46,9 +48,10 @@ abstract class ProfileMatrixItem : VectorEpoxyModel<ProfileMatrixItem.Holder>()
.takeIf { it != bestName } .takeIf { it != bestName }
// Special case for ThreePid fake matrix item // Special case for ThreePid fake matrix item
.takeIf { it != "@" } .takeIf { it != "@" }
holder.view.setOnClickListener(clickListener) holder.view.setOnClickListener(clickListener?.takeIf { editable })
holder.titleView.text = bestName holder.titleView.text = bestName
holder.subtitleView.setTextOrHide(matrixId) holder.subtitleView.setTextOrHide(matrixId)
holder.editableView.isVisible = editable
avatarRenderer.render(matrixItem, holder.avatarImageView) avatarRenderer.render(matrixItem, holder.avatarImageView)
holder.avatarDecorationImageView.setImageResource(userEncryptionTrustLevel.toImageRes()) holder.avatarDecorationImageView.setImageResource(userEncryptionTrustLevel.toImageRes())
} }
@ -58,5 +61,6 @@ abstract class ProfileMatrixItem : VectorEpoxyModel<ProfileMatrixItem.Holder>()
val subtitleView by bind<TextView>(R.id.matrixItemSubtitle) val subtitleView by bind<TextView>(R.id.matrixItemSubtitle)
val avatarImageView by bind<ImageView>(R.id.matrixItemAvatar) val avatarImageView by bind<ImageView>(R.id.matrixItemAvatar)
val avatarDecorationImageView by bind<ImageView>(R.id.matrixItemAvatarDecoration) val avatarDecorationImageView by bind<ImageView>(R.id.matrixItemAvatarDecoration)
val editableView by bind<View>(R.id.matrixItemEditable)
} }
} }

View file

@ -100,6 +100,7 @@ class RoomMemberListController @Inject constructor(
id("3pid_$idx") id("3pid_$idx")
matrixItem(content.toMatrixItem()) matrixItem(content.toMatrixItem())
avatarRenderer(avatarRenderer) avatarRenderer(avatarRenderer)
editable(data.actionsPermissions.canRevokeThreePidInvite)
clickListener { _ -> clickListener { _ ->
callback?.onThreePidInvites(event) callback?.onThreePidInvites(event)
} }