Commit 60f0c4d4 authored by Łukasz Rutkowski's avatar Łukasz Rutkowski

Show users summary when long-clicking reaction

parent 79bc2d7d
......@@ -60,6 +60,10 @@ abstract class BaseViewHolder<T : BaseUiModel<*>>(
reactionListener?.onReactionAdded(messageId, emoji)
}
}
override fun onReactionLongClicked(emojiShortname: String, usernames: List<String>) {
reactionListener?.onReactionLongClicked(emojiShortname, usernames)
}
}
val context = itemView.context
val manager = FlexboxLayoutManager(context, FlexDirection.ROW)
......
......@@ -4,7 +4,6 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView
import chat.rocket.android.R
......@@ -76,7 +75,7 @@ class MessageReactionsAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>()
class SingleReactionViewHolder(
view: View,
private val listener: EmojiReactionListener?
) : RecyclerView.ViewHolder(view), View.OnClickListener {
) : RecyclerView.ViewHolder(view), View.OnClickListener, View.OnLongClickListener {
@Inject
lateinit var localRepository: LocalRepository
......@@ -119,6 +118,8 @@ class MessageReactionsAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>()
view_flipper_reaction.setOnClickListener(this@SingleReactionViewHolder)
text_count.setOnClickListener(this@SingleReactionViewHolder)
view_flipper_reaction.setOnLongClickListener(this@SingleReactionViewHolder)
text_count.setOnLongClickListener(this@SingleReactionViewHolder)
}
}
......@@ -130,6 +131,11 @@ class MessageReactionsAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>()
}
}
}
override fun onLongClick(v: View?): Boolean {
listener?.onReactionLongClicked(reaction.shortname, reaction.usernames)
return true
}
}
class AddReactionViewHolder(
......
......@@ -989,6 +989,10 @@ class ChatRoomPresenter @Inject constructor(
view.showReactionsPopup(messageId)
}
fun showReactionsSummary(emojiShortname: String, usernames: List<String>) {
view.showReactionsSummary(emojiShortname, usernames, currentLoggedUsername)
}
fun loadCommands() {
launchUI(strategy) {
try {
......
......@@ -140,6 +140,8 @@ interface ChatRoomView : LoadingView, MessageView {
fun showReactionsPopup(messageId: String)
fun showReactionsSummary(emojiShortname: String, usernames: List<String>, currentLoggedUsername: String?)
/**
* Show list of commands.
*
......
......@@ -22,6 +22,7 @@ import android.widget.EditText
import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.TextView
import android.widget.Toast
import androidx.annotation.DrawableRes
import androidx.core.text.bold
import androidx.core.view.isVisible
......@@ -665,6 +666,33 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
presenter.react(messageId, emoji.shortname)
}
override fun onReactionLongClicked(emojiShortname: String, usernames: List<String>) {
presenter.showReactionsSummary(emojiShortname, usernames)
}
override fun showReactionsSummary(emojiShortname: String, usernames: List<String>, currentLoggedUsername: String?) {
var usernamesString = usernames.asSequence()
.take(15)
.joinToString { username ->
if (username == currentLoggedUsername) {
getString(R.string.msg_you).toLowerCase()
} else {
"@$username"
}
}
if (usernames.size > 15) {
usernamesString += " " + getString(R.string.And_more, usernames.size - 15).toLowerCase()
} else {
usernamesString = usernamesString.replace(""",([^,]+)$""".toRegex()) {
" ${getString(R.string.and)}${it.groupValues[1]}"
}
}
if (usernamesString[0] != '@') {
usernamesString = usernamesString.capitalize()
}
showToast("$usernamesString ${getString(R.string.Reacted_with).toLowerCase()} $emojiShortname", Toast.LENGTH_LONG)
}
override fun showReactionsPopup(messageId: String) {
ui {
val emojiPickerPopup = EmojiPickerPopup(it)
......
......@@ -277,6 +277,9 @@
<!-- Emoji message-->
<string name="msg_no_recent_emoji">Keine letzten Emojis</string>
<string name="alert_title_default_skin_tone">Standart Hautton</string>
<string name="And_more">Und %1$d mehr</string>
<string name="and">und</string>
<string name="Reacted_with">Reagierte mit</string>
<!-- Sorting and grouping-->
<string name="menu_chatroom_sort">Sortiere</string>
......
......@@ -275,6 +275,9 @@
<!-- Emoji message-->
<string name="msg_no_recent_emoji">Sin emojis recientes</string>
<string name="alert_title_default_skin_tone">Tono de piel predeterminado</string>
<string name="And_more">Y %1$d mas</string>
<string name="and">y</string>
<string name="Reacted_with">Reacciono con</string>
<!-- Sorting and grouping-->
<string name="menu_chatroom_sort">Ordenar</string>
......
......@@ -280,6 +280,9 @@
<!-- Emoji message-->
<string name="msg_no_recent_emoji">Aucun emoji récent</string>
<string name="alert_title_default_skin_tone">Tonalité de peau par défaut</string>
<string name="And_more">et encore %1$d</string>
<string name="and">et</string>
<string name="Reacted_with">a réagi avec</string>
<!-- Sorting and grouping-->
<string name="menu_chatroom_sort">Trier</string>
......
......@@ -282,6 +282,9 @@
<!-- Emoji message-->
<string name="msg_no_recent_emoji">最近の絵文字はありません</string>
<string name="alert_title_default_skin_tone">デフォルトスキントークン</string>
<string name="And_more">さらに %1$d</string>
<string name="and"></string>
<string name="Reacted_with">がリアクションしています</string>
<!-- Sorting and grouping-->
<string name="menu_chatroom_sort">ソート</string>
......
......@@ -278,6 +278,9 @@
<!-- Emoji message-->
<string name="msg_no_recent_emoji">Nenhum emoji recente</string>
<string name="alert_title_default_skin_tone">Tom de pele padrão</string>
<string name="And_more">E mais %1$d</string>
<string name="and">e</string>
<string name="Reacted_with">Reagiu com</string>
<!-- Sorting and grouping-->
<string name="menu_chatroom_sort">Ordenar</string>
......
......@@ -275,6 +275,9 @@
<!-- Emoji message-->
<string name="msg_no_recent_emoji">Пусто</string>
<string name="alert_title_default_skin_tone">Тон кожи по умолчанию</string>
<string name="And_more">И еще %1$d</string>
<string name="and">и</string>
<string name="Reacted_with">Реагирует с</string>
<!-- Sorting and grouping-->
<string name="menu_chatroom_sort">Сортировать</string>
......
......@@ -279,6 +279,9 @@
<!-- Emoji message-->
<string name="msg_no_recent_emoji">Son kullanılan emoji bulunmamaktadır</string>
<string name="alert_title_default_skin_tone">Varsayılan tasarım tonu</string>
<string name="And_more">Ve %1$d kadar daha fazla</string>
<string name="and">ve</string>
<string name="Reacted_with">ile reaksiyona sokulur</string>
<!-- Sorting and grouping-->
<string name="menu_chatroom_sort">Sırala</string>
......
......@@ -276,6 +276,9 @@
<!-- Emoji message-->
<string name="msg_no_recent_emoji">Пусто</string>
<string name="alert_title_default_skin_tone">Тон шкіри за замовчуванням</string>
<string name="And_more">І ще %1$d</string>
<string name="and">і</string>
<string name="Reacted_with">реагує з</string>
<!-- Sorting and grouping-->
<string name="menu_chatroom_sort">Сортувати</string>
......
......@@ -292,6 +292,9 @@ https://github.com/RocketChat/java-code-styles/blob/master/CODING_STYLE.md#strin
<!-- Emoji message-->
<string name="msg_no_recent_emoji">No recent emojis</string>
<string name="alert_title_default_skin_tone">Default skin tone</string>
<string name="And_more">And %1$d more</string>
<string name="and">and</string>
<string name="Reacted_with">Reacted with</string>
<!-- Sorting and grouping-->
<string name="menu_chatroom_sort">Sort</string>
......
......@@ -16,4 +16,12 @@ interface EmojiReactionListener {
* @param emojiShortname The shortname of the emoji (:grin:, :smiley:, etc).
*/
fun onReactionTouched(messageId: String, emojiShortname: String)
/**
* Callback when an added reaction is long-clicked.
*
* @param emojiShortname The shortname of the emoji (:grin:, :smiley:, etc).
* @param usernames The list of usernames of users who added the reaction.
*/
fun onReactionLongClicked(emojiShortname: String, usernames: List<String>)
}
\ 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