fix to always show author name in group conversations

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2023-01-19 11:10:18 +01:00
parent 8b0a58faeb
commit 3e0026d49d
No known key found for this signature in database
GPG key ID: C793F8B59F43CE7B
6 changed files with 41 additions and 15 deletions

View file

@ -122,6 +122,7 @@ class IncomingLinkPreviewMessageViewHolder(incomingView: View, payload: Any) : M
private fun setAvatarAndAuthorOnMessageItem(message: ChatMessage) { private fun setAvatarAndAuthorOnMessageItem(message: ChatMessage) {
val author: String = message.actorDisplayName!! val author: String = message.actorDisplayName!!
if (!TextUtils.isEmpty(author)) { if (!TextUtils.isEmpty(author)) {
binding.messageAuthor.visibility = View.VISIBLE
binding.messageAuthor.text = author binding.messageAuthor.text = author
binding.messageUserAvatar.setOnClickListener { binding.messageUserAvatar.setOnClickListener {
(payload as? MessagePayload)?.profileBottomSheet?.showFor(message.actorId!!, itemView.context) (payload as? MessagePayload)?.profileBottomSheet?.showFor(message.actorId!!, itemView.context)

View file

@ -126,6 +126,7 @@ class IncomingLocationMessageViewHolder(incomingView: View, payload: Any) : Mess
private fun setAvatarAndAuthorOnMessageItem(message: ChatMessage) { private fun setAvatarAndAuthorOnMessageItem(message: ChatMessage) {
val author: String = message.actorDisplayName!! val author: String = message.actorDisplayName!!
if (!TextUtils.isEmpty(author)) { if (!TextUtils.isEmpty(author)) {
binding.messageAuthor.visibility = View.VISIBLE
binding.messageAuthor.text = author binding.messageAuthor.text = author
binding.messageUserAvatar.setOnClickListener { binding.messageUserAvatar.setOnClickListener {
(payload as? MessagePayload)?.profileBottomSheet?.showFor(message.actorId!!, itemView.context) (payload as? MessagePayload)?.profileBottomSheet?.showFor(message.actorId!!, itemView.context)

View file

@ -146,6 +146,7 @@ class IncomingPollMessageViewHolder(incomingView: View, payload: Any) : MessageH
private fun setAvatarAndAuthorOnMessageItem(message: ChatMessage) { private fun setAvatarAndAuthorOnMessageItem(message: ChatMessage) {
val author: String = message.actorDisplayName!! val author: String = message.actorDisplayName!!
if (!TextUtils.isEmpty(author)) { if (!TextUtils.isEmpty(author)) {
binding.messageAuthor.visibility = View.VISIBLE
binding.messageAuthor.text = author binding.messageAuthor.text = author
binding.messageUserAvatar.setOnClickListener { binding.messageUserAvatar.setOnClickListener {
(payload as? MessagePayload)?.profileBottomSheet?.showFor(message.actorId!!, itemView.context) (payload as? MessagePayload)?.profileBottomSheet?.showFor(message.actorId!!, itemView.context)

View file

@ -3,6 +3,8 @@
* *
* @author Andy Scherzinger * @author Andy Scherzinger
* @author Tim Krüger * @author Tim Krüger
* @author Marcel Hibbe
* Copyright (C) 2022-2023 Marcel Hibbe <dev@mhibbe.de>
* Copyright (C) 2021-2022 Tim Krüger <t@timkrueger.me> * Copyright (C) 2021-2022 Tim Krüger <t@timkrueger.me>
* Copyright (C) 2021 Andy Scherzinger <info@andy-scherzinger.de> * Copyright (C) 2021 Andy Scherzinger <info@andy-scherzinger.de>
* *

View file

@ -4,6 +4,8 @@
* @author Mario Danic * @author Mario Danic
* @author Andy Scherzinger * @author Andy Scherzinger
* @author Tim Krüger * @author Tim Krüger
* @author Marcel Hibbe
* Copyright (C) 2022-2023 Marcel Hibbe <dev@mhibbe.de>
* Copyright (C) 2021 Tim Krüger <t@timkrueger.me> * Copyright (C) 2021 Tim Krüger <t@timkrueger.me>
* Copyright (C) 2021 Andy Scherzinger <info@andy-scherzinger.de> * Copyright (C) 2021 Andy Scherzinger <info@andy-scherzinger.de>
* Copyright (C) 2017-2018 Mario Danic <mario@lovelyhq.com> * Copyright (C) 2017-2018 Mario Danic <mario@lovelyhq.com>
@ -75,20 +77,10 @@ class IncomingTextMessageViewHolder(itemView: View, payload: Any) : MessageHolde
override fun onBind(message: ChatMessage) { override fun onBind(message: ChatMessage) {
super.onBind(message) super.onBind(message)
sharedApplication!!.componentApplication.inject(this) sharedApplication!!.componentApplication.inject(this)
processAuthor(message)
if (!message.isGrouped && !message.isOneToOneConversation) { setAvatarAndAuthorOnMessageItem(message)
showAvatarOnChatMessage(message)
} else {
if (message.isOneToOneConversation) {
binding.messageUserAvatar.visibility = View.GONE
} else {
binding.messageUserAvatar.visibility = View.INVISIBLE
}
binding.messageAuthor.visibility = View.GONE
}
viewThemeUtils.talk.themeIncomingMessageBubble(bubble, message.isGrouped, message.isDeleted) colorizeMessageBubble(message)
itemView.isSelected = false itemView.isSelected = false
@ -139,15 +131,43 @@ class IncomingTextMessageViewHolder(itemView: View, payload: Any) : MessageHolde
commonMessageInterface.onClickReaction(chatMessage, emoji) commonMessageInterface.onClickReaction(chatMessage, emoji)
} }
private fun processAuthor(message: ChatMessage) { private fun setAvatarAndAuthorOnMessageItem(message: ChatMessage) {
if (!TextUtils.isEmpty(message.actorDisplayName)) { val author: String = message.actorDisplayName!!
binding.messageAuthor.text = message.actorDisplayName if (!TextUtils.isEmpty(author)) {
binding.messageAuthor.visibility = View.VISIBLE
binding.messageAuthor.text = author
binding.messageUserAvatar.setOnClickListener { binding.messageUserAvatar.setOnClickListener {
(payload as? MessagePayload)?.profileBottomSheet?.showFor(message.actorId!!, itemView.context) (payload as? MessagePayload)?.profileBottomSheet?.showFor(message.actorId!!, itemView.context)
} }
} else { } else {
binding.messageAuthor.setText(R.string.nc_nick_guest) binding.messageAuthor.setText(R.string.nc_nick_guest)
} }
if (!message.isGrouped && !message.isOneToOneConversation) {
setAvatarOnMessage(message)
} else {
if (message.isOneToOneConversation) {
binding.messageUserAvatar.visibility = View.GONE
} else {
binding.messageUserAvatar.visibility = View.INVISIBLE
}
binding.messageAuthor.visibility = View.GONE
}
}
private fun setAvatarOnMessage(message: ChatMessage) {
binding.messageUserAvatar.visibility = View.VISIBLE
if (message.actorType == "guests") {
// do nothing, avatar is set
} else if (message.actorType == "bots" && message.actorId == "changelog") {
binding.messageUserAvatar.loadChangelogBotAvatar()
} else if (message.actorType == "bots") {
binding.messageUserAvatar.loadBotsAvatar()
}
}
private fun colorizeMessageBubble(message: ChatMessage) {
viewThemeUtils.talk.themeIncomingMessageBubble(bubble, message.isGrouped, message.isDeleted)
} }
private fun processParentMessage(message: ChatMessage) { private fun processParentMessage(message: ChatMessage) {

View file

@ -223,6 +223,7 @@ class IncomingVoiceMessageViewHolder(incomingView: View, payload: Any) : Message
private fun setAvatarAndAuthorOnMessageItem(message: ChatMessage) { private fun setAvatarAndAuthorOnMessageItem(message: ChatMessage) {
val author: String = message.actorDisplayName!! val author: String = message.actorDisplayName!!
if (!TextUtils.isEmpty(author)) { if (!TextUtils.isEmpty(author)) {
binding.messageAuthor.visibility = View.VISIBLE
binding.messageAuthor.text = author binding.messageAuthor.text = author
binding.messageUserAvatar.setOnClickListener { binding.messageUserAvatar.setOnClickListener {
(payload as? MessagePayload)?.profileBottomSheet?.showFor(message.actorId!!, itemView.context) (payload as? MessagePayload)?.profileBottomSheet?.showFor(message.actorId!!, itemView.context)