DataSource Interface
TheDataSource interface defines how the UI Kit provides:
- Message templates (how each message type is rendered)
- Bubble content views (the actual views inside message bubbles)
- Message options (actions on message bubbles like reply, copy, delete)
- Attachment options (composer actions like camera, gallery, file)
- AI options (AI-powered composer actions)
- Text formatters (text processing for mentions, links, etc.)
DataSourceDecorator Pattern
DataSourceDecorator is an abstract class that wraps a DataSource and delegates all method calls to it. You extend it and override only the methods you want to customize. This is the decorator pattern — you layer behavior on top of the existing implementation.
ChatConfigurator
ChatConfigurator manages the active DataSource instance:
You can chain multiple decorators by calling
enable multiple times. Each call wraps the previous DataSource.
Example: Adding a Custom Message Option
Create aDataSourceDecorator that adds a “Translate” option to all text messages:
- Kotlin
- Java
Message Template Methods
Message templates define how each message type is rendered. Override these to add custom message types or modify existing ones:Bubble Content View Methods
Each message type has a pair of methods following thecreateView / bindView pattern:
The
get* method creates the View (called once per ViewHolder), and the bind* method populates it with data (called on each bind). Override these to completely replace how a message type is rendered inside its bubble.
Other DataSource Methods
Related
- Menu & Options — Component-level option customization.
- Text Formatters — Custom text processing via DataSource.
- Customization Overview — See all customization categories.