Skip to main content

Attachment Gallery#

AttachmentGalleryActivity is an Activity used to display attachments that the users have sent in the chat. It is an image gallery where users can view, share, and download the pictures, and use a menu to easily navigate through them.

Light ModeDark Mode

Handling Actions#

There are four user actions that can be customized by the following handlers:

  • AttachmentReplyOptionHandler
  • AttachmentShowInChatOptionHandler
  • AttachmentDownloadOptionHandler
  • AttachmentDeleteOptionHandler

These are called when the user selects one of the options from the overflow menu in the top right:


As the gallery is usually opened from MessageListView, you can set these handlers on that View the following way:

messageListView.setAttachmentReplyOptionClickHandler { resultItem ->
// Handle reply to attachment

messageListView.setAttachmentShowInChatOptionClickHandler { resultItem ->
// Handle show in chat

messageListView.setDownloadOptionHandler { resultItem ->
// Handle download the attachment

messageListView.setAttachmentDeleteOptionClickHandler { resultItem ->
// Handle delete

Navigating To Attachment Gallery#

By default, the Attachment Gallery is opened when a user clicks on an attachment in MessageListView. In that case, all actions mentioned above have a default implementation, which can be changed by overriding MessageListView's handlers.

You can also navigate to AttachmentGalleryActivity manually from anywhere else in your code. In this case, you will need to implement all available actions:

// Create Attachment Gallery Destination
val destination = AttachmentGalleryDestination(
attachmentReplyOptionHandler = { resultItem ->
// Handle reply
attachmentShowInChatOptionHandler = { resultItem ->
// Handle show image in chat
attachmentDownloadOptionHandler = { resultItem ->
// Handle download image
attachmentDeleteOptionClickHandler = { resultItem ->
// Handle delete image

// Register destination with the ActivityResultRegistry
activity?.activityResultRegistry?.let { registry ->

// Set the data to display
destination.setData(attachmentGalleryItems = listOf(), attachmentIndex = 0)

// Fire the navigation request

Did you find this page helpful?