Commit 48c17f7a authored by Leonardo Aramaki's avatar Leonardo Aramaki

Add list of message action items to hide for a specific message. First check...

Add list of message action items to hide for a specific message. First check for Message_Read_Receipt_Store_Users setting
parent eeffed86
...@@ -77,7 +77,8 @@ abstract class BaseViewHolder<T : BaseViewModel<*>>( ...@@ -77,7 +77,8 @@ abstract class BaseViewHolder<T : BaseViewModel<*>>(
private val onClickListener = { view: View -> private val onClickListener = { view: View ->
if (data?.message?.isSystemMessage() == false) { if (data?.message?.isSystemMessage() == false) {
data?.message?.let { data?.let { vm ->
vm.message.let {
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_message_unpin }?.apply { menuItems.find { it.itemId == R.id.action_message_unpin }?.apply {
setTitle(if (it.pinned) R.string.action_msg_unpin else R.string.action_msg_pin) setTitle(if (it.pinned) R.string.action_msg_unpin else R.string.action_msg_pin)
...@@ -89,11 +90,14 @@ abstract class BaseViewHolder<T : BaseViewModel<*>>( ...@@ -89,11 +90,14 @@ abstract class BaseViewHolder<T : BaseViewModel<*>>(
setTitle(if (isStarred) R.string.action_msg_unstar else R.string.action_msg_star) setTitle(if (isStarred) R.string.action_msg_unstar else R.string.action_msg_star)
isChecked = isStarred isChecked = isStarred
} }
val adapter = ActionListAdapter(menuItems, this@BaseViewHolder) val adapter = ActionListAdapter(menuItems = menuItems.filterNot {
vm.menuItemsToHide.contains(it.itemId)
}, callback = this@BaseViewHolder)
BottomSheetMenu(adapter).show(view.context) BottomSheetMenu(adapter).show(view.context)
} }
} }
} }
}
internal fun setupActionMenu(view: View) { internal fun setupActionMenu(view: View) {
if (listener.isActionsEnabled()) { if (listener.isActionsEnabled()) {
......
...@@ -188,6 +188,11 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR ...@@ -188,6 +188,11 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
super.onDestroyView() super.onDestroyView()
} }
override fun onResume() {
super.onResume()
activity?.invalidateOptionsMenu()
}
override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) { override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) {
if (requestCode == REQUEST_CODE_FOR_PERFORM_SAF && resultCode == Activity.RESULT_OK) { if (requestCode == REQUEST_CODE_FOR_PERFORM_SAF && resultCode == Activity.RESULT_OK) {
if (resultData != null) { if (resultData != null) {
...@@ -199,6 +204,10 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR ...@@ -199,6 +204,10 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
super.onCreateOptionsMenu(menu, inflater) super.onCreateOptionsMenu(menu, inflater)
inflater.inflate(R.menu.chatroom_actions, menu) inflater.inflate(R.menu.chatroom_actions, menu)
}
override fun onPrepareOptionsMenu(menu: Menu) {
super.onPrepareOptionsMenu(menu)
menu.findItem(R.id.action_members_list)?.isVisible = !isBroadcastChannel menu.findItem(R.id.action_members_list)?.isVisible = !isBroadcastChannel
} }
......
...@@ -15,7 +15,8 @@ data class AudioAttachmentViewModel( ...@@ -15,7 +15,8 @@ data class AudioAttachmentViewModel(
override var nextDownStreamMessage: BaseViewModel<*>? = null, override var nextDownStreamMessage: BaseViewModel<*>? = null,
override var preview: Message? = null, override var preview: Message? = null,
override var isTemporary: Boolean = false, override var isTemporary: Boolean = false,
override var unread: Boolean? = null override var unread: Boolean? = null,
override var menuItemsToHide: MutableList<Int> = mutableListOf()
) : BaseFileAttachmentViewModel<AudioAttachment> { ) : BaseFileAttachmentViewModel<AudioAttachment> {
override val viewType: Int override val viewType: Int
get() = BaseViewModel.ViewType.AUDIO_ATTACHMENT.viewType get() = BaseViewModel.ViewType.AUDIO_ATTACHMENT.viewType
......
...@@ -17,7 +17,8 @@ data class AuthorAttachmentViewModel( ...@@ -17,7 +17,8 @@ data class AuthorAttachmentViewModel(
override var nextDownStreamMessage: BaseViewModel<*>? = null, override var nextDownStreamMessage: BaseViewModel<*>? = null,
override var preview: Message? = null, override var preview: Message? = null,
override var isTemporary: Boolean = false, override var isTemporary: Boolean = false,
override var unread: Boolean? = null override var unread: Boolean? = null,
override var menuItemsToHide: MutableList<Int> = mutableListOf()
) : BaseAttachmentViewModel<AuthorAttachment> { ) : BaseAttachmentViewModel<AuthorAttachment> {
override val viewType: Int override val viewType: Int
get() = BaseViewModel.ViewType.AUTHOR_ATTACHMENT.viewType get() = BaseViewModel.ViewType.AUTHOR_ATTACHMENT.viewType
......
...@@ -14,6 +14,7 @@ interface BaseViewModel<out T> { ...@@ -14,6 +14,7 @@ interface BaseViewModel<out T> {
var preview: Message? var preview: Message?
var isTemporary: Boolean var isTemporary: Boolean
var unread: Boolean? var unread: Boolean?
var menuItemsToHide: MutableList<Int>
enum class ViewType(val viewType: Int) { enum class ViewType(val viewType: Int) {
MESSAGE(0), MESSAGE(0),
......
...@@ -16,7 +16,8 @@ data class ColorAttachmentViewModel( ...@@ -16,7 +16,8 @@ data class ColorAttachmentViewModel(
override var nextDownStreamMessage: BaseViewModel<*>? = null, override var nextDownStreamMessage: BaseViewModel<*>? = null,
override var preview: Message? = null, override var preview: Message? = null,
override var isTemporary: Boolean = false, override var isTemporary: Boolean = false,
override var unread: Boolean? = null override var unread: Boolean? = null,
override var menuItemsToHide: MutableList<Int> = mutableListOf()
) : BaseAttachmentViewModel<ColorAttachment> { ) : BaseAttachmentViewModel<ColorAttachment> {
override val viewType: Int override val viewType: Int
get() = BaseViewModel.ViewType.COLOR_ATTACHMENT.viewType get() = BaseViewModel.ViewType.COLOR_ATTACHMENT.viewType
......
...@@ -16,7 +16,8 @@ data class GenericFileAttachmentViewModel( ...@@ -16,7 +16,8 @@ data class GenericFileAttachmentViewModel(
override var nextDownStreamMessage: BaseViewModel<*>? = null, override var nextDownStreamMessage: BaseViewModel<*>? = null,
override var preview: Message? = null, override var preview: Message? = null,
override var isTemporary: Boolean = false, override var isTemporary: Boolean = false,
override var unread: Boolean? = null override var unread: Boolean? = null,
override var menuItemsToHide: MutableList<Int> = mutableListOf()
) : BaseFileAttachmentViewModel<GenericFileAttachment> { ) : BaseFileAttachmentViewModel<GenericFileAttachment> {
override val viewType: Int override val viewType: Int
get() = BaseViewModel.ViewType.GENERIC_FILE_ATTACHMENT.viewType get() = BaseViewModel.ViewType.GENERIC_FILE_ATTACHMENT.viewType
......
...@@ -15,7 +15,8 @@ data class ImageAttachmentViewModel( ...@@ -15,7 +15,8 @@ data class ImageAttachmentViewModel(
override var nextDownStreamMessage: BaseViewModel<*>? = null, override var nextDownStreamMessage: BaseViewModel<*>? = null,
override var preview: Message? = null, override var preview: Message? = null,
override var isTemporary: Boolean = false, override var isTemporary: Boolean = false,
override var unread: Boolean? = null override var unread: Boolean? = null,
override var menuItemsToHide: MutableList<Int> = mutableListOf()
) : BaseFileAttachmentViewModel<ImageAttachment> { ) : BaseFileAttachmentViewModel<ImageAttachment> {
override val viewType: Int override val viewType: Int
get() = BaseViewModel.ViewType.IMAGE_ATTACHMENT.viewType get() = BaseViewModel.ViewType.IMAGE_ATTACHMENT.viewType
......
...@@ -16,7 +16,8 @@ data class MessageAttachmentViewModel( ...@@ -16,7 +16,8 @@ data class MessageAttachmentViewModel(
var messageLink: String? = null, var messageLink: String? = null,
override var preview: Message? = null, override var preview: Message? = null,
override var isTemporary: Boolean = false, override var isTemporary: Boolean = false,
override var unread: Boolean? = null override var unread: Boolean? = null,
override var menuItemsToHide: MutableList<Int> = mutableListOf()
) : BaseViewModel<Message> { ) : BaseViewModel<Message> {
override val viewType: Int override val viewType: Int
get() = BaseViewModel.ViewType.MESSAGE_ATTACHMENT.viewType get() = BaseViewModel.ViewType.MESSAGE_ATTACHMENT.viewType
......
...@@ -12,7 +12,8 @@ data class MessageReplyViewModel( ...@@ -12,7 +12,8 @@ data class MessageReplyViewModel(
override var preview: Message?, override var preview: Message?,
override var isTemporary: Boolean = false, override var isTemporary: Boolean = false,
override val message: Message, override val message: Message,
override var unread: Boolean? = null override var unread: Boolean? = null,
override var menuItemsToHide: MutableList<Int> = mutableListOf()
) : BaseViewModel<MessageReply> { ) : BaseViewModel<MessageReply> {
override val viewType: Int override val viewType: Int
get() = BaseViewModel.ViewType.MESSAGE_REPLY.viewType get() = BaseViewModel.ViewType.MESSAGE_REPLY.viewType
......
...@@ -17,7 +17,8 @@ data class MessageViewModel( ...@@ -17,7 +17,8 @@ data class MessageViewModel(
override var preview: Message? = null, override var preview: Message? = null,
var isFirstUnread: Boolean, var isFirstUnread: Boolean,
override var isTemporary: Boolean = false, override var isTemporary: Boolean = false,
override var unread: Boolean? = null override var unread: Boolean? = null,
override var menuItemsToHide: MutableList<Int> = mutableListOf()
) : BaseMessageViewModel<Message> { ) : BaseMessageViewModel<Message> {
override val viewType: Int override val viewType: Int
get() = BaseViewModel.ViewType.MESSAGE.viewType get() = BaseViewModel.ViewType.MESSAGE.viewType
......
...@@ -16,7 +16,8 @@ data class UrlPreviewViewModel( ...@@ -16,7 +16,8 @@ data class UrlPreviewViewModel(
override var nextDownStreamMessage: BaseViewModel<*>? = null, override var nextDownStreamMessage: BaseViewModel<*>? = null,
override var preview: Message? = null, override var preview: Message? = null,
override var isTemporary: Boolean = false, override var isTemporary: Boolean = false,
override var unread: Boolean? = null override var unread: Boolean? = null,
override var menuItemsToHide: MutableList<Int> = mutableListOf()
) : BaseViewModel<Url> { ) : BaseViewModel<Url> {
override val viewType: Int override val viewType: Int
get() = BaseViewModel.ViewType.URL_PREVIEW.viewType get() = BaseViewModel.ViewType.URL_PREVIEW.viewType
......
...@@ -15,7 +15,8 @@ data class VideoAttachmentViewModel( ...@@ -15,7 +15,8 @@ data class VideoAttachmentViewModel(
override var nextDownStreamMessage: BaseViewModel<*>? = null, override var nextDownStreamMessage: BaseViewModel<*>? = null,
override var preview: Message? = null, override var preview: Message? = null,
override var isTemporary: Boolean = false, override var isTemporary: Boolean = false,
override var unread: Boolean? = null override var unread: Boolean? = null,
override var menuItemsToHide: MutableList<Int> = mutableListOf()
) : BaseFileAttachmentViewModel<VideoAttachment> { ) : BaseFileAttachmentViewModel<VideoAttachment> {
override val viewType: Int override val viewType: Int
get() = BaseViewModel.ViewType.VIDEO_ATTACHMENT.viewType get() = BaseViewModel.ViewType.VIDEO_ATTACHMENT.viewType
......
...@@ -20,13 +20,13 @@ import chat.rocket.android.helper.MessageParser ...@@ -20,13 +20,13 @@ import chat.rocket.android.helper.MessageParser
import chat.rocket.android.helper.UserHelper import chat.rocket.android.helper.UserHelper
import chat.rocket.android.infrastructure.LocalRepository import chat.rocket.android.infrastructure.LocalRepository
import chat.rocket.android.server.domain.ChatRoomsInteractor import chat.rocket.android.server.domain.ChatRoomsInteractor
import chat.rocket.android.server.domain.GetActiveUsersInteractor
import chat.rocket.android.server.domain.GetCurrentServerInteractor import chat.rocket.android.server.domain.GetCurrentServerInteractor
import chat.rocket.android.server.domain.GetSettingsInteractor import chat.rocket.android.server.domain.GetSettingsInteractor
import chat.rocket.android.server.domain.TokenRepository import chat.rocket.android.server.domain.TokenRepository
import chat.rocket.android.server.domain.UsersRepository import chat.rocket.android.server.domain.UsersRepository
import chat.rocket.android.server.domain.baseUrl import chat.rocket.android.server.domain.baseUrl
import chat.rocket.android.server.domain.messageReadReceiptEnabled import chat.rocket.android.server.domain.messageReadReceiptEnabled
import chat.rocket.android.server.domain.messageReadReceiptStoreUsers
import chat.rocket.android.server.domain.useRealName import chat.rocket.android.server.domain.useRealName
import chat.rocket.android.util.extensions.avatarUrl import chat.rocket.android.util.extensions.avatarUrl
import chat.rocket.android.util.extensions.isNotNullNorEmpty import chat.rocket.android.util.extensions.isNotNullNorEmpty
...@@ -141,6 +141,7 @@ class ViewModelMapper @Inject constructor( ...@@ -141,6 +141,7 @@ class ViewModelMapper @Inject constructor(
for (i in list.size - 1 downTo 0) { for (i in list.size - 1 downTo 0) {
val next = if (i - 1 < 0) null else list[i - 1] val next = if (i - 1 < 0) null else list[i - 1]
list[i].nextDownStreamMessage = next list[i].nextDownStreamMessage = next
mapVisibleActions(list[i])
} }
if (isBroadcastReplyAvailable(roomViewModel, message)) { if (isBroadcastReplyAvailable(roomViewModel, message)) {
...@@ -154,6 +155,12 @@ class ViewModelMapper @Inject constructor( ...@@ -154,6 +155,12 @@ class ViewModelMapper @Inject constructor(
return@withContext list return@withContext list
} }
private fun mapVisibleActions(viewModel: BaseViewModel<*>) {
if (!settings.messageReadReceiptStoreUsers()) {
viewModel.menuItemsToHide.add(R.id.action_message_info)
}
}
private suspend fun translateAsNotReversed( private suspend fun translateAsNotReversed(
message: Message, message: Message,
roomViewModel: RoomViewModel roomViewModel: RoomViewModel
......
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