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

Chat in an open channel

An open channel is a public chat that allows a massive number of users to interact with one another in a more dynamic environment. Open channels can accommodate up to 1,000 simultaneous users and don’t require an invitation for users to enter.


Open channel screen

An open 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 open channel screen, which is the open channel name. It also has two buttons on the left and 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 open channel settings screen appears for operators and the participant list screen appears for channel participants. The view of the channel header is created and customized in the OpenChannelHeaderComponent of the OpenChannelModule.

Message list

The message list component shows a list of all messages exchanged in the open 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 participants. The view of the message list is created and customized in the OpenChannelMessageListComponent of the OpenChannelModule. You can also customize each item in the list view using OpenChannelMessageListAdapter.

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 OpenChannelMessageInputComponent of the OpenChannelModule.

Message list status

The message list status component shows the result of the data request for a message list. The StatusComponent exists in the OpenChannelModule 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 an open 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 an open channel screen through OpenChannelActivity, which uses UIKitFragmentFactory to create views.

Start an activity

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

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

Create a fragment

OpenChannelActivity allows you to create a basic OpenChannelFragment through UIKitFragmentFactory and OpenChannelFragment.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 OpenChannelFragment. To see all APIs of OpenChannelFragment.Builder, refer to the API reference page.

OpenChannelFragment fragment = new OpenChannelFragment.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 open channel key function, you can customize OpenChannelFragment to change different aspects of the screen. The OpenChannelFragment.Builder class allows you to create and customize the basic OpenChannelFragment 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 OpenChannelFragment to display and customize the open channel screen.

FragmentModuleComponentStyleRecyclerView

OpenChannelFragment

OpenChannelModule

OpenChannelHeaderComponent

OpenMessageListComponent

OpenMessageInputComponent

StatusComponent

Module.OpenChannel

OpenChannelMessageListAdapter

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:

Note: The links to the above customization pages provide an example of how to customize classes related to ChannelFragment. In order to make changes to the open channel, you must use the correct classes.