AI Integration Quick Reference
AI Integration Quick Reference
Overview
Threaded replies allow users to respond directly to a specific message in one-on-one or group chats, improving context and readability:- Organizes related replies into a dedicated thread view.
- Mirrors functionality in Slack, Discord, and WhatsApp.
- Maintains clarity in active conversations.
Prerequisites
- Android project in Android Studio.
- CometChat Android UI Kit v5 (
com.cometchat:chatuikit-kotlinorcom.cometchat:chatuikit-jetpack) added to yourbuild.gradle. - Valid CometChat App ID, Auth Key, and Region initialized.
<uses-permission android:name="android.permission.INTERNET"/>inAndroidManifest.xml.- Logged-in user via
CometChatUIKit.login(). - Existing
MessagesActivityusingCometChatMessageList.
Components
Integration Steps
Step 1: Add Thread Layout
Createres/layout/activity_thread_message.xml:
activity_thread_message.xml
Step 2: Set up ThreadMessageActivity
Initialize UI & handle blocked-user flows:- Kotlin (XML Views)
- Jetpack Compose
Step 3: Create ThreadMessageViewModel
Store parent message and expose via StateFlow:Step 4: Hook Thread Entry from Message List
In yourMessagesActivity, capture thread icon taps:
- Kotlin (XML Views)
- Jetpack Compose
Implementation Flow
- User taps thread icon on a message.
IntentlaunchesThreadMessageActivitywith raw message JSON (or Compose navigation).- ViewModel stores parent message and exposes via StateFlow.
- Header &
MessageListrender parent + replies. - Composer sends new replies under the parent message.
- Live updates flow automatically via UI Kit.
Customization Options
- Styling: Override theme attributes or call setter methods on views.
- Header Height:
threadHeader.setMaxHeight(...). - Hide Reactions:
threadHeader.setReactionVisibility(View.GONE).
Filtering & Edge Cases
- Group Membership: Verify membership before enabling composer.
- Empty Thread: Show placeholder if no replies.
- Blocked Users: Composer hidden; use unblock layout.
Blocked-User Handling
- Kotlin (XML Views)
- Jetpack Compose
Group vs. User-Level Differences
Summary / Feature Matrix
Next Steps & Further Reading
Android Sample App (Kotlin)
Explore this feature in the CometChat SampleApp:
GitHub → SampleApp