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

Chat in an open channel

Copy link

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

Copy link

An open 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 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

Copy link

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

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

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 OpenChannelModule 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 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

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 OpenChannel, or find it on your Sendbird Dashboard. Begin a channel activity using intent which transitions you from the current activity to OpenChannelActivity as shown in the example below.

KotlinJava
val intent = OpenChannelActivity.newIntent(context, OpenChannelActivity::class.java, "channel_url")
startActivity(intent)

Create a fragment

Copy link

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.

KotlinJava
val fragment = 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

Copy link

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, see the Customizations overview page for further details.

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.