UIKit Android v3
UIKit Android
UIKit
Android
Home
/
UIKit
/
Android
This is the new Docs for UIKit v3 beta for Android. To see the previous Docs, click here.

File sharing

File sharing is a feature that allows users to send files during a chat, such as images, audio files, and videos. File sharing appears in the MessageListComponent of the ChannelModule or OpenChannelModule.


Group channel

There are currently four types of file messages that users can send: image file, video file, audio file, and document file. These files can be shared with other members in the channel by either directly taking a photo with the camera on a mobile device or uploading an image, video, audio, or document file from the sender’s mobile device.

Note : In order to use the file sharing feature, you must first create a channel and enable the chat service. To learn how to allow users to chat in a channel, refer to the Chat in a group channel page.

Customize the UI for file sharing

You can customize the UI for file sharing using style resource and icon resource.

Style resource

To customize the style of channel items, you have to change the UIKit-defined style values in the res/values/styles.xml file as shown below. To learn how to customize the style, refer to Style resource.

<style name="Widget.Sendbird.Message.Me.File">
</style>
<style name="Widget.Sendbird.Message.Other.File">
</style>

Icon resource

The following table shows customizable file sharing icons.

Icon nameImageDescription

icon_add

An icon used to select and add files.

icon_document

An icon used to select a file to send.

icon_file_audio

An icon indicating an audio file message.

icon_file_document

An icon indicating a document file message.

icon_gif

An icon indicating a GIF, the Graphics Interchange Format, file message.

icon_play

An icon indicating a video file message.

Image compression

UIKit for Android allows users to compress images when sending them to other users in the channel on a client app. By reducing the image size, they can send and receive image files faster and minimize the usage of data storage as well as the data usage. Image compression can be applied to the following image types: jpg, jpeg, and png.

The following table lists methods in the SendbirdUIKit instance that are related to image compression.

List of methods

MethodDescription

setUseImageCompression()

Determines whether to compress the image when sending an image file message. This method only applies to the following image types: image/jpg, image/jpeg, and image/png. (Default: false)

shouldUseImageCompression()

Retrieves the set value of setUseImageCompression() on whether the image should be compressed when sending it as an image file message.

setCompressQuality()

Sets the value of the compression rate to apply to the image. Acceptable values are 0 to 100, inclusive. (Default: 100)

getCompressQuality()

Retrieves the set value of the compression rate to apply to the image.

setResizingSize()

Sets the new width and height to apply to the image. The given value is shown in the order of the width first, then the height. (Default: 1080x1920)

* When displaying the compressed image as a thumbnail, the value of the new width and height will be halved. The minimum value for the compressed thumbnail is 100x100.

getResizingSize()

Retrieves the resized width and height to apply to the image.

// To determine whether to compress an image
SendbirdUIKit.setUseImageCompression(true);
boolean useImageCompression = SendbirdUIKit.shouldUseImageCompression();

// To set a compression rate value
SendbirdUIKit.setCompressQuality(50);
int compressQuality = SendbirdUIKit.getCompressQuality();

// To resize an image
SendbirdUIKit.setResizingSize(new Pair<>(1080, 1920));
Pair<Integer, Integer> resizingSize = SendbirdUIKit.getResizingSize();

Note: To compress an image without changing the width and height, use the setCompressQuality() method. To resize the width and height of an image, use the setResizingSize() method.


Open channel

There are currently four types of file messages that users can send: image file, video file, audio file, and document file. These files can be shared with other participants in the channel by either directly taking a photo with the camera on a mobile device or uploading an image, video, audio, or document file from the sender’s mobile device.

Note : In order to use the file sharing feature, you must first create a channel and enable chat service. To learn how to allow users to chat in a channel, refer to Chat in open channel.

Customize the UI for file sharing

You can customize the UI for file sharing using Style resource and Icon resource.

Style resource

To customize the style of channel items, you have to change the UIKit-defined style values in the res/values/styles.xml file as shown below. To learn how to customize the style, refer to Style resource.

<style name="Widget.Sendbird.OpenChannel.Message.File">
</style>

Icon resource

The following table shows customizable file sharing icons.

Icon nameImageDescription

icon_add

An icon used to select and add files.

icon_document

An icon used to select a file to send.

icon_file_audio

An icon indicating an audio file message.

icon_file_document

An icon indicating a document file message.

icon_gif

An icon indicating a GIF, the Graphics Interchange Format, file message.

icon_play

An icon indicating a video file message.

Image compression

UIKit for Android allows users to compress images when sending them to other users in the channel on a client app. By reducing the image size, they can send and receive image files faster and minimize the usage of data storage as well as the data usage. Image compression can be applied to the following image types: jpg, jpeg, and png.

The following table lists methods in the SendbirdUIKit instance that are related to image compression.

List of methods

MethodDescription

setUseImageCompression()

Determines whether to compress the image when sending an image file message. This method only applies to the following image types: image/jpg, image/jpeg, and image/png. (Default: false)

shouldUseImageCompression()

Retrieves the set value of setUseImageCompression() on whether the image should be compressed when sending it as an image file message.

setCompressQuality()

Sets the value of the compression rate to apply to the image. Acceptable values are 0 to 100, inclusive. (Default: 100)

getCompressQuality()

Retrieves the set value of the compression rate to apply to the image.

setResizingSize()

Sets the new width and height to apply to the image. The given value is shown in the order of the width first, then the height. (Default: 1080x1920)

* When displaying the compressed image as a thumbnail, the value of the new width and height will be halved. The minimum value for the compressed thumbnail is 100x100.

getResizingSize()

Retrieves the resized width and height to apply to the image.

// To determine whether to compress an image
SendbirdUIKit.setUseImageCompression(true);
boolean useImageCompression = SendbirdUIKit.shouldUseImageCompression();

// To set a compression rate value
SendbirdUIKit.setCompressQuality(50);
int compressQuality = SendbirdUIKit.getCompressQuality();

// To resize an image
SendbirdUIKit.setResizingSize(new Pair<>(1080, 1920));
Pair<Integer, Integer> resizingSize = SendbirdUIKit.getResizingSize();

Note: To compress an image without changing the width and height, use the setCompressQuality() method. To resize the width and height of an image, use the setResizingSize() method.