Commit e344e3c0 authored by Lucio Maciel's avatar Lucio Maciel

Improve long tap area on messages

parent c176e9fe
...@@ -14,10 +14,9 @@ class AudioAttachmentViewHolder(itemView: View, ...@@ -14,10 +14,9 @@ class AudioAttachmentViewHolder(itemView: View,
init { init {
with(itemView) { with(itemView) {
setupActionMenu(attachment_container)
image_attachment.setVisible(false) image_attachment.setVisible(false)
audio_video_attachment.setVisible(true) audio_video_attachment.setVisible(true)
setupActionMenu(attachment_container)
setupActionMenu(audio_video_attachment)
} }
} }
......
...@@ -19,12 +19,9 @@ class AuthorAttachmentViewHolder(itemView: View, ...@@ -19,12 +19,9 @@ class AuthorAttachmentViewHolder(itemView: View,
init { init {
with(itemView) { with(itemView) {
setupActionMenu(author_attachment_container) setupActionMenu(author_attachment_container)
setupActionMenu(text_fields)
setupActionMenu(text_author_name)
} }
} }
override fun bindViews(data: AuthorAttachmentViewModel) { override fun bindViews(data: AuthorAttachmentViewModel) {
with(itemView) { with(itemView) {
data.icon?.let { icon -> data.icon?.let { icon ->
......
...@@ -3,6 +3,8 @@ package chat.rocket.android.chatroom.adapter ...@@ -3,6 +3,8 @@ package chat.rocket.android.chatroom.adapter
import android.support.v7.widget.RecyclerView import android.support.v7.widget.RecyclerView
import android.view.MenuItem import android.view.MenuItem
import android.view.View import android.view.View
import android.view.ViewGroup
import androidx.core.view.children
import chat.rocket.android.R import chat.rocket.android.R
import chat.rocket.android.chatroom.ui.bottomsheet.BottomSheetMenu import chat.rocket.android.chatroom.ui.bottomsheet.BottomSheetMenu
import chat.rocket.android.chatroom.ui.bottomsheet.adapter.ActionListAdapter import chat.rocket.android.chatroom.ui.bottomsheet.adapter.ActionListAdapter
...@@ -74,7 +76,7 @@ abstract class BaseViewHolder<T : BaseViewModel<*>>( ...@@ -74,7 +76,7 @@ abstract class BaseViewHolder<T : BaseViewModel<*>>(
fun onActionSelected(item: MenuItem, message: Message) fun onActionSelected(item: MenuItem, message: Message)
} }
val longClickListener = { view: View -> private val longClickListener = { view: View ->
if (data?.message?.isSystemMessage() == false) { if (data?.message?.isSystemMessage() == false) {
val menuItems = view.context.inflate(R.menu.message_actions).toList() val menuItems = view.context.inflate(R.menu.message_actions).toList()
menuItems.find { it.itemId == R.id.action_menu_msg_pin_unpin }?.apply { menuItems.find { it.itemId == R.id.action_menu_msg_pin_unpin }?.apply {
...@@ -90,6 +92,13 @@ abstract class BaseViewHolder<T : BaseViewModel<*>>( ...@@ -90,6 +92,13 @@ abstract class BaseViewHolder<T : BaseViewModel<*>>(
internal fun setupActionMenu(view: View) { internal fun setupActionMenu(view: View) {
if (listener.isActionsEnabled()) { if (listener.isActionsEnabled()) {
if (view is ViewGroup) {
for (child in view.children) {
if (child !is RecyclerView && child.id != R.id.recycler_view_reactions) {
setupActionMenu(child)
}
}
}
view.setOnLongClickListener(longClickListener) view.setOnLongClickListener(longClickListener)
} }
} }
......
...@@ -20,7 +20,6 @@ class ColorAttachmentViewHolder(itemView: View, ...@@ -20,7 +20,6 @@ class ColorAttachmentViewHolder(itemView: View,
init { init {
with(itemView) { with(itemView) {
setupActionMenu(attachment_text)
setupActionMenu(color_attachment_container) setupActionMenu(color_attachment_container)
attachment_text.movementMethod = LinkMovementMethod() attachment_text.movementMethod = LinkMovementMethod()
} }
......
...@@ -17,11 +17,9 @@ class GenericFileAttachmentViewHolder(itemView: View, ...@@ -17,11 +17,9 @@ class GenericFileAttachmentViewHolder(itemView: View,
init { init {
with(itemView) { with(itemView) {
setupActionMenu(file_attachment_container) setupActionMenu(file_attachment_container)
setupActionMenu(text_file_name)
} }
} }
override fun bindViews(data: GenericFileAttachmentViewModel) { override fun bindViews(data: GenericFileAttachmentViewModel) {
with(itemView) { with(itemView) {
text_file_name.content = data.attachmentTitle text_file_name.content = data.attachmentTitle
......
...@@ -47,7 +47,6 @@ class ImageAttachmentViewHolder(itemView: View, ...@@ -47,7 +47,6 @@ class ImageAttachmentViewHolder(itemView: View,
init { init {
with(itemView) { with(itemView) {
setupActionMenu(attachment_container) setupActionMenu(attachment_container)
setupActionMenu(image_attachment)
} }
} }
......
...@@ -4,7 +4,7 @@ import android.text.method.LinkMovementMethod ...@@ -4,7 +4,7 @@ import android.text.method.LinkMovementMethod
import android.view.View import android.view.View
import chat.rocket.android.chatroom.viewmodel.MessageAttachmentViewModel import chat.rocket.android.chatroom.viewmodel.MessageAttachmentViewModel
import chat.rocket.android.widget.emoji.EmojiReactionListener import chat.rocket.android.widget.emoji.EmojiReactionListener
import kotlinx.android.synthetic.main.item_message.view.* import kotlinx.android.synthetic.main.item_message_attachment.view.*
class MessageAttachmentViewHolder( class MessageAttachmentViewHolder(
itemView: View, itemView: View,
...@@ -14,8 +14,8 @@ class MessageAttachmentViewHolder( ...@@ -14,8 +14,8 @@ class MessageAttachmentViewHolder(
init { init {
with(itemView) { with(itemView) {
setupActionMenu(attachment_container)
text_content.movementMethod = LinkMovementMethod() text_content.movementMethod = LinkMovementMethod()
setupActionMenu(text_content)
} }
} }
......
...@@ -16,8 +16,8 @@ class MessageViewHolder( ...@@ -16,8 +16,8 @@ class MessageViewHolder(
init { init {
with(itemView) { with(itemView) {
setupActionMenu(message_container)
text_content.movementMethod = LinkMovementMethod() text_content.movementMethod = LinkMovementMethod()
setupActionMenu(text_content)
} }
} }
......
...@@ -14,10 +14,9 @@ class VideoAttachmentViewHolder(itemView: View, ...@@ -14,10 +14,9 @@ class VideoAttachmentViewHolder(itemView: View,
init { init {
with(itemView) { with(itemView) {
setupActionMenu(attachment_container)
image_attachment.setVisible(false) image_attachment.setVisible(false)
audio_video_attachment.setVisible(true) audio_video_attachment.setVisible(true)
setupActionMenu(attachment_container)
setupActionMenu(audio_video_attachment)
} }
} }
......
...@@ -58,6 +58,7 @@ ...@@ -58,6 +58,7 @@
android:ellipsize="end" android:ellipsize="end"
android:maxLines="2" android:maxLines="2"
android:textDirection="locale" android:textDirection="locale"
tools:visibility="visible"
app:layout_constraintEnd_toStartOf="@+id/layout_unread_messages_badge" app:layout_constraintEnd_toStartOf="@+id/layout_unread_messages_badge"
app:layout_constraintStart_toStartOf="@+id/image_chat_icon" app:layout_constraintStart_toStartOf="@+id/image_chat_icon"
app:layout_constraintTop_toBottomOf="@+id/text_chat_name" app:layout_constraintTop_toBottomOf="@+id/text_chat_name"
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/message_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground" android:background="?android:attr/selectableItemBackground"
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/attachment_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground" android:background="?android:attr/selectableItemBackground"
......
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