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 message input field region of the ChannelFragment
class.
In UIKit for Android, 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 Chat in a channel.
Customize the UI for file sharing
You can customize the UI for file sharing using StyleSet
and IconSet
.
StyleSet
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.
List of attributes of Widget.Sendbird.File
Attribute | Resource type | Description |
---|---|---|
sb_message_me_text_appearance | text appearance | The size, color, font, and style of text in file messages sent by the current user. |
sb_message_other_text_appearance | text appearance | The size, color, font, and style of text in file messages sent by remote users in the channel. |
sb_message_me_background | drawable/color | The shape and color of message bubbles containing a file sent by the current user. |
sb_message_other_background | drawable/color | The shape and color of message bubbles containing a file sent by others in the channel. |
sb_message_me_background_tint | color | The shape and tinted color of message bubbles containing a file sent by the current user. |
sb_message_other_background_tint | color | The shape and tinted color of message bubbles containing a file sent by the current user. |
IconSet
The following table shows customizable file sharing icons.
Icon name | Image | Description |
---|---|---|
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 | |
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
Method | Description |
---|---|
setUseImageCompression() | Determines whether to compress the image when sending an image file message. This method only applies to the following image types: |
shouldUseImageCompression() | Retrieves the set value of |
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 |
getResizingSize() | Retrieves the resized |
Note: To compress an image without changing the
width
andheight
, use thesetCompressQuality()
method. To resize thewidth
andheight
of an image, use thesetResizingSize()
method.