More longclick actions for stickers

Allow
- Reactions
- Redactions
- Replies

Closes https://github.com/SchildiChat/SchildiChat-android/issues/57

Change-Id: I773cdcf84b2291494096debed38ba2342708290f
This commit is contained in:
SpiritCroc 2021-01-26 18:57:19 +01:00
parent 221be6947d
commit dd5fd4c128
2 changed files with 10 additions and 6 deletions

View File

@ -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()
}

View File

@ -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