@cometchat/skills 3.0.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +44 -17
- package/bin/install.js +389 -43
- package/package.json +19 -9
- package/skills/cometchat/SKILL.md +1066 -265
- package/skills/cometchat-android-v5/SKILL.md +120 -0
- package/skills/cometchat-android-v5-components/SKILL.md +430 -0
- package/skills/cometchat-android-v5-core/SKILL.md +468 -0
- package/skills/cometchat-android-v5-customization/SKILL.md +305 -0
- package/skills/cometchat-android-v5-extensions/SKILL.md +124 -0
- package/skills/cometchat-android-v5-features/SKILL.md +130 -0
- package/skills/cometchat-android-v5-placement/SKILL.md +276 -0
- package/skills/cometchat-android-v5-production/SKILL.md +94 -0
- package/skills/cometchat-android-v5-push/SKILL.md +620 -0
- package/skills/cometchat-android-v5-testing/SKILL.md +187 -0
- package/skills/cometchat-android-v5-theming/SKILL.md +166 -0
- package/skills/cometchat-android-v5-troubleshooting/SKILL.md +73 -0
- package/skills/cometchat-android-v6/SKILL.md +107 -0
- package/skills/cometchat-android-v6-builder-settings/SKILL.md +145 -0
- package/skills/cometchat-android-v6-compose-components/SKILL.md +202 -0
- package/skills/cometchat-android-v6-compose-customization/SKILL.md +280 -0
- package/skills/cometchat-android-v6-compose-placement/SKILL.md +213 -0
- package/skills/cometchat-android-v6-compose-theming/SKILL.md +224 -0
- package/skills/cometchat-android-v6-core/SKILL.md +354 -0
- package/skills/cometchat-android-v6-events/SKILL.md +212 -0
- package/skills/cometchat-android-v6-extensions/SKILL.md +191 -0
- package/skills/cometchat-android-v6-features/SKILL.md +130 -0
- package/skills/cometchat-android-v6-kotlin-components/SKILL.md +197 -0
- package/skills/cometchat-android-v6-kotlin-customization/SKILL.md +268 -0
- package/skills/cometchat-android-v6-kotlin-placement/SKILL.md +248 -0
- package/skills/cometchat-android-v6-kotlin-theming/SKILL.md +202 -0
- package/skills/cometchat-android-v6-production/SKILL.md +187 -0
- package/skills/cometchat-android-v6-push/SKILL.md +274 -0
- package/skills/cometchat-android-v6-testing/SKILL.md +279 -0
- package/skills/cometchat-android-v6-troubleshooting/SKILL.md +249 -0
- package/skills/cometchat-angular-components/SKILL.md +706 -0
- package/skills/cometchat-angular-core/SKILL.md +444 -0
- package/skills/cometchat-angular-customization/SKILL.md +424 -0
- package/skills/cometchat-angular-features/SKILL.md +447 -0
- package/skills/cometchat-angular-patterns/SKILL.md +447 -0
- package/skills/cometchat-angular-placement/SKILL.md +685 -0
- package/skills/cometchat-angular-production/SKILL.md +415 -0
- package/skills/cometchat-angular-theming/SKILL.md +365 -0
- package/skills/cometchat-angular-troubleshooting/SKILL.md +329 -0
- package/skills/cometchat-astro-patterns/SKILL.md +3 -3
- package/skills/cometchat-components/SKILL.md +11 -0
- package/skills/cometchat-core/SKILL.md +11 -6
- package/skills/cometchat-customization/references/component-catalog.md +1 -1
- package/skills/cometchat-features/SKILL.md +176 -108
- package/skills/cometchat-flutter-v5/SKILL.md +167 -0
- package/skills/cometchat-flutter-v5-calls/SKILL.md +192 -0
- package/skills/cometchat-flutter-v5-conversations/SKILL.md +117 -0
- package/skills/cometchat-flutter-v5-core/SKILL.md +221 -0
- package/skills/cometchat-flutter-v5-customization/SKILL.md +227 -0
- package/skills/cometchat-flutter-v5-events/SKILL.md +155 -0
- package/skills/cometchat-flutter-v5-messages/SKILL.md +258 -0
- package/skills/cometchat-flutter-v5-production/SKILL.md +207 -0
- package/skills/cometchat-flutter-v5-push/SKILL.md +284 -0
- package/skills/cometchat-flutter-v5-theming/SKILL.md +160 -0
- package/skills/cometchat-flutter-v5-troubleshooting/SKILL.md +129 -0
- package/skills/cometchat-flutter-v5-users-groups/SKILL.md +151 -0
- package/skills/cometchat-flutter-v6/SKILL.md +445 -0
- package/skills/cometchat-flutter-v6-calls/SKILL.md +333 -0
- package/skills/cometchat-flutter-v6-components/SKILL.md +365 -0
- package/skills/cometchat-flutter-v6-conversations/SKILL.md +210 -0
- package/skills/cometchat-flutter-v6-core/SKILL.md +305 -0
- package/skills/cometchat-flutter-v6-customization/SKILL.md +666 -0
- package/skills/cometchat-flutter-v6-events/SKILL.md +216 -0
- package/skills/cometchat-flutter-v6-features/SKILL.md +406 -0
- package/skills/cometchat-flutter-v6-messages/SKILL.md +333 -0
- package/skills/cometchat-flutter-v6-migration/SKILL.md +381 -0
- package/skills/cometchat-flutter-v6-placement/SKILL.md +398 -0
- package/skills/cometchat-flutter-v6-production/SKILL.md +632 -0
- package/skills/cometchat-flutter-v6-theming/SKILL.md +260 -0
- package/skills/cometchat-flutter-v6-troubleshooting/SKILL.md +726 -0
- package/skills/cometchat-flutter-v6-users-groups/SKILL.md +216 -0
- package/skills/cometchat-ios/SKILL.md +323 -0
- package/skills/cometchat-ios-components/SKILL.md +651 -0
- package/skills/cometchat-ios-core/SKILL.md +822 -0
- package/skills/cometchat-ios-customization/SKILL.md +825 -0
- package/skills/cometchat-ios-features/SKILL.md +725 -0
- package/skills/cometchat-ios-placement/SKILL.md +750 -0
- package/skills/cometchat-ios-production/SKILL.md +730 -0
- package/skills/cometchat-ios-push/SKILL.md +582 -0
- package/skills/cometchat-ios-theming/SKILL.md +631 -0
- package/skills/cometchat-ios-troubleshooting/SKILL.md +983 -0
- package/skills/cometchat-native-bare-patterns/SKILL.md +470 -0
- package/skills/cometchat-native-components/SKILL.md +594 -0
- package/skills/cometchat-native-core/SKILL.md +407 -0
- package/skills/cometchat-native-customization/SKILL.md +594 -0
- package/skills/cometchat-native-expo-patterns/SKILL.md +485 -0
- package/skills/cometchat-native-features/SKILL.md +608 -0
- package/skills/cometchat-native-placement/SKILL.md +500 -0
- package/skills/cometchat-native-production/SKILL.md +694 -0
- package/skills/cometchat-native-push/SKILL.md +593 -0
- package/skills/cometchat-native-testing/SKILL.md +583 -0
- package/skills/cometchat-native-theming/SKILL.md +656 -0
- package/skills/cometchat-native-troubleshooting/SKILL.md +433 -0
- package/skills/cometchat-nextjs-patterns/SKILL.md +5 -5
- package/skills/cometchat-production/SKILL.md +60 -0
- package/skills/cometchat-react-router-patterns/SKILL.md +23 -21
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cometchat-android-v6-kotlin-components
|
|
3
|
+
description: "CometChat Android UIKit v6 Kotlin Views component catalog — all custom View chat UI components, their properties, styles, and usage"
|
|
4
|
+
license: "MIT"
|
|
5
|
+
compatibility: "Android 9.0+ (API 28); Kotlin 1.9+; com.cometchat:chatuikit-kotlin-android:6.x"
|
|
6
|
+
allowed-tools: "executeBash, readFile, fileSearch, listDirectory"
|
|
7
|
+
metadata:
|
|
8
|
+
author: "CometChat"
|
|
9
|
+
version: "3.0.1"
|
|
10
|
+
tags: "cometchat, android, kotlin-views, components, conversations, messages, users, groups, calls"
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
> **Companion skills:** cometchat-android-v6-compose-components (Compose equivalent), cometchat-android-v6-kotlin-theming, cometchat-android-v6-kotlin-customization, cometchat-android-v6-kotlin-placement
|
|
14
|
+
|
|
15
|
+
## Purpose
|
|
16
|
+
|
|
17
|
+
Complete catalog of all Kotlin Views components in CometChat UIKit v6. Each component is a custom `View` class in `com.cometchat.uikit.kotlin.presentation`.
|
|
18
|
+
|
|
19
|
+
## Use this skill when
|
|
20
|
+
|
|
21
|
+
- Adding a CometChat Views component to an Activity or Fragment
|
|
22
|
+
- Looking up component properties and methods
|
|
23
|
+
- Understanding which component to use for a specific chat feature
|
|
24
|
+
- Finding the style class for a component
|
|
25
|
+
|
|
26
|
+
## Do not use this skill when
|
|
27
|
+
|
|
28
|
+
- Working with Compose components (use `cometchat-android-v6-compose-components`)
|
|
29
|
+
- Customizing bubble rendering (use `cometchat-android-v6-kotlin-customization`)
|
|
30
|
+
- Placing components in navigation (use `cometchat-android-v6-kotlin-placement`)
|
|
31
|
+
|
|
32
|
+
## 1. Component Catalog
|
|
33
|
+
|
|
34
|
+
### 1.1 List Components
|
|
35
|
+
|
|
36
|
+
| Component | Package | Type | Purpose |
|
|
37
|
+
|---|---|---|---|
|
|
38
|
+
| `CometChatConversations` | `presentation.conversations.ui` | View | Recent conversations list |
|
|
39
|
+
| `CometChatUsers` | `presentation.users.ui` | View | User list |
|
|
40
|
+
| `CometChatGroups` | `presentation.groups.ui` | View | Group list |
|
|
41
|
+
| `CometChatGroupMembers` | `presentation.groupmembers.ui` | View | Members of a group |
|
|
42
|
+
| `CometChatCallLogs` | `presentation.calllogs.ui` | View | Call history |
|
|
43
|
+
|
|
44
|
+
### 1.2 Messaging Components
|
|
45
|
+
|
|
46
|
+
| Component | Package | Type | Purpose |
|
|
47
|
+
|---|---|---|---|
|
|
48
|
+
| `CometChatMessageList` | `presentation.messagelist.ui` | View | Message list with bubbles |
|
|
49
|
+
| `CometChatMessageComposer` | `presentation.messagecomposer.ui` | View | Message input with attachments |
|
|
50
|
+
| `CometChatMessageHeader` | `presentation.messageheader.ui` | View | Chat header (name, status, actions) |
|
|
51
|
+
| `CometChatMessageInformation` | `presentation.messageinformation.ui` | View | Message delivery/read info |
|
|
52
|
+
| `CometChatThreadHeader` | `presentation.threadheader.ui` | View | Thread parent message header |
|
|
53
|
+
|
|
54
|
+
### 1.3 Call Components
|
|
55
|
+
|
|
56
|
+
| Component | Package | Type | Purpose |
|
|
57
|
+
|---|---|---|---|
|
|
58
|
+
| `CometChatCallButtons` | `presentation.callbuttons` | View | Audio/video call buttons |
|
|
59
|
+
| `CometChatIncomingCall` | `presentation.incomingcall` | View | Incoming call screen |
|
|
60
|
+
| `CometChatOutgoingCall` | `presentation.outgoingcall` | View | Outgoing call screen |
|
|
61
|
+
| `CometChatOngoingCall` | `presentation.ongoingcall.ui` | View | Active call screen |
|
|
62
|
+
| `CometChatCallActivity` | `calls` | Activity | Activity wrapper for calls |
|
|
63
|
+
|
|
64
|
+
### 1.4 Utility Components
|
|
65
|
+
|
|
66
|
+
| Component | Package | Type | Purpose |
|
|
67
|
+
|---|---|---|---|
|
|
68
|
+
| `CometChatSearch` | `presentation.search.ui` | View | Global search |
|
|
69
|
+
| `CometChatReactionList` | `presentation.reactionlist.ui` | View | Reaction details |
|
|
70
|
+
| `CometChatEmojiKeyboard` | `presentation.emojikeyboard.ui` | View | Emoji picker |
|
|
71
|
+
| `CometChatStickerKeyboard` | `presentation.stickerkeyboard.ui` | View | Sticker picker |
|
|
72
|
+
| `CometChatFlagMessageDialog` | `presentation.report` | Dialog | Report/flag message |
|
|
73
|
+
|
|
74
|
+
### 1.5 Shared Elements
|
|
75
|
+
|
|
76
|
+
Located in `presentation.shared/`:
|
|
77
|
+
|
|
78
|
+
- AI features: `aiconversationstarter/`, `aiconversationsummary/`, `aismartreplies/`
|
|
79
|
+
- Base elements: `baseelements/`
|
|
80
|
+
- Message bubble: `messagebubble/` (BubbleFactory, CometChatMessageBubble, InternalContentRenderer)
|
|
81
|
+
- Dialog: `dialog/`
|
|
82
|
+
- Media: `mediarecorder/`, `mediaselection/`, `mediaviewer/`, `inlineaudiorecorder/`
|
|
83
|
+
- Message preview: `messagepreview/`
|
|
84
|
+
- Moderation: `moderation/`
|
|
85
|
+
- Permissions: `permission/`
|
|
86
|
+
- Popup menu: `popupmenu/`
|
|
87
|
+
- Reactions: `reaction/`
|
|
88
|
+
- Receipts: `receipts/`
|
|
89
|
+
- Search box: `searchbox/`
|
|
90
|
+
- Shimmer: `shimmer/`
|
|
91
|
+
- Status indicator: `statusindicator/`
|
|
92
|
+
- Suggestion list: `suggestionlist/`
|
|
93
|
+
- Toolbar: `toolbar/`
|
|
94
|
+
- Typing indicator: `typingindicator/`
|
|
95
|
+
|
|
96
|
+
### 1.6 Adapters
|
|
97
|
+
|
|
98
|
+
List components use RecyclerView adapters:
|
|
99
|
+
|
|
100
|
+
| Adapter | Component |
|
|
101
|
+
|---|---|
|
|
102
|
+
| `ConversationsAdapter` | `CometChatConversations` |
|
|
103
|
+
| `MessageAdapter` | `CometChatMessageList` |
|
|
104
|
+
| Group/User adapters in respective packages | `CometChatGroups`, `CometChatUsers` |
|
|
105
|
+
|
|
106
|
+
## 2. Basic Usage Examples
|
|
107
|
+
|
|
108
|
+
### 2.1 Conversations List in an Activity
|
|
109
|
+
|
|
110
|
+
```kotlin
|
|
111
|
+
import com.cometchat.uikit.kotlin.presentation.conversations.ui.CometChatConversations
|
|
112
|
+
|
|
113
|
+
class ConversationsActivity : AppCompatActivity() {
|
|
114
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
|
115
|
+
super.onCreate(savedInstanceState)
|
|
116
|
+
|
|
117
|
+
val conversations = CometChatConversations(this)
|
|
118
|
+
conversations.setOnItemClick { conversation ->
|
|
119
|
+
// Navigate to chat
|
|
120
|
+
}
|
|
121
|
+
setContentView(conversations)
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### 2.2 Message List in XML Layout
|
|
127
|
+
|
|
128
|
+
```xml
|
|
129
|
+
<com.cometchat.uikit.kotlin.presentation.messagelist.ui.CometChatMessageList
|
|
130
|
+
android:id="@+id/messageList"
|
|
131
|
+
android:layout_width="match_parent"
|
|
132
|
+
android:layout_height="0dp"
|
|
133
|
+
android:layout_weight="1" />
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
```kotlin
|
|
137
|
+
val messageList = findViewById<CometChatMessageList>(R.id.messageList)
|
|
138
|
+
messageList.setUser(user)
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### 2.3 Users List
|
|
142
|
+
|
|
143
|
+
```kotlin
|
|
144
|
+
val users = CometChatUsers(this)
|
|
145
|
+
users.setOnItemClick { user ->
|
|
146
|
+
// Navigate to chat with user
|
|
147
|
+
}
|
|
148
|
+
setContentView(users)
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### 2.4 Full Chat Screen
|
|
152
|
+
|
|
153
|
+
```kotlin
|
|
154
|
+
class MessagesActivity : AppCompatActivity() {
|
|
155
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
|
156
|
+
super.onCreate(savedInstanceState)
|
|
157
|
+
setContentView(R.layout.activity_messages)
|
|
158
|
+
|
|
159
|
+
val header = findViewById<CometChatMessageHeader>(R.id.messageHeader)
|
|
160
|
+
val messageList = findViewById<CometChatMessageList>(R.id.messageList)
|
|
161
|
+
val composer = findViewById<CometChatMessageComposer>(R.id.messageComposer)
|
|
162
|
+
|
|
163
|
+
header.setUser(user)
|
|
164
|
+
messageList.setUser(user)
|
|
165
|
+
composer.setUser(user)
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## 3. Style Classes
|
|
171
|
+
|
|
172
|
+
Every component has a corresponding style class in its `style/` subpackage:
|
|
173
|
+
|
|
174
|
+
| Component | Style Class |
|
|
175
|
+
|---|---|
|
|
176
|
+
| `CometChatConversations` | `CometChatConversationsStyle` |
|
|
177
|
+
| `CometChatUsers` | `CometChatUsersStyle` |
|
|
178
|
+
| `CometChatGroups` | `CometChatGroupsStyle` |
|
|
179
|
+
| `CometChatGroupMembers` | `CometChatGroupMembersStyle` |
|
|
180
|
+
| `CometChatMessageList` | `CometChatMessageListStyle` |
|
|
181
|
+
| `CometChatMessageComposer` | `CometChatMessageComposerStyle` |
|
|
182
|
+
| `CometChatMessageHeader` | `CometChatMessageHeaderStyle` |
|
|
183
|
+
| `CometChatCallLogs` | `CometChatCallLogsStyle` |
|
|
184
|
+
| `CometChatThreadHeader` | `CometChatThreadHeaderStyle` |
|
|
185
|
+
|
|
186
|
+
Style classes resolve defaults from XML theme attributes and `CometChatTheme` singleton.
|
|
187
|
+
|
|
188
|
+
## 4. ViewModel Integration
|
|
189
|
+
|
|
190
|
+
Each component creates its own ViewModel internally via factories from `chatuikit-core`. ViewModels are shared with the Compose stack — the same `CometChatConversationsViewModel` powers both `CometChatConversations` (View) and `CometChatConversations` (@Composable).
|
|
191
|
+
|
|
192
|
+
## Hard rules
|
|
193
|
+
|
|
194
|
+
- Activity theme MUST inherit from `CometChatTheme.DayNight` (or `.Light` / `.Dark`) — `Theme.AppCompat.*`, `Theme.MaterialComponents.*.Bridge`, plain `Theme.MaterialComponents.*`, and `Theme.Material3.*` all crash at component inflation. See `cometchat-android-v6-kotlin-placement` "Activity theme" section.
|
|
195
|
+
- Components create their own ViewModels internally — do NOT try to create or inject ViewModels manually
|
|
196
|
+
- Use `setUser(user)` or `setGroup(group)` to configure messaging components — they need a target to load messages
|
|
197
|
+
- For bubble customization, use `setBubbleFactories()` and `set*ViewProvider()` — see `cometchat-android-v6-kotlin-customization`
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cometchat-android-v6-kotlin-customization
|
|
3
|
+
description: "CometChat Android UIKit v6 Kotlin Views customization — BubbleFactory abstract class, BubbleViewProvider, style classes, and per-slot overrides"
|
|
4
|
+
license: "MIT"
|
|
5
|
+
compatibility: "Android 9.0+ (API 28); Kotlin 1.9+; com.cometchat:chatuikit-kotlin-android:6.x"
|
|
6
|
+
allowed-tools: "executeBash, readFile, fileSearch, listDirectory"
|
|
7
|
+
metadata:
|
|
8
|
+
author: "CometChat"
|
|
9
|
+
version: "3.0.0"
|
|
10
|
+
tags: "cometchat, android, kotlin-views, customization, bubble-factory, bubble-view-provider, style"
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
> **Companion skills:** cometchat-android-v6-compose-customization (Compose equivalent), cometchat-android-v6-kotlin-components, cometchat-android-v6-kotlin-theming, cometchat-android-v6-extensions (DataSource layer), cometchat-android-v6-events
|
|
14
|
+
|
|
15
|
+
## Purpose
|
|
16
|
+
|
|
17
|
+
Customize CometChat Kotlin Views components — override message bubble rendering with BubbleFactory, use BubbleViewProvider for per-slot overrides, and apply style classes. This is the v6 replacement for v5's DataSource/ChatConfigurator pattern.
|
|
18
|
+
|
|
19
|
+
## Use this skill when
|
|
20
|
+
|
|
21
|
+
- Creating custom message bubble rendering for specific message types
|
|
22
|
+
- Overriding individual bubble slots (avatar, header, footer, content, etc.)
|
|
23
|
+
- Applying custom styles to components
|
|
24
|
+
- Replacing the entire bubble layout for a message type
|
|
25
|
+
|
|
26
|
+
## Do not use this skill when
|
|
27
|
+
|
|
28
|
+
- Working with Compose customization (use `cometchat-android-v6-compose-customization`)
|
|
29
|
+
- Changing theme colors globally (use `cometchat-android-v6-kotlin-theming`)
|
|
30
|
+
- Extending the data layer (use `cometchat-android-v6-extensions`)
|
|
31
|
+
|
|
32
|
+
## 1. BubbleFactory (Message Bubble Customization)
|
|
33
|
+
|
|
34
|
+
`BubbleFactory` is an abstract class in `com.cometchat.uikit.kotlin.presentation.shared.messagebubble`. Each subclass handles a specific message type.
|
|
35
|
+
|
|
36
|
+
### 1.1 Creating a Custom BubbleFactory
|
|
37
|
+
|
|
38
|
+
```kotlin
|
|
39
|
+
import com.cometchat.uikit.kotlin.presentation.shared.messagebubble.BubbleFactory
|
|
40
|
+
import com.cometchat.chat.constants.CometChatConstants
|
|
41
|
+
import com.cometchat.chat.models.BaseMessage
|
|
42
|
+
import com.cometchat.uikit.core.constants.UIKitConstants.MessageBubbleAlignment
|
|
43
|
+
|
|
44
|
+
class LocationBubbleFactory : BubbleFactory() {
|
|
45
|
+
|
|
46
|
+
override fun getCategory(): String = CometChatConstants.CATEGORY_CUSTOM
|
|
47
|
+
override fun getType(): String = "location"
|
|
48
|
+
|
|
49
|
+
override fun createContentView(context: Context): View {
|
|
50
|
+
// Called ONCE when ViewHolder is created — message NOT available here
|
|
51
|
+
return LocationMapView(context)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
override fun bindContentView(
|
|
55
|
+
view: View,
|
|
56
|
+
message: BaseMessage,
|
|
57
|
+
alignment: MessageBubbleAlignment,
|
|
58
|
+
holder: RecyclerView.ViewHolder?,
|
|
59
|
+
position: Int
|
|
60
|
+
) {
|
|
61
|
+
// Called EVERY TIME a message is displayed
|
|
62
|
+
val mapView = view as LocationMapView
|
|
63
|
+
val metadata = message.metadata
|
|
64
|
+
mapView.setLocation(
|
|
65
|
+
metadata?.optDouble("latitude") ?: 0.0,
|
|
66
|
+
metadata?.optDouble("longitude") ?: 0.0
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### 1.2 Registering BubbleFactories
|
|
73
|
+
|
|
74
|
+
```kotlin
|
|
75
|
+
val messageList = findViewById<CometChatMessageList>(R.id.messageList)
|
|
76
|
+
messageList.setBubbleFactories(listOf(
|
|
77
|
+
LocationBubbleFactory(),
|
|
78
|
+
PaymentBubbleFactory()
|
|
79
|
+
))
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
The list is converted to a map keyed by `"category_type"` internally.
|
|
83
|
+
|
|
84
|
+
### 1.3 Complete Bubble Replacement
|
|
85
|
+
|
|
86
|
+
Override `createBubbleView()` / `bindBubbleView()` to replace the ENTIRE bubble:
|
|
87
|
+
|
|
88
|
+
```kotlin
|
|
89
|
+
class CustomBubbleFactory : BubbleFactory() {
|
|
90
|
+
override fun getCategory(): String = "custom"
|
|
91
|
+
override fun getType(): String = "payment"
|
|
92
|
+
|
|
93
|
+
override fun createBubbleView(context: Context): View? {
|
|
94
|
+
// Return non-null to replace the entire CometChatMessageBubble
|
|
95
|
+
return PaymentCardView(context)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
override fun bindBubbleView(
|
|
99
|
+
view: View,
|
|
100
|
+
message: BaseMessage,
|
|
101
|
+
alignment: MessageBubbleAlignment,
|
|
102
|
+
holder: RecyclerView.ViewHolder?,
|
|
103
|
+
position: Int
|
|
104
|
+
) {
|
|
105
|
+
(view as PaymentCardView).bind(message)
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
When `createBubbleView()` returns non-null, `createContentView()` and all other slot methods are ignored.
|
|
111
|
+
|
|
112
|
+
### 1.4 Slot Methods
|
|
113
|
+
|
|
114
|
+
All follow the create/bind pattern for RecyclerView efficiency:
|
|
115
|
+
|
|
116
|
+
| Create Method | Bind Method | Slot |
|
|
117
|
+
|---|---|---|
|
|
118
|
+
| `createContentView(ctx): View` | `bindContentView(view, msg, align, holder, pos)` | Main content |
|
|
119
|
+
| `createLeadingView(ctx): View?` | `bindLeadingView(view, msg, align)` | Avatar |
|
|
120
|
+
| `createHeaderView(ctx): View?` | `bindHeaderView(view, msg, align)` | Sender name |
|
|
121
|
+
| `createReplyView(ctx): View?` | `bindReplyView(view, msg, align)` | Reply preview |
|
|
122
|
+
| `createBottomView(ctx): View?` | `bindBottomView(view, msg, align)` | Reactions |
|
|
123
|
+
| `createStatusInfoView(ctx): View?` | `bindStatusInfoView(view, msg, align)` | Timestamp/receipts |
|
|
124
|
+
| `createThreadView(ctx): View?` | `bindThreadView(view, msg, align)` | Thread indicator |
|
|
125
|
+
| `createFooterView(ctx): View?` | `bindFooterView(view, msg, align)` | Footer |
|
|
126
|
+
|
|
127
|
+
**Critical:** `create*()` methods are called when the ViewHolder is created — the message is NOT available. All message-specific logic goes in `bind*()`.
|
|
128
|
+
|
|
129
|
+
### 1.5 Style Override
|
|
130
|
+
|
|
131
|
+
```kotlin
|
|
132
|
+
override fun getBubbleStyle(
|
|
133
|
+
message: BaseMessage,
|
|
134
|
+
alignment: MessageBubbleAlignment
|
|
135
|
+
): CometChatMessageBubbleStyle? {
|
|
136
|
+
// Highest priority in the 3-tier style chain
|
|
137
|
+
return CometChatMessageBubbleStyle(/* custom style */)
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### 1.6 Lifecycle
|
|
142
|
+
|
|
143
|
+
```kotlin
|
|
144
|
+
override fun onViewRecycled(contentView: View) {
|
|
145
|
+
// Clean up resources (image loads, animations, media playback)
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### 1.7 Factory Key
|
|
150
|
+
|
|
151
|
+
```kotlin
|
|
152
|
+
// Get the factory key for a message
|
|
153
|
+
val key = BubbleFactory.getFactoryKey(message) // "category_type" or "deleted"
|
|
154
|
+
|
|
155
|
+
// Create a key manually
|
|
156
|
+
val key = BubbleFactory.getKey("custom", "location") // "custom_location"
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## 2. BubbleViewProvider (Per-Slot Overrides)
|
|
160
|
+
|
|
161
|
+
`BubbleViewProvider` is a simpler interface for overriding individual slots across ALL message types.
|
|
162
|
+
|
|
163
|
+
### 2.1 Interface
|
|
164
|
+
|
|
165
|
+
```kotlin
|
|
166
|
+
interface BubbleViewProvider {
|
|
167
|
+
fun createView(
|
|
168
|
+
context: Context,
|
|
169
|
+
message: BaseMessage,
|
|
170
|
+
alignment: MessageBubbleAlignment
|
|
171
|
+
): View?
|
|
172
|
+
|
|
173
|
+
fun bindView(
|
|
174
|
+
view: View,
|
|
175
|
+
message: BaseMessage,
|
|
176
|
+
alignment: MessageBubbleAlignment
|
|
177
|
+
)
|
|
178
|
+
}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### 2.2 Usage
|
|
182
|
+
|
|
183
|
+
```kotlin
|
|
184
|
+
val messageList = findViewById<CometChatMessageList>(R.id.messageList)
|
|
185
|
+
|
|
186
|
+
// Custom avatar for all messages
|
|
187
|
+
messageList.setLeadingViewProvider(object : BubbleViewProvider {
|
|
188
|
+
override fun createView(
|
|
189
|
+
context: Context,
|
|
190
|
+
message: BaseMessage,
|
|
191
|
+
alignment: MessageBubbleAlignment
|
|
192
|
+
): View? {
|
|
193
|
+
return if (alignment == MessageBubbleAlignment.LEFT) {
|
|
194
|
+
ImageView(context).apply {
|
|
195
|
+
layoutParams = ViewGroup.LayoutParams(32.dp, 32.dp)
|
|
196
|
+
}
|
|
197
|
+
} else null
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
override fun bindView(
|
|
201
|
+
view: View,
|
|
202
|
+
message: BaseMessage,
|
|
203
|
+
alignment: MessageBubbleAlignment
|
|
204
|
+
) {
|
|
205
|
+
(view as ImageView).load(message.sender?.avatar)
|
|
206
|
+
}
|
|
207
|
+
})
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### 2.3 All Provider Setters
|
|
211
|
+
|
|
212
|
+
| Method | Slot |
|
|
213
|
+
|---|---|
|
|
214
|
+
| `setLeadingViewProvider(provider)` | Avatar |
|
|
215
|
+
| `setHeaderViewProvider(provider)` | Sender name |
|
|
216
|
+
| `setContentViewProvider(provider)` | Main content |
|
|
217
|
+
| `setReplyViewProvider(provider)` | Reply preview |
|
|
218
|
+
| `setBottomViewProvider(provider)` | Reactions |
|
|
219
|
+
| `setStatusInfoViewProvider(provider)` | Timestamp/receipts |
|
|
220
|
+
| `setThreadViewProvider(provider)` | Thread indicator |
|
|
221
|
+
| `setFooterViewProvider(provider)` | Footer |
|
|
222
|
+
|
|
223
|
+
### 2.4 Priority Order
|
|
224
|
+
|
|
225
|
+
For each slot:
|
|
226
|
+
1. Explicit `BubbleViewProvider` (highest priority)
|
|
227
|
+
2. `BubbleFactory` slot method
|
|
228
|
+
3. Internal default rendering
|
|
229
|
+
|
|
230
|
+
## 3. Component-Level Customization
|
|
231
|
+
|
|
232
|
+
### 3.1 Header/Footer Views on MessageList
|
|
233
|
+
|
|
234
|
+
```kotlin
|
|
235
|
+
// Custom header above the message list
|
|
236
|
+
messageList.setHeaderView(myCustomHeaderView)
|
|
237
|
+
|
|
238
|
+
// Custom footer below the message list
|
|
239
|
+
messageList.setFooterView(myCustomFooterView)
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### 3.2 Style Classes
|
|
243
|
+
|
|
244
|
+
```kotlin
|
|
245
|
+
// Style classes resolve from XML attrs and CometChatTheme singleton
|
|
246
|
+
val style = CometChatMessageListStyle(/* properties */)
|
|
247
|
+
messageList.setStyle(style)
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
## 4. v5 → v6 Migration
|
|
251
|
+
|
|
252
|
+
| v5 Pattern | v6 Pattern |
|
|
253
|
+
|---|---|
|
|
254
|
+
| `ChatConfigurator.enable(decorator)` | `messageList.setBubbleFactories(listOf(...))` |
|
|
255
|
+
| DataSource template methods | BubbleFactory slot methods |
|
|
256
|
+
| Global decorator chain | Per-component factory registration |
|
|
257
|
+
| No bubble replacement | `createBubbleView()` for complete replacement |
|
|
258
|
+
| Theme-level styling only | Per-factory `getBubbleStyle()` |
|
|
259
|
+
|
|
260
|
+
## Hard rules
|
|
261
|
+
|
|
262
|
+
- BubbleFactory is an `abstract class` — extend it with `BubbleFactory()`
|
|
263
|
+
- `create*()` methods are called WITHOUT a message — do NOT access message data in create methods
|
|
264
|
+
- `bind*()` methods receive the message — all message-specific logic goes here
|
|
265
|
+
- BubbleViewProvider overrides take precedence over BubbleFactory slot methods
|
|
266
|
+
- For per-type content customization, use BubbleFactory. For cross-type slot overrides, use BubbleViewProvider
|
|
267
|
+
- `onViewRecycled()` is critical for cleaning up image loads, animations, or media playback
|
|
268
|
+
- Do NOT confuse BubbleFactory (UI rendering) with DataSource (data fetching) — they are separate layers
|