Skip to main content
Version: v4

Message Information

The MessageInformation is a Component designed to display message-related information, such as delivery and read receipts. It serves as an integral part of the CometChat UI UI Kit, extending the ListBase class, which provides the underlying infrastructure for CometChat UI components. With its rich set of methods and properties, developers can easily customize and tailor the appearance and behavior of the message information view to suit the specific requirements of their application.

Image

MessageInformation is comprised of the following Base Components:

Base ComponentsDescription
List BaseThis renders common components used across Conversations, Groups & Users.

Usage

Integration

The following code snippet illustrates how you can directly incorporate the MessageComposer component into your layout.xml file.

<com.cometchat.chatuikit.messageinformation.CometChatMessageInformation
android:id="@+id/cometchat_message_information"
android:layout_width="match_parent"
android:layout_height="match_parent" />

Actions

Actions dictate how a component functions. They are divided into two types: Predefined and User-defined. You can override either type, allowing you to tailor the behavior of the component to fit your specific needs.

1. OnBackPress

The OnSendButtonClick event is typically triggered when the back button is pressed and it carries a default action. However, with the following code snippet, you can effortlessly override this default operation.

cometChatMessageInformation.addOnBackPressListener(new CometChatListBase.OnBackPress() {
@Override
public void onBack() {
// Your BackPress action
}
});
2. onError

This action doesn't change the behavior of the component but rather listens for any errors that occur in the MessageList component.

cometChatMessageInformation.setError(new OnError() {
@Override
public void onError(Context context, CometChatException e) {
// your error handling logic
}
});

Filters

MessageInformation component does not have any available filters.


Events

MessageInformation component does not have any available events.


Customization

To fit your app's design requirements, you can customize the appearance of the MessageInformation component. We provide exposed methods that allow you to modify the experience and behavior according to your specific needs.

Style

Using Style you can customize the look and feel of the component in your app, These parameters typically control elements such as the color, size, shape, and fonts used within the component.

1. MessageInformation Style

To modify the styling, you can apply the MessageInformationStyle to the MessageInformation Component using the setStyle method.

MessageInformationStyle style = new MessageInformationStyle();
cometChatMessageInformation.setStyle(style);

The following properties are exposed by MessageInformationStyle:

PropertyDescriptionCode
SubtitleText ColorSets the text color for the subtitlesetSubtitleTextColor(@ColorInt int)
SubtitleText AppearanceSets the text appearance for the subtitlesetSubtitleTextAppearance(@StyleRes int)
Title FontSets the font for the titlesetSubtitleTextAppearance(@StyleRes int)
EmptyText FontSets the font for the empty state textsetEmptyTextFont(String emptyTextFont)
EmptyText AppearanceSets the text appearance for the empty state textsetEmptyTextAppearance(@StyleRes int )
ErrorText AppearanceSets the text appearance for the error state textsetErrorTextAppearance(@StyleRes int )
ErrorText AppearanceSets the text appearance for the error state textsetErrorTextAppearance(@StyleRes int )
ErrorText AppearanceSets the text appearance for the error state textsetErrorTextAppearance(@StyleRes int )
Title ColorSets the text color for the titlesetTitleColor(@ColorInt int)
BackIcon TintSets the tint color for the back iconsetBackIconTint(@ColorInt int)
OnlineStatus ColorSets the text color for the online statussetOnlineStatusColor(int onlineStatusColor)
Separator ColorSets the color for the separatorsetSeparatorColor(@ColorInt int)
LoadingIcon TintSets the tint color for the loading iconsetLoadingIconTint(@ColorInt int)
EmptyText ColorSets the text color for the empty state textsetEmptyTextColor(@ColorInt int
MessageTitle AppearanceSets the text appearance for the message titlesetMessageTitleAppearance(@StyleRes int)
MessageInformationTitle AppearanceSets the text appearance for the message information titlesetMessageInformationTitleAppearance(@StyleRes int)
MessageText ColorSets the text color for the message textsetMessageTextColor(@ColorInt int)
MessageInfoText ColorSets the text color for the message info textsetMessageInfoTextColor(@ColorInt int)
Background ColorSets the background colorsetBackground(@ColorInt int)
Background DrawableSets the drawable backgroundsetBackground(Drawable)
Corner RadiusSets the corner radiussetCornerRadius(float cornerRadius)
Border WidthSets the width of the bordersetBorderWidth(int borderWidth)
Border ColorSets the color of the bordersetBorderColor(int borderColor)

2. ListItem Style

To apply customized styles to the ListItemStyle component in the MessageInformation Component, you can use the following code snippet. For more information, visit List Item Styles.

ListItemStyle listItemStyle = new ListItemStyle();
listItemStyle.setTitleColor(Color.BLACK);
cometChatMessageInformation.setListItemStyle(listItemStyle);

3. Avatar Style

To apply customized styles to the Avatar component in the MessageInformation Component, you can use the following code snippet. For more information, visit Avatar.

AvatarStyle avatarStyle = new AvatarStyle();
avatarStyle.setBorderWidth(10);
avatarStyle.setBorderColor(Color.BLACK);
cometChatMessageInformation.setAvatarStyle(avatarStyle);

4. MessageBubble Style

To apply customized styles to the MessageBubble component in the MessageInformation Component, you can use the following code snippet. For further insights on MessageBubble Styles refer

MessageBubbleStyle style = new MessageBubbleStyle();
style.setBackground(Color.BLACK);
style.setCornerRadius(2.5f);
cometChatMessageInformation.setMessageBubbleStyle(style);

Functionality

These are a set of small functional customizations that allow you to fine-tune the overall experience of the component. With these, you can change text, set custom icons, and toggle the visibility of UI elements.

    cometChatMessageInformation.setTitle("Your Title");
cometChatMessageInformation.setSearchText("Your search Title");
cometChatMessageInformation.setReadIcon(R.drawable.ic_read);

Below is a list of customizations along with corresponding code snippets

PropertyDescriptionCode
-----------------------
Set MessageSets the message to be displayed in the message information view.setMessage(BaseMessage message)
ErrorView VisibilitySets the message to be displayed in the message information view.setMessage(BaseMessage message)

How to integrate CometChatMesssageInformation ?

Since CometChatMesssageInformation is a Widget, it can be added directly to the layout file as shown below.

<com.cometchat.chatuikit.messageinformation.CometChatMessageInformation
android:id="@+id/cometchat_message_information"
android:layout_width="match_parent"
android:layout_height="match_parent" />
CometChatMessageInformation messageInformation = findViewById(R.id.cometchat_message_information);
messageInformation.setMessage(baseMessage);
messageInformation.setTemplate(messageTemplate);

Methods

MethodsParametersDescription
setTemplate(CometChatMessageTemplate template)CometChatMessageTemplateSets a custom message template for the message information view.
setMessage(BaseMessage message)BaseMessageSets the message to be displayed in the message information view.
setErrorViewVisibility(int visibility)intSets the visibility of the error view in the message information view.
setTitle(String title)StringSets the title that will be displayed at the top of the CometChatContacts view. This method allows you to customize the title to provide relevant information or context to the users.
setListItemView(Function3<Context, BaseMessage, MessageReceipt, View> listItemView)Function3<Context, BaseMessage, MessageReceipt, View>Sets a custom list item view for individual entries in the message information view.
public void setSubtitleView(Function3<Context, BaseMessage, MessageReceipt, View> subtitleView)Function3<Context, BaseMessage, MessageReceipt, View>Sets a custom subtitle view for individual entries in the message information view.
setReceiptDatePattern(Function1<MessageReceipt, String> datePattern)Function1<MessageReceipt, String>Sets a custom date pattern for formatting receipt dates in the message information view.
setStyle(MessageInformationStyle style)MessageInformationStyleSets the overall style and appearance for the message information view.
setReadIcon(@DrawableRes int readIcon)@DrawableRes intSets the custom icon resource for read receipts in the message information view.
setDeliveredIcon(@DrawableRes int deliverIcon)@DrawableRes intSets the custom icon resource for delivered receipts in the message information view.
setListItemStyle(ListItemStyle listItemStyle)ListItemStyleSets the style for list items in the message information view.
setAvatarStyle(AvatarStyle avatarStyle)AvatarStyleSets the style for avatars in the message information view.
setError(OnError onError)OnErrorSets the error callback to handle any errors that may occur within the message information view.
emptyStateText(String message)StringSets the text to be displayed in the empty state view of the message information view.
errorStateText(String errorText)StringSets the error message to be displayed in the error state view of the message information view.
setEmptyStateView(@LayoutRes int id)@LayoutRes intSets the custom layout resource for the empty state view of the message information view.
setErrorStateView(@LayoutRes int id)@LayoutRes intSets the custom layout resource for the error state view of the message information view.
setLoadingStateView(@LayoutRes int id)@LayoutRes intSets the custom layout resource for the loading state view of the message information view.
setBubbleView(Function2<Context, BaseMessage, View> bubbleView)Function2<Context, BaseMessage, View>This method allows you to set a custom bubble view in the message information Component.
setMessageBubbleStyle(MessageBubbleStyle messageBubbleStyle)MessageBubbleStyleThe setMessageBubbleStyle method is used to set the style and appearance of the message bubble in the CometChatMessageInformation component.
backIcon(@DrawableRes int res)@DrawableRes intThe back button is typically displayed at the top-left corner of the message information view, and it allows users to navigate back to the previous screen or close the message information view.
addOnBackPressListener(OnBackPress onBackPress)OnBackPressThis listener is triggered when the back button is pressed within the CometChatMessageInformation view. It provides a way to handle the back button press event and implement custom behavior.

MessageInformationStyle

This property is used to customize the appearance of the CometChatMesssageInformation component.

MethodsParametersDescription
setSubtitleTextColor(int subtitleTextColor)@ColorInt intSets the text color for the subtitle
setSubtitleTextAppearance(int subtitleTextAppearance)@StyleRes intSets the text appearance for the subtitle
setTitleFont(String titleFont)StringSets the font for the title
setEmptyTextFont(String emptyTextFont)StringSets the font for the empty state text
setTitleAppearance(int titleAppearance)@StyleRes intSets the text appearance for the title
setEmptyTextAppearance(int emptyTextAppearance)@StyleRes intSets the text appearance for the empty state text
setErrorTextAppearance(int errorTextAppearance)@StyleRes intSets the text appearance for the error state text
setTitleColor(int titleColor)@ColorInt intSets the text color for the title
setBackIconTint(int backIconTint)@ColorInt intSets the tint color for the back icon
setOnlineStatusColor(int onlineStatusColor)@ColorInt intSets the text color for the online status
setSeparatorColor(int separatorColor)@ColorInt intSets the color for the separator
setLoadingIconTint(int loadingIconTint)@ColorInt intSets the tint color for the loading icon
setEmptyTextColor(int emptyTextColor)@ColorInt intSets the text color for the empty state text
setErrorTextColor(int errorTextColor)@ColorInt intSets the text color for the error state text
setMessageTitleAppearance(int messageTitleAppearance)@StyleRes intSets the text appearance for the message title
setMessageInformationTitleAppearance(int messageInformationTitleAppearance)@StyleRes intSets the text appearance for the message information title
setMessageTextColor(int messageTextColor)@ColorInt intSets the text color for the message text
setMessageInfoTextColor(int messageInfoTextColor)@ColorInt intSets the text color for the message info text
setBackground(int background)@ColorInt intSets the background color
setBackground(Drawable drawableBackground)DrawableSets the drawable background
setCornerRadius(float cornerRadius)floatSets the corner radius
setBorderWidth(int borderWidth)intSets the width of the border
setBorderColor(int borderColor)intSets the color of the border
MessageInformationStyle messageInformationStyle = new MessageInformationStyle()
.setTitleAppearance(R.style.TitleTextStyle)
.setEmptyTextAppearance(R.style.EmptyTextStyle)
.setSubtitleTextColor(getResources().getColor(R.color.subtitle_text_color))
.setSubtitleTextAppearance(R.style.SubtitleTextStyle)
.setTitleColor(getResources().getColor(R.color.title_color))
.setBackIconTint(getResources().getColor(R.color.back_icon_tint))
.setBorderColor(getResources().getColor(R.color.border_color));
messageInformation.setStyle(messageInformationStyle);