Merge pull request #2802 from nextcloud/issue-1090

Implemented automatic scrolling to quoted messages on tap
This commit is contained in:
Andy Scherzinger 2023-02-27 18:13:10 +01:00 committed by GitHub
commit 7c75f8254d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View file

@ -40,6 +40,7 @@ import coil.load
import com.nextcloud.talk.R
import com.nextcloud.talk.application.NextcloudTalkApplication
import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedApplication
import com.nextcloud.talk.controllers.ChatController
import com.nextcloud.talk.databinding.ItemCustomIncomingTextMessageBinding
import com.nextcloud.talk.extensions.loadBotsAvatar
import com.nextcloud.talk.extensions.loadChangelogBotAvatar
@ -198,6 +199,11 @@ class IncomingTextMessageViewHolder(itemView: View, payload: Any) : MessageHolde
ContextCompat.getColor(binding.messageQuote.quoteColoredView.context, R.color.high_emphasis_text)
)
}
binding.messageQuote.quotedChatMessageView.setOnClickListener() {
val chatController = commonMessageInterface as ChatController
chatController.jumpToQuotedMessage(parentChatMessage)
}
}
private fun showAvatarOnChatMessage(message: ChatMessage) {

View file

@ -3487,6 +3487,16 @@ class ChatController(args: Bundle) :
)
}
fun jumpToQuotedMessage(parentMessage: ChatMessage) {
for (position in 0 until (adapter!!.items.size)) {
val currentItem = adapter?.items?.get(position)?.item
if (currentItem is ChatMessage && currentItem.id == parentMessage.id) {
layoutManager!!.scrollToPosition(position)
break
}
}
}
private fun logConversationInfos(methodName: String) {
Log.d(TAG, " |-----------------------------------------------")
Log.d(TAG, " | method: $methodName")