From dd5fd4c128dc95ff85aeb9c3af066edd216ad163 Mon Sep 17 00:00:00 2001 From: SpiritCroc Date: Tue, 26 Jan 2021 18:57:19 +0100 Subject: [PATCH] More longclick actions for stickers Allow - Reactions - Redactions - Replies Closes https://github.com/SchildiChat/SchildiChat-android/issues/57 Change-Id: I773cdcf84b2291494096debed38ba2342708290f --- .../im/vector/app/core/extensions/TimelineEvent.kt | 5 +++-- .../detail/timeline/action/MessageActionsViewModel.kt | 11 +++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/vector/src/main/java/im/vector/app/core/extensions/TimelineEvent.kt b/vector/src/main/java/im/vector/app/core/extensions/TimelineEvent.kt index 63e35c1c0f..dbef4c7ef8 100644 --- a/vector/src/main/java/im/vector/app/core/extensions/TimelineEvent.kt +++ b/vector/src/main/java/im/vector/app/core/extensions/TimelineEvent.kt @@ -21,6 +21,7 @@ import org.matrix.android.sdk.api.session.room.send.SendState import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent fun TimelineEvent.canReact(): Boolean { - // Only event of type Event.EVENT_TYPE_MESSAGE are supported for the moment - return root.getClearType() == EventType.MESSAGE && root.sendState == SendState.SYNCED && !root.isRedacted() + // Only event of type Event.EVENT_TYPE_MESSAGE and EventType.STICKER are supported for the moment + val clearType = root.getClearType() + return (clearType == EventType.MESSAGE || clearType == EventType.STICKER) && root.sendState == SendState.SYNCED && !root.isRedacted() } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/action/MessageActionsViewModel.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/action/MessageActionsViewModel.kt index b5d3102f46..4c495a0ba3 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/action/MessageActionsViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/action/MessageActionsViewModel.kt @@ -393,9 +393,11 @@ class MessageActionsViewModel @AssistedInject constructor(@Assisted } private fun canReply(event: TimelineEvent, messageContent: MessageContent?, actionPermissions: ActionPermissions): Boolean { - // Only event of type Event.EVENT_TYPE_MESSAGE are supported for the moment - if (event.root.getClearType() != EventType.MESSAGE) return false if (!actionPermissions.canSendMessage) return false + // Only event of type Event.EVENT_TYPE_MESSAGE and EventType.STICKER are supported for the moment + val clearType = event.root.getClearType() + if (clearType == EventType.STICKER) return true + if (clearType != EventType.MESSAGE) return false return when (messageContent?.msgType) { MessageType.MSGTYPE_TEXT, MessageType.MSGTYPE_NOTICE, @@ -424,8 +426,9 @@ class MessageActionsViewModel @AssistedInject constructor(@Assisted } private fun canRedact(event: TimelineEvent, actionPermissions: ActionPermissions): Boolean { - // Only event of type Event.EVENT_TYPE_MESSAGE are supported for the moment - if (event.root.getClearType() != EventType.MESSAGE) return false + // Only event of type Event.EVENT_TYPE_MESSAGE and EventType.STICKER are supported for the moment + val clearType = event.root.getClearType() + if (clearType != EventType.MESSAGE && clearType != EventType.STICKER) return false // Message sent by the current user can always be redacted if (event.root.senderId == session.myUserId) return true // Check permission for messages sent by other users