Added left to right swipe action on chat rooms as a shortcut to mark as read

This commit is contained in:
Sylvain Berfini 2021-04-22 17:47:37 +02:00
parent 9147601a1a
commit e2324eae66
2 changed files with 13 additions and 2 deletions

View file

@ -25,6 +25,7 @@ This version is a full rewrite of the app in kotlin, using modern Android compon
- Can display multiple files in the same chat bubble - Can display multiple files in the same chat bubble
- Display video in recordings if available - Display video in recordings if available
- "Swipe left to delete" action available on calls history, contacts & chat rooms list - "Swipe left to delete" action available on calls history, contacts & chat rooms list
- "Swipe right" to mark a chat room as read
- Android 11 people & conversation compliant - Android 11 people & conversation compliant
- New animations between fragments and for unread chat messages / missed calls counters (can be disabled) - New animations between fragments and for unread chat messages / missed calls counters (can be disabled)
- Bubble & conversation support for chat message notifications - Bubble & conversation support for chat message notifications

View file

@ -103,8 +103,18 @@ class MasterChatRoomsFragment : MasterFragment<ChatRoomMasterFragmentBinding, Ch
white, white,
ContextCompat.getColor(requireContext(), R.color.red_color) ContextCompat.getColor(requireContext(), R.color.red_color)
) )
swipeConfiguration.leftToRightAction = RecyclerViewSwipeConfiguration.Action(
requireContext().getString(R.string.received_chat_notification_mark_as_read_label),
white,
ContextCompat.getColor(requireContext(), R.color.imdn_read_color)
)
val swipeListener = object : RecyclerViewSwipeListener { val swipeListener = object : RecyclerViewSwipeListener {
override fun onLeftToRightSwipe(viewHolder: RecyclerView.ViewHolder) {} override fun onLeftToRightSwipe(viewHolder: RecyclerView.ViewHolder) {
adapter.notifyItemChanged(viewHolder.adapterPosition)
val chatRoom = adapter.currentList[viewHolder.adapterPosition]
chatRoom.markAsRead()
coreContext.notificationsManager.dismissChatNotification(chatRoom)
}
override fun onRightToLeftSwipe(viewHolder: RecyclerView.ViewHolder) { override fun onRightToLeftSwipe(viewHolder: RecyclerView.ViewHolder) {
val viewModel = DialogViewModel(getString(R.string.chat_room_delete_one_dialog)) val viewModel = DialogViewModel(getString(R.string.chat_room_delete_one_dialog))
@ -123,7 +133,7 @@ class MasterChatRoomsFragment : MasterFragment<ChatRoomMasterFragmentBinding, Ch
dialog.show() dialog.show()
} }
} }
RecyclerViewSwipeUtils(ItemTouchHelper.LEFT, swipeConfiguration, swipeListener) RecyclerViewSwipeUtils(ItemTouchHelper.LEFT or ItemTouchHelper.RIGHT, swipeConfiguration, swipeListener)
.attachToRecyclerView(binding.chatList) .attachToRecyclerView(binding.chatList)
// Divider between items // Divider between items