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

Reply to messages

Members of a group or supergroup channel can reply to each others' messages in a thread using MessageThreadActivity or MessageThreadFragment. When a user taps Reply in thread in the Message menu of a user or file message in the group channel screen, the thread screen appears. In the new thread, users can start a separate conversation in response to the parent message.

Note : Threads is currently a beta feature that's still undergoing testing and development for improvement. Some inadvertent issues may arise while implementing this key function. If you encounter any bugs or if you have any helpful feedback, contact our support team.


Message thread screen

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

Message thread header

The message thread header component shows the title of the message thread screen, which says Thread by default. There's also a button on the left corner of the component, which when tapped, the finish() method of the activity is called to exit the current screen. Below the title, there’s a text button that indicates the name of the channel that the thread belongs to. When a user taps on the button, they can view the corresponding parent message in the group channel screen. The view of the thread header is created and customized in MessageThreadHeaderComponent of MessageThreadModule.

Thread list

The thread list component shows the parent message and a list of all its replies, both text and file messages, in a chronological order. Replies sent by the current user are differentiated from those sent by other channel members by the color and location of the message bubble. The view of the thread list is created and customized in ThreadListComponent of MessageThreadModule.

Message thread input

The message thread input component is where the user can send either a text or file message as a reply to the parent message in the thread. The placeholder text in the message input field changes depending on whether the parent message has an existing thread or not. If the parent message already has one or more thread replies, the default placeholder text is Reply to thread. If the parent message has no existing replies, the placeholder text is Reply in thread. The view of the message thread input is created and customized in MessageThreadInputComponent of MessageThreadModule.

Thread list status

The thread list status component shows the result of the data request for a thread list. The StatusComponent exists in MessageThreadModule and lets the user know if the list is loading or if the list couldn’t be called.


Usage

UIKit for Android provides both activity and fragment to create a message thread 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 message thread screen through MessageThreadActivity, which uses UIKitFragmentFactory to create views.

Start an activity

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

Intent intent = new MessageThreadActivity
                .IntentBuilder(context, "channel_url", parentMessage)
                .setStartingPoint(startingPoint)
                .build();
startActivity(intent);

Create a fragment

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

MessageThreadFragment fragment = new MessageThreadFragment.Builder("channel_url", parentMessage).build();

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


Customization

In the reply to messages key function, you can customize MessageThreadFragment to change different parts of the screen. The MessageThreadFragment.Builder class allows you to create and customize the basic MessageThreadFragment 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 MessageThreadFragment to display and customize the message thread screen.

FragmentModuleComponentStyleRecyclerView

MessageThreadFragment

MessageThreadModule

MessageThreadHeaderComponent

ThreadListComponent

MessageThreadInputComponent

StatusComponent

Module.MessageThread

ThreadListAdapter

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 message thread screen, you must use the correct classes.