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.

Chat in a group channel

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

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

Header

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

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

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

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.


Usage

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 an activity

You can start an activity by using intent to move from one activity to ChannelActivity as shown below:

Intent intent = ChannelActivity.newIntent(context, "channel_url");
startActivity(intent);

Create a fragment

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.

ChannelFragment fragment = new 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

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, follow the links to Customization listed below: