build.gradle
.<uses-permission android:name="android.permission.INTERNET"/>
in AndroidManifest.xml
.CometChat.login()
.CometChatMessageList
and CometChatMessageComposer
.Component / Class | Role |
---|---|
UserDetailActivity.java | Displays user profile and provides block/unblock options. |
MessagesActivity.java | Hosts the chat screen and toggles UI based on block state. |
CometChatUIKit.blockUsers() | API to block one or more users by UID. |
CometChatUIKit.unblockUsers() | API to unblock one or more users by UID. |
User.isBlockedByMe() | Checks if the current user has blocked this user. |
unblockLayout (View) | Layout shown when a user is blocked, containing unblock. |
CometChatMessageComposer | Hidden when chatting with a blocked user. |
MessagesActivity.java
Ensures the composer and unblock UI reflect the current block state.
activity_messages.xml
Prepares the UI containers for dynamic show/hide operations.
UserDetailActivity.java
Integrates block action into the profile menu, triggering the UI toggle via LiveData.
Step | Action | Location |
---|---|---|
1 | Check block status | updateUserBlockStatus() in MessagesActivity.java fileciteturn9file0 |
2 | Show/hide composer and unblock layout | activity_messages.xml fileciteturn9file0 |
3 | Unblock API call and LiveData update | MessagesViewModel.unblockUser() |
4 | Block API call from profile | UserDetailActivity.blockMenuItem |
Case | Behavior |
---|---|
Blocked User | Composer hidden; unblock layout shown. |
Block Self | SDK ignores request; ensure menu is disabled. |
Group Chat | Blocking affects only 1:1 communication. |
Network Failure | Observe error callbacks and retry as needed. |
blockUsers
and unblockUsers
callbacks by showing alerts or retry prompts.Scenario | UI Behavior |
---|---|
ReceiverType.USER | Block/unblock enabled. |
ReceiverType.GROUP | Block option ignored; chat continues. |
Feature | Component / Method |
---|---|
Check block state | User.isBlockedByMe() |
Block user | CometChatUIKit.blockUsers() |
Unblock user | CometChatUIKit.unblockUsers() |
Update UI | updateUserBlockStatus() |
Profile block menu | UserDetailActivity.blockMenuItem |