TUIKit API (Android)

Last updated: 2020-03-12 15:32:38

PDF

ConversationLayout

ConversationLayout consists of TitleBarLayout and ConversationListLayout. Each component provides UI styles and event registration APIs for customization.

API Description
getConversationList Obtains the conversation list.
setConversationTop Pins a conversation on top.
deleteConversation Deletes a conversation.

ChatLayout

ChatLayout provides features such as message display and sending. Its user interface consists of the following four components, listed from the top down, and each component provides various methods to meet customization requirements.

  • TitleBarLayout
  • NoticeLayout
  • MessageLayout
  • InputLayout
API Description
getInputLayout Obtains the layout of the input area (InputLayout).
getMessageLayout Obtains the layout of the message area (MessageLayout).
getNoticeLayout Obtains the layout of the message area in the chat window (NoticeLayout).
setChatInfo Sets the current conversation ID, based on which the conversation panel loads relevant information required for the conversation, such as message records and user (group) information.
exitChat Quits a chat and releases relevant resources (this API is often invoked when an activity is finished.)
initDefault Initializes parameters.
loadMessages Loads chat messages.
sendMessage Sends messages.

NoticeLayout

NoticeLayout has a fixed position and is either displayed or hidden. When you scroll through chat content, its position remains unchanged. NoticeLayout can display group messages or broadcasts to be processed. Its layout is divided into two parts, which can be used to display the content topic and the auxiliary topic, respectively. You can set click events to respond to user operations.

API Description
getContent Obtains the topic information of a notice.
getContentExtra Obtains the further operations of a notice.
setOnNoticeClickListener Sets click events for a notice.
alwaysShow Sets whether NoticeLayout is constantly displayed.

MessageLayout

MessageLayout is inherited from RecyclerView and displays messages. It provides many methods to meet customization requirements, such as appearance settings, click events, and custom message display.

Setting the profile photo

API Description
setAvatar Sets the default profile photo. By default, profile photos on the left and right are the same.
getAvatar Obtains the default profile photo.
setAvatarRadius Sets the border-radius of the profile photo.
getAvatarRadius Obtains the border-radius of the profile photo.
setAvatarSize Sets the profile photo size.
getAvatarSize Obtains the profile photo size.

Setting the nickname style

API Description
setNameFontSize Sets the nickname font size.
getNameFontSize Obtains the nickname font size.
setNameFontColor Sets the nickname font color.
getNameFontColor Obtains the nickname font color.
setLeftNameVisibility Sets whether to display the left nickname.
getLeftNameVisibility Obtains the display status of the left nickname.
setRightNameVisibility Sets whether to display the right nickname.
getRightNameVisibility Obtains the display status of the right nickname.

Setting bubbles

API Description
setRightBubble Sets the background of the right chat bubble.
getRightBubble Obtains the background of the right chat bubble.
setLeftBubble Sets the background of the left chat bubble.
getLeftBubble Obtains the background of the left chat bubble.

Setting chat content

API Description
setChatContextFontSize Sets the font size of chat content.
getChatContextFontSize Obtains the font size of chat content.
setRightChatContentFontColor Sets the font color of right chat content.
getRightChatContentFontColor Obtains the font color of right chat content.
getLeftChatContentFontColor Obtains the font color of left chat content.
setLeftChatContentFontColor Sets the font color of left chat content.

Setting the chat time

API Description
setChatTimeBubble Sets the background for the chat time.
getChatTimeBubble Obtains the background for the chat time.
setChatTimeFontSize Sets the font size of the chat time.
getChatTimeFontSize Obtains the font size of the chat time.
setChatTimeFontColor Sets the font color of the chat time.
getChatTimeFontColor Obtains the font color of the chat time.

Setting chat prompts

API Description
setTipsMessageBubble Sets the background of chat prompts.
getTipsMessageBubble Obtains the background of chat prompts.
setTipsMessageFontSize Sets the font size of chat prompts.
getTipsMessageFontSize Obtains the font size of chat prompts.
setTipsMessageFontColor Sets the font color of chat prompts.
getTipsMessageFontColor Obtains the font color of chat prompts.

Setting other information

API Description
setAdapter Sets the message list adapter (MessageListAdapter).
setOnItemClickListener Sets the event listener for the message list (MessageLayout.OnItemClickListener).
getOnItemClickListener Obtains click events for the message list.
getPopActions Obtains the PopMenu action list.
addPopAction Adds a custom action to PopMenu.
setOnCustomMessageDrawListener Sets the callback for custom messages during rendering. When TUIKit refreshes a custom message, it invokes this callback.

InputLayout

InputLayout enables the input of common messages, including text, emojis, images, audio, videos, and files. In conjunction with MessageLayout.setOnCustomMessageDrawListener, it can send and display custom messages. In addition, you can hide, replace, or add InputLayout feature entries based on your actual business requirements.

API Description
disableAudioInput Hides the button after audio input is disabled.
disableEmojiInput Hides the button after emoji input is disabled.
disableMoreInput Hides the button after the More feature is disabled.
replaceMoreInput Replaces the panel that appears after you click "+".
replaceMoreInput Replaces the response event after you click "+".
disableSendPhotoAction Hides the button on the More panel after image sending is disabled.
disableCaptureAction Hides the button on the More panel after photo taking is disabled.
disableVideoRecordAction Hides the button on the More panel after video recording is disabled.
disableSendFileAction Hides the button on the More panel after file sending is disabled.
addAction Adds an event unit on the More panel.

TitleBarLayout

ConversationLayout, ChatLayout, and other areas all have a title bar. The title bar is divided into the left, middle, and right parts. Images and text are allowed in the left and right parts, whereas only text is allowed in the middle part. These parts return standard Android views. You can interact with these views based on your actual business requirements.

API Description
setLeftIcon Sets the icon of the left title.
setRightIcon Sets the icon of the right title.
setOnLeftClickListener Sets the click event for the left title.
setOnRightClickListener Sets the click event for the right title.
setTitle Sets the text title. The position parameter specifies the text position.
getLeftGroup Returns the left title section.
getRightGroup Returns the right title section.
getLeftIcon Returns the icon of the left title.
getRightIcon Returns the icon of the right title.
getLeftTitle Returns the text of the left title.
getMiddleTitle Returns the text of the middle title.
getRightTitle Returns the text of the right title.