Skip to content

Commit 1057eaa

Browse files
authored
Merge pull request #631 from Kommunicate-io/CM-2415
[CM-2415] Expose Events with correct data to endusers | Android SDK
2 parents 8d5ee6b + da7b137 commit 1057eaa

File tree

4 files changed

+14
-0
lines changed

4 files changed

+14
-0
lines changed

kommunicate/src/main/java/io/kommunicate/callbacks/KmPluginEventListener.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ public interface KmPluginEventListener {
2020
void onVoiceButtonClick(String action);
2121
void onRatingEmoticonsClick(Integer ratingValue);
2222
void onRateConversationClick();
23+
void onCurrentOpenedConversation(Integer conversationId);
2324
}

kommunicate/src/main/java/io/kommunicate/devkit/broadcast/EventManager.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,12 @@ public void sendOnRateConversationClick() {
231231
kmPluginEventListener.onRateConversationClick();
232232
}
233233
}
234+
235+
public void sendOnCurrentOpenedConversation(Integer conversationID) {
236+
if (kmPluginEventListener != null && conversationID != null) {
237+
kmPluginEventListener.onCurrentOpenedConversation(conversationID);
238+
}
239+
}
234240
private void handleState(Message message) {
235241
if (message != null) {
236242
Bundle bundle = message.getData();

kommunicateui/src/main/java/io/kommunicate/ui/conversation/ConversationUIService.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import io.kommunicate.devkit.api.conversation.Message;
3434
import io.kommunicate.devkit.api.conversation.database.MessageDatabaseService;
3535
import io.kommunicate.devkit.broadcast.BroadcastService;
36+
import io.kommunicate.devkit.broadcast.EventManager;
3637
import io.kommunicate.devkit.channel.service.ChannelService;
3738
import io.kommunicate.devkit.contact.AppContactService;
3839
import io.kommunicate.devkit.contact.BaseContactService;
@@ -140,6 +141,7 @@ public ConversationFragment getConversationFragment() {
140141
Integer conversationId = ((ConversationActivity) fragmentActivity).getConversationId();
141142
conversationFragment = getConversationFragment(fragmentActivity, contact, channel, conversationId, null, null, null);
142143
ConversationActivity.addFragment(fragmentActivity, conversationFragment, CONVERSATION_FRAGMENT);
144+
EventManager.getInstance().sendOnCurrentOpenedConversation(conversationId);
143145
}
144146
return conversationFragment;
145147
}
@@ -152,6 +154,7 @@ public void run() {
152154
if (conversationFragment == null) {
153155
conversationFragment = getConversationFragment(fragmentActivity, contact, null, conversationId, searchString, messageSearchString, null);
154156
((MobiComKitActivityInterface) fragmentActivity).addFragment(conversationFragment);
157+
EventManager.getInstance().sendOnCurrentOpenedConversation(conversationId);
155158
} else {
156159
MessageInfoFragment messageInfoFragment = (MessageInfoFragment) UIService.getFragmentByTag(fragmentActivity, ConversationUIService.MESSGAE_INFO_FRAGMENT);
157160
if (messageInfoFragment != null) {
@@ -160,6 +163,7 @@ public void run() {
160163
}
161164
}
162165
conversationFragment.loadConversation(contact, conversationId, messageSearchString);
166+
EventManager.getInstance().sendOnCurrentOpenedConversation(conversationId);
163167
}
164168
}
165169
});
@@ -173,6 +177,7 @@ public void run() {
173177
if (conversationFragment == null) {
174178
conversationFragment = getConversationFragment(fragmentActivity, null, channel, conversationId, searchString, messageSearchString, preFilledMessage);
175179
((MobiComKitActivityInterface) fragmentActivity).addFragment(conversationFragment);
180+
EventManager.getInstance().sendOnCurrentOpenedConversation(conversationId);
176181
} else {
177182
MessageInfoFragment messageInfoFragment = (MessageInfoFragment) UIService.getFragmentByTag(fragmentActivity, ConversationUIService.MESSGAE_INFO_FRAGMENT);
178183
if (messageInfoFragment != null && fragmentActivity.getSupportFragmentManager() != null) {

kommunicateui/src/main/java/io/kommunicate/ui/conversation/activity/ConversationActivity.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,7 @@ protected void onCreate(Bundle savedInstanceState) {
464464
conversation = ConversationUIService.getConversationFragment(this, contact, null, currentConversationId, null, null, null);
465465
}
466466
addFragment(this, conversation, ConversationUIService.CONVERSATION_FRAGMENT);
467+
EventManager.getInstance().sendOnCurrentOpenedConversation(currentConversationId);
467468
}
468469
} else {
469470
setSearchListFragment(quickConversationFragment);
@@ -903,6 +904,7 @@ public void run() {
903904
channel = clickedChannel;
904905
conversation = ConversationUIService.getConversationFragment(ConversationActivity.this, null, channel, conversationId, searchString, null, null);
905906
addFragment(ConversationActivity.this, conversation, ConversationUIService.CONVERSATION_FRAGMENT);
907+
EventManager.getInstance().sendOnCurrentOpenedConversation(conversation.getId());
906908
}
907909
});
908910
}

0 commit comments

Comments
 (0)