Commit 33796d86 authored by Leonardo Aramaki's avatar Leonardo Aramaki

Add support on the chat view for reply/quote actions

parent 5d68045a
...@@ -42,6 +42,14 @@ interface ChatRoomView : LoadingView, MessageView { ...@@ -42,6 +42,14 @@ interface ChatRoomView : LoadingView, MessageView {
*/ */
fun dispatchUpdateMessage(index: Int, message: MessageViewModel) fun dispatchUpdateMessage(index: Int, message: MessageViewModel)
/**
* Show reply status above the message composer.
*
* @param replyMarkdown The markdown of the message reply.
* @param quotedMessage The message to quote.
*/
fun showReplyStatus(replyMarkdown: String, quotedMessage: String)
fun disableMessageInput() fun disableMessageInput()
fun enableMessageInput(clear: Boolean = false) fun enableMessageInput(clear: Boolean = false)
} }
\ No newline at end of file
...@@ -45,6 +45,8 @@ class ChatRoomFragment : Fragment(), ChatRoomView { ...@@ -45,6 +45,8 @@ class ChatRoomFragment : Fragment(), ChatRoomView {
private lateinit var chatRoomType: String private lateinit var chatRoomType: String
private var isChatRoomReadOnly: Boolean = false private var isChatRoomReadOnly: Boolean = false
private lateinit var adapter: ChatRoomAdapter private lateinit var adapter: ChatRoomAdapter
private lateinit var citationSnackbar: CitationSnackbar
private var citation: String? = null
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
...@@ -67,6 +69,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView { ...@@ -67,6 +69,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
presenter.loadMessages(chatRoomId, chatRoomType) presenter.loadMessages(chatRoomId, chatRoomType)
setupComposer() setupComposer()
setupCitationSnackbar()
} }
override fun onDestroyView() { override fun onDestroyView() {
...@@ -77,7 +80,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView { ...@@ -77,7 +80,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView {
override fun showMessages(dataSet: List<MessageViewModel>, serverUrl: String) { override fun showMessages(dataSet: List<MessageViewModel>, serverUrl: String) {
activity?.apply { activity?.apply {
if (recycler_view.adapter == null) { if (recycler_view.adapter == null) {
adapter = ChatRoomAdapter(serverUrl, presenter) adapter = ChatRoomAdapter(serverUrl, chatRoomType, chatRoomName, presenter)
recycler_view.adapter = adapter recycler_view.adapter = adapter
val linearLayoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, true) val linearLayoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, true)
recycler_view.layoutManager = linearLayoutManager recycler_view.layoutManager = linearLayoutManager
...@@ -126,6 +129,14 @@ class ChatRoomFragment : Fragment(), ChatRoomView { ...@@ -126,6 +129,14 @@ class ChatRoomFragment : Fragment(), ChatRoomView {
adapter.removeItem(msgId) adapter.removeItem(msgId)
} }
override fun showReplyStatus(replyMarkdown: String, quotedMessage: String) {
activity?.apply {
citation = replyMarkdown
citationSnackbar.text = quotedMessage
citationSnackbar.show()
}
}
override fun showLoading() = view_loading.setVisible(true) override fun showLoading() = view_loading.setVisible(true)
override fun hideLoading() = view_loading.setVisible(false) override fun hideLoading() = view_loading.setVisible(false)
...@@ -139,7 +150,24 @@ class ChatRoomFragment : Fragment(), ChatRoomView { ...@@ -139,7 +150,24 @@ class ChatRoomFragment : Fragment(), ChatRoomView {
text_room_is_read_only.setVisible(true) text_room_is_read_only.setVisible(true)
top_container.setVisible(false) top_container.setVisible(false)
} else { } else {
text_send.setOnClickListener { sendMessage(text_message.textContent) } text_send.setOnClickListener {
var textMessage = citation ?: ""
textMessage = textMessage + text_message.textContent
sendMessage(textMessage)
clearCitation()
}
} }
} }
private fun setupCitationSnackbar() {
citationSnackbar = CitationSnackbar.make(message_list_container, "")
citationSnackbar.cancelView.setOnClickListener({
clearCitation()
})
}
private fun clearCitation() {
citation = null
citationSnackbar.dismiss()
}
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment