cometchat-android-v6-compose-customization — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited cometchat-android-v6-compose-customization (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
Ground truth:com.cometchat:chatuikit-{compose,kotlin}-android:6.x(+calls-sdk-android:5.x) — resolved AAR (javap) +ui-kit/android/v6. Official docs: https://www.cometchat.com/docs/ui-kit/android/v6/overview · Docs MCP:claude mcp add --transport http cometchat-docs https://www.cometchat.com/docs/mcp(or fetch the URL directly without MCP). Verify symbols against the installed package/source before relying on them.
Companion skills: cometchat-android-v6-kotlin-customization (Views equivalent), cometchat-android-v6-compose-components, cometchat-android-v6-compose-theming, cometchat-android-v6-extensions (DataSource layer), cometchat-android-v6-events
Customize CometChat Compose components — override message bubble rendering with BubbleFactory, use slot lambda parameters for per-slot overrides, and apply @Immutable style classes. This is the v6 replacement for v5's DataSource/ChatConfigurator pattern.
cometchat-android-v6-kotlin-customization)cometchat-android-v6-compose-theming)cometchat-android-v6-extensions)BubbleFactory is an interface in com.cometchat.uikit.compose.presentation.shared.messagebubble. Each implementation handles a specific message type.
import com.cometchat.uikit.compose.presentation.shared.messagebubble.BubbleFactory
import com.cometchat.chat.constants.CometChatConstants
import com.cometchat.chat.models.BaseMessage
import com.cometchat.uikit.core.constants.UIKitConstants.MessageBubbleAlignment
class LocationBubbleFactory : BubbleFactory {
override fun getCategory(): String = CometChatConstants.CATEGORY_CUSTOM
override fun getType(): String = "location"
override fun getContentView(
message: BaseMessage,
alignment: MessageBubbleAlignment,
style: CometChatMessageBubbleStyle,
textFormatters: List<CometChatTextFormatter>
): @Composable () -> Unit = {
// Your custom content composable
val metadata = message.metadata
val lat = metadata?.optDouble("latitude") ?: 0.0
val lng = metadata?.optDouble("longitude") ?: 0.0
LocationMapView(latitude = lat, longitude = lng)
}
}CometChatMessageList(
user = user,
bubbleFactories = listOf(
LocationBubbleFactory(),
PaymentBubbleFactory()
)
)The list is converted to a map keyed by "category_type" internally via toFactoryMap().
Override getBubbleView() to replace the ENTIRE bubble (all slots):
class CustomBubbleFactory : BubbleFactory {
override fun getCategory(): String = "custom"
override fun getType(): String = "payment"
override fun getBubbleView(
message: BaseMessage,
alignment: MessageBubbleAlignment
): (@Composable () -> Unit)? = {
// Complete custom bubble — no header, footer, avatar, etc.
PaymentCard(message = message, alignment = alignment)
}
}When getBubbleView() returns non-null, all other slot methods are ignored.
All return (@Composable () -> Unit)? — return null to use defaults:
| Method | Slot | Parameters |
|---|---|---|
getContentView() | Main content | message, alignment, style, textFormatters |
getLeadingView() | Avatar | message, alignment, style |
getHeaderView() | Sender name | message, alignment, style, showTime |
getReplyView() | Reply preview | message, alignment, style |
getBottomView() | Moderation | message, alignment, style, hideModerationView |
getStatusInfoView() | Timestamp/receipts | message, alignment, style, showTime |
getThreadView() | Thread indicator | message, alignment, style, onThreadRepliesClick |
getFooterView() | Reactions | message, alignment, style, onReactionClick, onReactionLongClick, onAddMoreReactionsClick |
override fun getBubbleStyle(
message: BaseMessage,
alignment: MessageBubbleAlignment
): CometChatMessageBubbleStyle? {
return CometChatMessageBubbleStyle(
backgroundColor = Color(0xFFE8F5E9),
cornerRadius = 16.dp
)
}Factory style is the highest priority in the 3-tier style chain.
override fun onDispose(message: BaseMessage) {
// Clean up resources when bubble leaves composition
}attachmentOptions parameterA BubbleFactory only renders a custom type; to let users create one you usually add a composer attachment action. On Compose the canonical path is the `attachmentOptions` parameter on CometChatMessageComposer — a List<CometChatMessageComposerAction> whose contents are added after the built-in options.
CometChatMessageComposer(
user = user,
attachmentOptions = listOf(
CometChatMessageComposerAction(
id = "location",
title = "Send Location",
icon = R.drawable.ic_location,
onClick = OnClick { /* pick + send (see 1.8) */ }
)
)
)Append is automatic — your list does NOT replace the defaults. Internally the composable calls composerViewModel.setAttachmentOptions(attachmentOptions) (CometChatMessageComposer.kt:431-432), which sets only the custom options list (_customAttachmentOptions). The defaults (camera/image/video/audio/document/poll/collab-doc/collab-whiteboard) are rebuilt every time by getDefaultAttachmentOptions(...) and your custom options are concatenated at the end (CometChatMessageComposerViewModel.kt:646-649). There is no "wipe defaults" footgun here — setAttachmentOptions despite its name does NOT drop the built-ins.
Hide a built-in instead with the composer'shide*Optionflags (e.g.hidePollOption = true), which flip the_show*Optionvisibility checked insidegetDefaultAttachmentOptions.
If you hold a CometChatMessageComposerViewModel directly (advanced), addAttachmentOption(action) appends one custom option and setAttachmentOptions(list) replaces the custom list — both verified at CometChatMessageComposerViewModel.kt:657 / :666. The built-in option IDs are constants on CometChatMessageComposerAction (ID_CAMERA, ID_IMAGE, ID_VIDEO, ID_AUDIO, ID_DOCUMENT, ID_POLL, ID_COLLABORATIVE_DOCUMENT, ID_COLLABORATIVE_WHITEBOARD — CometChatMessageComposerAction.kt:42-49).
val message = CustomMessage(
receiverId,
CometChatConstants.RECEIVER_TYPE_USER, // or RECEIVER_TYPE_GROUP
"location", // matches the BubbleFactory type
customData // org.json.JSONObject
)
// ✅ kit path — sets muid + sender, fires ccMessageSent → list APPENDS
CometChatUIKit.sendCustomMessage(message, object : CometChat.CallbackListener<CustomMessage>() {
override fun onSuccess(p0: CustomMessage) {}
override fun onError(p0: CometChatException) {}
})
// ❌ CometChat.sendCustomMessage(...) — no muid/sender/event → recipient error + realtime replaceVerified (v6 core/compose): CometChatMessageComposer(attachmentOptions = …) param (CometChatMessageComposer.kt:338), CometChatMessageComposerViewModel.addAttachmentOption / setAttachmentOptions / getDefaultAttachmentOptions (:657 / :666 / :547), CometChatUIKit.sendCustomMessage(CustomMessage, CallbackListener) (CometChatUIKit.kt:472).
To replace the rendering of a built-in type (e.g. text or image), register a BubbleFactory whose getCategory()/getType() match the built-in identifiers. Built-in types are NOT pre-seeded as factory entries — the bubble falls back to InternalContentRenderer only when no factory matches a "category_type" key (CometChatMessageBubble.kt:155 "Falls back to InternalContentRenderer if no factory is provided"). So a matching factory simply takes priority over the internal default.
import com.cometchat.chat.constants.CometChatConstants
class MyTextBubbleFactory : BubbleFactory {
override fun getCategory(): String = CometChatConstants.CATEGORY_MESSAGE // "message"
override fun getType(): String = CometChatConstants.MESSAGE_TYPE_TEXT // "text"
override fun getContentView(
message: BaseMessage,
alignment: UIKitConstants.MessageBubbleAlignment,
style: CometChatMessageBubbleStyle,
textFormatters: List<CometChatTextFormatter>
): @Composable () -> Unit = {
MyCustomTextContent(message as TextMessage) // only the content area
}
// …or override getBubbleView() to replace the whole bubble (see 1.3)
}
CometChatMessageList(user = user, bubbleFactories = listOf(MyTextBubbleFactory()))This is still additive at the list level: registering a message_text factory only overrides text bubbles; image/video/custom types keep their internal rendering. Use getContentView() for content-only override, getBubbleView() for full-bubble replacement.
CometChatMessageList exposes two lambda parameters for the long-press option sheet (CometChatMessageList.kt:577-598):
| Param | Type | Semantics |
|---|---|---|
addOptions | ((BaseMessage) -> List<CometChatMessageOption>)? | Append after the defaults |
options | ((BaseMessage) -> List<CometChatMessageOption>?)? | Replace all defaults (takes precedence over addOptions; return null to keep defaults) |
onMessageOptionClick | ((BaseMessage, optionId: String, optionName: String) -> Unit)? | Click handler |
Use addOptions for a Forward-style action so the built-in Reply/Copy/Edit/Delete survive:
import com.cometchat.uikit.core.domain.model.CometChatMessageOption
CometChatMessageList(
user = user,
addOptions = { message -> // ✅ appended to defaults
listOf(
CometChatMessageOption(
id = "forward",
title = "Forward",
icon = R.drawable.ic_forward,
onClick = { /* open forward picker for `message` */ }
)
)
}
// ❌ options = { listOf(forward) } // would DROP reply/copy/edit/delete
)CometChatMessageOption(id, title, titleColor, icon, iconTintColor, …, onClick) is a data class at CometChatMessageOption.kt:21. Resolution order is verified in CometChatMessageListViewModel.resolveMessageOptions (:817-827): setOptions result wins if non-null, else defaultOptions + addOptions.
⚠️ Verify before using — symbols not found in the GA v6 Compose source.CometChatUIKit.getDataSource(),getMessageTemplates(),CometChatMessageTemplate, and atemplatesparameter on the ComposeCometChatMessageListappear in the Android docs but are absent from the verified `com.cometchat.uikit.compose` GA source (they're the legacycom.cometchat.chatuikitv5-shaped API; the Compose list only exposesbubbleFactories). Treat this section as a docs reference that may not compile against your installed v6 kit — prefer `BubbleFactory` (the confirmed v6-native path) for all new code.
The BubbleFactory / slot-lambda surface above is the primary v6 customization path. The Android docs also teach a `MessageTemplate` path through the data source (message-template) — fetch the existing templates, mutate the one you want, then re-apply (append, never replace with a single-item list):
// 1. fetch existing templates from the data source
val templates = CometChatUIKit.getDataSource()
.getMessageTemplates(additionParameter) // pass the list's additionParameter
.toMutableList()
// 2. mutate the template you want (or create a new one for a custom type)
templates.find { it.type == UIKitConstants.MessageType.TEXT }
?.setContentView { baseMessage, alignment ->
Text(text = (baseMessage as? TextMessage)?.text ?: "")
}
// new custom type:
val contact = CometChatMessageTemplate().apply {
setType("contact"); setCategory(UIKitConstants.MessageCategory.CUSTOM)
setContentView { baseMessage, _ -> /* custom composable */ }
}
templates.add(contact)
// 3. re-apply — Compose passes the list to CometChatMessageList
CometChatMessageList(user = user, templates = templates)Compose templates expose lambda slot setters (setContentView, setHeaderView, setFooterView, setBottomView, setStatusInfoView, setBubbleView, setOptions) mirroring §2's slots. Prefer BubbleFactory for new code; use getMessageTemplates(...) when you want to start from the kit's defaults and tweak one type. (This overlaps the custom-message topic.)
Override individual slots across ALL message types directly on CometChatMessageList:
CometChatMessageList(
user = user,
// Custom avatar for all messages
leadingView = { message, alignment ->
if (alignment == MessageAlignment.LEFT) {
AsyncImage(
model = message.sender?.avatar,
contentDescription = null,
modifier = Modifier.size(32.dp).clip(CircleShape)
)
}
},
// Custom timestamp for all messages
statusInfoView = { message, alignment ->
Text(
text = formatTime(message.sentAt),
style = CometChatTheme.typography.caption1Regular,
color = CometChatTheme.colorScheme.textColorTertiary
)
},
// Custom footer for all messages
footerView = { message, alignment ->
// Custom reactions display
ReactionsRow(message = message)
}
)| Parameter | Type | Slot |
|---|---|---|
leadingView | @Composable (BaseMessage, MessageAlignment) -> Unit | Avatar |
headerView | @Composable (BaseMessage, MessageAlignment) -> Unit | Sender name |
replyView | @Composable (BaseMessage, MessageAlignment) -> Unit | Reply preview |
contentView | @Composable (BaseMessage, MessageAlignment) -> Unit | Main content |
bottomView | @Composable (BaseMessage, MessageAlignment) -> Unit | Moderation |
statusInfoView | @Composable (BaseMessage, MessageAlignment) -> Unit | Timestamp/receipts |
threadView | @Composable (BaseMessage, MessageAlignment) -> Unit | Thread indicator |
footerView | @Composable (BaseMessage, MessageAlignment) -> Unit | Reactions |
For each slot, the resolution order is:
CometChatConversations(
style = CometChatConversationsStyle.default(
backgroundColor = Color(0xFFF5F5F5),
titleTextColor = Color.Black,
titleTextStyle = CometChatTheme.typography.heading1Bold,
separatorColor = Color.LightGray,
itemStyle = CometChatConversationListItemStyle.default(
titleTextColor = Color.DarkGray
)
)
)All style classes follow this pattern:
@Immutable
data class CometChatConversationsStyle(
val backgroundColor: Color,
val titleTextColor: Color,
val titleTextStyle: TextStyle,
// ... many properties
) {
companion object {
@Composable
fun default(
backgroundColor: Color = CometChatTheme.colorScheme.backgroundColor1,
titleTextColor: Color = CometChatTheme.colorScheme.textColorPrimary,
// ... defaults from CometChatTheme
): CometChatConversationsStyle = CometChatConversationsStyle(/* ... */)
}
}Use Companion.default() with named parameter overrides — never call the data class constructor directly.
Some styles contain nested style classes:
CometChatConversationsStyle.default(
itemStyle = CometChatConversationListItemStyle.default(/* ... */),
popupMenuStyle = CometChatPopupMenuStyle.default(/* ... */),
emptyStateStyle = CometChatEmptyStateStyle.default(/* ... */),
errorStateStyle = CometChatErrorStateStyle.default(/* ... */),
loadingStateStyle = CometChatLoadingStateStyle.default(/* ... */),
dialogStyle = CometChatDialogStyle.default(/* ... */)
)CometChatMessageList(
user = user,
loadingView = { CircularProgressIndicator() },
emptyView = { Text("No messages yet") },
errorView = { Text("Something went wrong") }
)| v5 Pattern | v6 Pattern |
|---|---|
ChatConfigurator.enable(decorator) | CometChatMessageList(bubbleFactories = listOf(...)) |
| DataSource template methods | BubbleFactory slot methods |
| Global decorator chain | Per-component factory registration |
| No bubble replacement | getBubbleView() for complete replacement |
| Theme-level styling only | Per-factory getBubbleStyle() |
Style/transform message text inline by passing textFormatters to the composer/list. The kit ships CometChatMentionsFormatter + CometChatRichTextFormatter (subclasses of the abstract CometChatTextFormatter) in com.cometchat.uikit.compose.presentation.shared.formatters. Default behavior (a mentions formatter) applies when you pass nothing — so to ADD a custom one, include the defaults too.
import com.cometchat.uikit.compose.presentation.shared.formatters.CometChatMentionsFormatter
import com.cometchat.uikit.compose.presentation.shared.formatters.CometChatTextFormatter
CometChatMessageComposer(
user = user,
textFormatters = listOf(CometChatMentionsFormatter(context) /* , YourFormatter(context) */),
)
// CometChatMessageList also takes textFormatters: List<CometChatTextFormatter>.For a custom @/#/! token: subclass CometChatTextFormatter(trackingCharacter) and implement its search() + view hooks (see the kit's formatters/ source + the per-platform docs).
interface — implement it, don't extend an abstract classgetCategory() and getType() are REQUIRED — they identify which message type the factory handlesgetBubbleView() returns non-null, ALL other slot methods are ignored for that message typeCometChatMessageList override BubbleFactory slot methods — use lambdas for cross-type overrides, factories for per-type overridesCompanion.default() factory — the data class constructor requires ALL parametersSound is a customization sub-dimension. The UI Kit plays incoming/outgoing message + call sounds via CometChatSoundManager — mute it, swap custom audio, or play a specific sound. The full API + recipe lives in `cometchat-android-v6-compose-theming` (Sound section). Verify the access path against the installed kit before relying on it.
~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.