This page explains the key functions of fly recent chat in MirrorFly UIKit for Android.
A Fly Recent chat is the complete list of recent chats that you're made with single conversation. The recent chat list is displayed once a connection with Mirrorfly server is established, and can be easily managed without complex implementation because the FlyRecentChatActivity or FlyRecentChatFragment class handles core features such as chat pagination and real-time updates.
Use the intent to move from one activity to the FlyRecentChatActivity as follows:
If you want to customize the recent chat activity, use CustomFlyRecentChatActivity as follows:
UIKit’s FlyRecentChatFragment class extends the
class and is designed to take up the whole screen of the activity. It is recommended to create this fragment in the onCreate() method of the user-generated activity. By default, the header of the flyrecentchat view isn’t visible when using the FlyRecentChatFragment.
UIKit provides methods that can be overridden so that you can customize your UI.
|createFlyRecentChatFragment()||FlyRecentChatFragment||Called when the FlyRecentChatActivity is created.|
The FlyRecentChatFragment class enables you to customize the UI of your fly recenct chat view. As shown below, the fragment class is composed of two regions: the header and recent chat.
Recent chat view
|Header||Acts as an optional ActionBar in the fly recent chat activity. By default, it displays the title and two buttons on the left and right, which are all customizable. If the left button is clicked, the finish() method of the activity will be called to close the current activity. If the right button is clicked, the user can determine which chat type to select. After the user selects a chat type, the user will be taken to ContactActivity.|
|Fly Recent chat||Displays the chat's cover image, chat name, number of unread messages, last message sent. If a chat is clicked, the user will be taken to the corresponding FlyChatActivity. It is fully customizable.|
The FlyRecentChatFragment.Builder class provides APIs that enable you to create a customized FlyRecentChatFragment. Before building, the FlyRecentChatFragment’s settings can be customized using the builder’s setters. The following is an example of how to build the FlyRecentChatFragment:
|setCustomFlyRecentChatFragment()||Applies CustomFlyRecentChatFragment to FlyRecentChatFragment. By inheritance, CustomFlyRecentChatFragment should be a subclass of FlyRecentChatFragment.|
|setUserHeader()||Determines whether the header is used. (Default: calls from an activity: true, calls from a fragment: false)|
|setHeaderTitle()||Specifies the title of the header. (Default: Chats)|
|setUseHeaderLeftButton()||Determines whether the left button of the header is used. (Default: true)|
|setUseHeaderRightButton()||Determines whether the right button of the header is used. (Default: true)|
|setHeaderLeftButtonIconResId()||Specifies the icon on the left button of the header. (Default: icon_arrow_left)|
|setHeaderLeftButtonIcon()||Specifies the icon and the tint on the left button of the header. (Default: icon_arrow_left, light mode : primary_300, dark mode : primary_200)|
|setHeaderRightButtonIconResId()||Specifies the icon on the right button of the header. (Default: icon_create)|
|setHeaderRightButtonIcon()||Specifies the icon and the tint on the right button of the header. (Default: icon_create, light mode : primary_300, dark mode : primary_200)|
|setHeaderLeftButtonListener()||Specifies the action of the click listener on the left button of the header. (Default: finish the current activity)|
|setHeaderRightButtonListener()||Specifies the action of the click listener on the right button of the header. (Default: start the ContactActivity)|
|setItemClickListener()||Specifies the action of the click listener on an item of the chat list. (Default: start the FlyChatActivity)|
You can customize the methods in the FlyRecentChatFragment class as follows:
- Create a new fragment which inherits FlyRecentChatFragment as a subclass.
- Override the methods in the fragment. The following table lists the methods you can use.
- Apply the customized fragment by using the FlyRecentChatFragment.Builder().setCustomFlyRecentChatFragment() method.
Click listeners can be added to fly recent chat items to perform specific actions when clicked. Through the listeners, the Chat instance is passed as an argument to a parameter, which includes the chat information of the clicked chat. Based on this information, click listeners can be added to perform specific actions.
Create a User defined Activity (MFUICustomTestActivity) in the newly created project and implement the fragment function as follows:
To customize the style of fly recent chat items, create style_custom.xml inside the res/values folder and add the value as follows:. The table below shows the style of fly recent chat items you can customize. You need to keep the original names of the items and parents defined by the UIKit during the process.
Note : If already style_custom.xml added skip to themes.
Add the CustomRecentChatListFragment style in the theme.xml to customize the fly recent chat.