Chat UIKit Android View v3
Chat UIKit Android View
Chat UIKit
Android View
Version 3

Chat in a group channel

Copy link

A group channel is a chat that allows close interactions between a limited number of users. In order to join this type of channel, an invitation from a channel member is required by default. Users can create 1-to-1 group channels or 1-to-N group channels and there's also a supergroup channel, which is an expanded version of a group channel that can accommodate more than 2,000 members in one channel.


Group channel screen

Copy link

A group channel screen is composed of four components: header, message list, message input, and message list status.

Header

Copy link

The header component shows the title of the group channel screen, which is either the group channel name or the name of another user in a 1-to-1 chat channel. It also has two buttons, one on the left and the other on the right corner of the component. When the left button is tapped, the finish() method of the activity is called to exit the current screen. When the right button is tapped, the group channel settings screen appears. The view of the channel header is created and customized in the ChannelHeaderComponent of the ChannelModule.

Message list

Copy link

The message list component shows a list of all messages exchanged in the group channel in a chronological order. The list shows both text and file messages and messages sent by the current user are differentiated from those sent by other channel members. The view of the message list is created and customized in the MessageListComponent of the ChannelModule. You can also customize each item in the list view using MessageListAdapter.

Message input

Copy link

The message input component is where the user can either enter a text message or send a file message by importing a file, image or video. The view of the message input is created and customized in the MessageInputComponent of the ChannelModule.

Message list status

Copy link

The message list status component shows the result of the data request for a message list. The StatusComponent exists in the ChannelModule and lets the user know if the list is loading or if the list could not be called.


UIKit for Android provides both activity and fragment to create a group channel screen. You can choose which one to build your app with and you may solely use activity instead of fragment if you wish to. You can build a group channel screen through ChannelActivity, which uses UIKitFragmentFactory to create views.

Start a channel activity

Copy link

To enter the chat screen, a channel_url is required as a unique identifier for the channel. You can find this URL from the url property of the GroupChannel, or find it on your Sendbird Dashboard. Begin a channel activity using intent which transitions you from the current activity to ChannelActivity as shown in the example below.

KotlinJava
val intent = ChannelActivity.newIntent(context, "channel_url")
startActivity(intent)

Create a fragment

Copy link

ChannelActivity allows you to create a basic ChannelFragment through UIKitFragmentFactory and ChannelFragment.Builder. UIKitFragmentFactory has a set of methods that build each fragment, whereas the builder class provides APIs to customize the UI of the data and event handlers used in ChannelFragment. To see all APIs of ChannelFragment.Builder, refer to the API reference page.

KotlinJava
val fragment = ChannelFragment.Builder("channel_url").build()

Note: To use UIKit's fragments as a nested fragment, refer to the Android Developer Documentation's Nested Fragments.


Customization

Copy link

In the group channel key function, you can customize ChannelFragment to change different aspects of the screen. The ChannelFragment.Builder class allows you to create and customize the basic ChannelFragment that UIKit provides but you can only change its own APIs, such as setting a layout. If you wish to customize the fragment beyond using the APIs provided in the builder, you must inherit new customization methods.

The following table shows the main classes used in ChannelFragment to display and customize the group channel screen.

FragmentModuleComponentStyleRecyclerView

ChannelFragment

ChannelModule

ChannelHeaderComponent

MessageListComponent

MessageInputComponent

StatusComponent

Module.Channel

MessageListAdapter

Depending on the UI or the feature you wish to customize in the fragment, you can change the classes mentioned in the table. To learn how to customize the fragment, see the Customizations overview page for further details.