Recent Chats
#
Build the fragmentThe 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
- Chat Type
#
Fragment regionsRegion | Description |
---|---|
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. |
#
Set the fragment.builder()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
:
#
List of setter methodsSetter method | Description |
---|---|
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) |
#
Customize the fly recent chatCreate a User defined Activity (MFUICustomTestActivity)
in the newly created project and implement the fragment function as follows:
#
MFUICustomTestActivity layout xml file as follows :#
Customize the style of the fly recent chatTo 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.
#
Theme - Apply custom style for Recent ChatCreate a style called CustomChatListStyle
in the themes.xml
to customize the flyrecentchat. Override only the required widgets and customize their styles.
Example
Widgets :Widget.MirrorFly.AppBar
Attribute :android:background
rest of the widgets provides the default Ui.
Note : To apply the declared custom styles, pass the
R.style.CustomChatListStyle
to theFlyRecentChatFragment.Builder
constructor as follows: