Unverified Commit 18e06ae0 authored by Filipe de Lima Brito's avatar Filipe de Lima Brito Committed by GitHub

Merge pull request #1393 from divyanshub024/message-confirm

[IMPROVEMENT] Confirm before deleting the message
parents 796f6c26 cfd7193b
package chat.rocket.android.chatroom.adapter
import android.app.AlertDialog
import android.content.Context
import androidx.recyclerview.widget.RecyclerView
import android.view.MenuItem
import android.view.ViewGroup
......@@ -18,7 +20,8 @@ class ChatRoomAdapter(
private val roomName: String? = null,
private val presenter: ChatRoomPresenter? = null,
private val enableActions: Boolean = true,
private val reactionListener: EmojiReactionListener? = null
private val reactionListener: EmojiReactionListener? = null,
private val context: Context? = null
) : RecyclerView.Adapter<BaseViewHolder<*>>() {
private val dataSet = ArrayList<BaseUiModel<*>>()
......@@ -233,7 +236,16 @@ class ChatRoomAdapter(
presenter?.unpinMessage(id)
}
}
R.id.action_message_delete -> presenter?.deleteMessage(roomId, id)
R.id.action_message_delete -> {
context?.let {
val builder = AlertDialog.Builder(it)
builder.setTitle(it.getString(R.string.msg_delete_message))
.setMessage(it.getString(R.string.msg_delete_description))
.setPositiveButton(it.getString(R.string.msg_ok)) { _, _ -> presenter?.deleteMessage(roomId, id) }
.setNegativeButton(it.getString(R.string.msg_cancel)) { _, _ -> }
.show()
}
}
R.id.action_menu_msg_react -> presenter?.showReactions(id)
else -> TODO("Not implemented")
}
......
......@@ -257,7 +257,8 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
chatRoomType,
chatRoomName,
presenter,
reactionListener = this@ChatRoomFragment
reactionListener = this@ChatRoomFragment,
context = context
)
recycler_view.adapter = adapter
if (dataSet.size >= 30) {
......
......@@ -132,6 +132,9 @@
// TODO: Add proper translation.
<string name="msg_search">Search</string>
<string name="msg_message_copied">Mensaje copiado</string>
// TODO: Add proper translation.
<string name="msg_delete_message">Delete Message</string>
<string name="msg_delete_description">Are you sure you want to delete this message</string>
<!-- Create channel messages -->
// TODO: Add proper translation.
......
......@@ -132,6 +132,9 @@
// TODO: Add proper translation.
<string name="msg_search">Search</string>
<string name="msg_message_copied">Message copié</string>
// TODO: Add proper translation.
<string name="msg_delete_message">Delete Message</string>
<string name="msg_delete_description">Are you sure you want to delete this message</string>
<!-- Create channel messages -->
// TODO: Add proper translation.
......
......@@ -123,6 +123,8 @@
// TODO: Add proper translation.
<string name="msg_search">Search</string>
<string name="msg_message_copied">संदेश कॉपी किया गया</string>
<string name="msg_delete_message">संदेश को हटाएं</string>
<string name="msg_delete_description">क्या आप निश्चित रूप से यह संदेश हटाना चाहते हैं</string>
<!-- Create channel messages -->
// TODO: Add proper translation.
......
......@@ -119,6 +119,9 @@
<string name="msg_channel_name">Nome do chat</string>
<string name="msg_search">Buscar</string>
<string name="msg_message_copied">Mensagem copiada</string>
// TODO: Add proper translation.
<string name="msg_delete_message">Delete Message</string>
<string name="msg_delete_description">Are you sure you want to delete this message</string>
<!-- Create channel messages -->
<string name="msg_private_channel">Privado</string>
......
......@@ -117,6 +117,9 @@
<string name="msg_several_users_are_typing">Несколько пользователей печатают…</string>
<string name="msg_no_search_found">Результатов не найдено</string>
<string name="msg_message_copied">Сообщение скопировано</string>
// TODO: Add proper translation.
<string name="msg_delete_message">Delete Message</string>
<string name="msg_delete_description">Are you sure you want to delete this message</string>
<string name="msg_channel_name">Назва каналу</string>
<string name="msg_search">Пошук</string>
......
......@@ -133,6 +133,8 @@
<string name="msg_channel_created_successfully">Channel created successfully</string>
<string name="msg_message_copied">Message copied</string>
<string name="msg_delete_message">Delete Message</string>
<string name="msg_delete_description">Are you sure you want to delete this message</string>
<!-- System messages -->
<string name="message_room_name_changed">Room name changed to: %1$s by %2$s</string>
......
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