diff --git a/android/src/main/java/io/openim/flutter_openim_sdk/FlutterOpenimSdkPlugin.java b/android/src/main/java/io/openim/flutter_openim_sdk/FlutterOpenimSdkPlugin.java index c8fea9f..4bc81fd 100644 --- a/android/src/main/java/io/openim/flutter_openim_sdk/FlutterOpenimSdkPlugin.java +++ b/android/src/main/java/io/openim/flutter_openim_sdk/FlutterOpenimSdkPlugin.java @@ -16,6 +16,7 @@ import io.flutter.plugin.common.MethodChannel.MethodCallHandler; import io.flutter.plugin.common.MethodChannel.Result; import io.openim.flutter_openim_sdk.manager.ConversationManager; import io.openim.flutter_openim_sdk.manager.FriendshipManager; +import io.openim.flutter_openim_sdk.manager.GroupManager; import io.openim.flutter_openim_sdk.manager.IMManager; import io.openim.flutter_openim_sdk.manager.MessageManager; import io.openim.flutter_openim_sdk.util.CommonUtil; @@ -35,6 +36,7 @@ public class FlutterOpenimSdkPlugin implements FlutterPlugin, MethodCallHandler private static FriendshipManager friendshipManager; private static MessageManager messageManager; private static ConversationManager conversationManager; + private static GroupManager groupManager; public FlutterOpenimSdkPlugin() { } @@ -44,6 +46,7 @@ public class FlutterOpenimSdkPlugin implements FlutterPlugin, MethodCallHandler FlutterOpenimSdkPlugin.friendshipManager = new FriendshipManager(); FlutterOpenimSdkPlugin.messageManager = new MessageManager(); FlutterOpenimSdkPlugin.conversationManager = new ConversationManager(); + FlutterOpenimSdkPlugin.groupManager = new GroupManager(); } @Override diff --git a/android/src/main/java/io/openim/flutter_openim_sdk/listener/AdvancedMsgListenerImpl.java b/android/src/main/java/io/openim/flutter_openim_sdk/listener/AdvancedMsgListener.java similarity index 87% rename from android/src/main/java/io/openim/flutter_openim_sdk/listener/AdvancedMsgListenerImpl.java rename to android/src/main/java/io/openim/flutter_openim_sdk/listener/AdvancedMsgListener.java index cb8acea..92f1ee4 100644 --- a/android/src/main/java/io/openim/flutter_openim_sdk/listener/AdvancedMsgListenerImpl.java +++ b/android/src/main/java/io/openim/flutter_openim_sdk/listener/AdvancedMsgListener.java @@ -6,10 +6,10 @@ import java.util.Map; import io.openim.flutter_openim_sdk.util.CommonUtil; import open_im_sdk.OnAdvancedMsgListener; -public class AdvancedMsgListenerImpl implements OnAdvancedMsgListener { +public class AdvancedMsgListener implements OnAdvancedMsgListener { final Map values = new HashMap<>(); - public AdvancedMsgListenerImpl(String listenerId) { + public AdvancedMsgListener(String listenerId) { this.values.put("id", listenerId); } diff --git a/android/src/main/java/io/openim/flutter_openim_sdk/listener/BaseImpl.java b/android/src/main/java/io/openim/flutter_openim_sdk/listener/BaseListener.java similarity index 85% rename from android/src/main/java/io/openim/flutter_openim_sdk/listener/BaseImpl.java rename to android/src/main/java/io/openim/flutter_openim_sdk/listener/BaseListener.java index ac7be97..41810a4 100644 --- a/android/src/main/java/io/openim/flutter_openim_sdk/listener/BaseImpl.java +++ b/android/src/main/java/io/openim/flutter_openim_sdk/listener/BaseListener.java @@ -6,11 +6,11 @@ import io.flutter.plugin.common.MethodChannel; import io.openim.flutter_openim_sdk.util.CommonUtil; import open_im_sdk.Base; -public class BaseImpl implements Base { +public class BaseListener implements Base { MethodChannel.Result result; - public BaseImpl(MethodChannel.Result result) { + public BaseListener(MethodChannel.Result result) { this.result = result; } diff --git a/android/src/main/java/io/openim/flutter_openim_sdk/listener/ConversationListenerImpl.java b/android/src/main/java/io/openim/flutter_openim_sdk/listener/ConversationListener.java similarity index 93% rename from android/src/main/java/io/openim/flutter_openim_sdk/listener/ConversationListenerImpl.java rename to android/src/main/java/io/openim/flutter_openim_sdk/listener/ConversationListener.java index fdc41e0..9d91ea1 100644 --- a/android/src/main/java/io/openim/flutter_openim_sdk/listener/ConversationListenerImpl.java +++ b/android/src/main/java/io/openim/flutter_openim_sdk/listener/ConversationListener.java @@ -3,7 +3,7 @@ package io.openim.flutter_openim_sdk.listener; import io.openim.flutter_openim_sdk.util.CommonUtil; import open_im_sdk.OnConversationListener; -public class ConversationListenerImpl implements OnConversationListener { +public class ConversationListener implements OnConversationListener { @Override diff --git a/android/src/main/java/io/openim/flutter_openim_sdk/listener/FriendshipListenerImpl.java b/android/src/main/java/io/openim/flutter_openim_sdk/listener/FriendshipListener.java similarity index 95% rename from android/src/main/java/io/openim/flutter_openim_sdk/listener/FriendshipListenerImpl.java rename to android/src/main/java/io/openim/flutter_openim_sdk/listener/FriendshipListener.java index 0ce7ad9..7ec7962 100644 --- a/android/src/main/java/io/openim/flutter_openim_sdk/listener/FriendshipListenerImpl.java +++ b/android/src/main/java/io/openim/flutter_openim_sdk/listener/FriendshipListener.java @@ -3,7 +3,7 @@ package io.openim.flutter_openim_sdk.listener; import io.openim.flutter_openim_sdk.util.CommonUtil; import open_im_sdk.OnFriendshipListener; -public class FriendshipListenerImpl implements OnFriendshipListener { +public class FriendshipListener implements OnFriendshipListener { @Override public void onBlackListAdd(String s) { diff --git a/android/src/main/java/io/openim/flutter_openim_sdk/listener/GroupListener.java b/android/src/main/java/io/openim/flutter_openim_sdk/listener/GroupListener.java new file mode 100644 index 0000000..9f21a90 --- /dev/null +++ b/android/src/main/java/io/openim/flutter_openim_sdk/listener/GroupListener.java @@ -0,0 +1,77 @@ +package io.openim.flutter_openim_sdk.listener; + +import java.util.HashMap; +import java.util.Map; + +import io.openim.flutter_openim_sdk.util.CommonUtil; +import open_im_sdk.OnGroupListener; + +public class GroupListener implements OnGroupListener { + @Override + public void onApplicationProcessed(String s, String s1, int i, String s2) { + Map map = new HashMap<>(); + map.put("groupId", s); + map.put("opUser", s1); + map.put("agreeOrReject", i); + map.put("opReason", s2); + CommonUtil.emitEvent("groupListener", "onApplicationProcessed", map); + } + + @Override + public void onGroupCreated(String s) { + Map map = new HashMap<>(); + map.put("groupId", s); + CommonUtil.emitEvent("groupListener", "onGroupCreated", map); + } + + @Override + public void onGroupInfoChanged(String s, String s1) { + Map map = new HashMap<>(); + map.put("groupId", s); + map.put("groupInfo", s1); + CommonUtil.emitEvent("groupListener", "onGroupInfoChanged", map); + } + + @Override + public void onMemberEnter(String s, String s1) { + Map map = new HashMap<>(); + map.put("groupId", s); + map.put("memberList", s1); + CommonUtil.emitEvent("groupListener", "onMemberEnter", map); + } + + @Override + public void onMemberInvited(String s, String s1, String s2) { + Map map = new HashMap<>(); + map.put("groupId", s); + map.put("opUser", s1); + map.put("memberList", s2); + CommonUtil.emitEvent("groupListener", "onMemberInvited", map); + } + + @Override + public void onMemberKicked(String s, String s1, String s2) { + Map map = new HashMap<>(); + map.put("groupId", s); + map.put("opUser", s1); + map.put("memberList", s2); + CommonUtil.emitEvent("groupListener", "onMemberKicked", map); + } + + @Override + public void onMemberLeave(String s, String s1) { + Map map = new HashMap<>(); + map.put("groupId", s); + map.put("member", s1); + CommonUtil.emitEvent("groupListener", "onMemberLeave", map); + } + + @Override + public void onReceiveJoinApplication(String s, String s1, String s2) { + Map map = new HashMap<>(); + map.put("groupId", s); + map.put("member", s1); + map.put("opReason", s2); + CommonUtil.emitEvent("groupListener", "onReceiveJoinApplication", map); + } +} diff --git a/android/src/main/java/io/openim/flutter_openim_sdk/listener/SDKListenerImpl.java b/android/src/main/java/io/openim/flutter_openim_sdk/listener/SDKListener.java similarity index 94% rename from android/src/main/java/io/openim/flutter_openim_sdk/listener/SDKListenerImpl.java rename to android/src/main/java/io/openim/flutter_openim_sdk/listener/SDKListener.java index f2ea706..cb7cf03 100644 --- a/android/src/main/java/io/openim/flutter_openim_sdk/listener/SDKListenerImpl.java +++ b/android/src/main/java/io/openim/flutter_openim_sdk/listener/SDKListener.java @@ -4,7 +4,7 @@ package io.openim.flutter_openim_sdk.listener; import io.openim.flutter_openim_sdk.util.CommonUtil; import open_im_sdk.IMSDKListener; -public class SDKListenerImpl implements IMSDKListener { +public class SDKListener implements IMSDKListener { @Override public void onConnectFailed(long l, String s) { diff --git a/android/src/main/java/io/openim/flutter_openim_sdk/manager/ConversationManager.java b/android/src/main/java/io/openim/flutter_openim_sdk/manager/ConversationManager.java index abdf4e5..907bc55 100644 --- a/android/src/main/java/io/openim/flutter_openim_sdk/manager/ConversationManager.java +++ b/android/src/main/java/io/openim/flutter_openim_sdk/manager/ConversationManager.java @@ -2,42 +2,53 @@ package io.openim.flutter_openim_sdk.manager; import io.flutter.plugin.common.MethodCall; import io.flutter.plugin.common.MethodChannel; -import io.openim.flutter_openim_sdk.listener.BaseImpl; -import io.openim.flutter_openim_sdk.listener.ConversationListenerImpl; +import io.openim.flutter_openim_sdk.listener.BaseListener; +import io.openim.flutter_openim_sdk.listener.ConversationListener; import io.openim.flutter_openim_sdk.util.CommonUtil; import open_im_sdk.Open_im_sdk; public class ConversationManager { public void setConversationListener(MethodCall methodCall, MethodChannel.Result result) { - Open_im_sdk.setConversationListener(new ConversationListenerImpl()); + Open_im_sdk.setConversationListener(new ConversationListener()); } public void getAllConversationList(MethodCall methodCall, MethodChannel.Result result) { - Open_im_sdk.getAllConversationList(new BaseImpl(result)); + Open_im_sdk.getAllConversationList(new BaseListener(result)); } public void getOneConversation(MethodCall methodCall, MethodChannel.Result result) { - Open_im_sdk.getOneConversation(CommonUtil.getConversationSourceId(methodCall), CommonUtil.getConversationSessionType(methodCall), new BaseImpl(result)); + Open_im_sdk.getOneConversation( + CommonUtil.getConversationSourceId(methodCall), + CommonUtil.getConversationSessionType(methodCall), + new BaseListener(result)); } public void getMultipleConversation(MethodCall methodCall, MethodChannel.Result result) { - Open_im_sdk.getMultipleConversation(CommonUtil.getConversationIds(methodCall), new BaseImpl(result)); + Open_im_sdk.getMultipleConversation( + CommonUtil.getConversationIds(methodCall), + new BaseListener(result)); } public void deleteConversation(MethodCall methodCall, MethodChannel.Result result) { - Open_im_sdk.deleteConversation(CommonUtil.getConversationId(methodCall), new BaseImpl(result)); + Open_im_sdk.deleteConversation(CommonUtil.getConversationId(methodCall), new BaseListener(result)); } public void setConversationDraft(MethodCall methodCall, MethodChannel.Result result) { - Open_im_sdk.setConversationDraft(CommonUtil.getConversationId(methodCall), CommonUtil.getConversationDraft(methodCall), new BaseImpl(result)); + Open_im_sdk.setConversationDraft( + CommonUtil.getConversationId(methodCall), + CommonUtil.getConversationDraft(methodCall), + new BaseListener(result)); } public void pinConversation(MethodCall methodCall, MethodChannel.Result result) { - Open_im_sdk.pinConversation(CommonUtil.getConversationId(methodCall), CommonUtil.isPinnedConversation(methodCall), new BaseImpl(result)); + Open_im_sdk.pinConversation( + CommonUtil.getConversationId(methodCall), + CommonUtil.isPinnedConversation(methodCall), + new BaseListener(result)); } public void getTotalUnreadMsgCount(MethodCall methodCall, MethodChannel.Result result) { - Open_im_sdk.getTotalUnreadMsgCount(new BaseImpl(result)); + Open_im_sdk.getTotalUnreadMsgCount(new BaseListener(result)); } } diff --git a/android/src/main/java/io/openim/flutter_openim_sdk/manager/FriendshipManager.java b/android/src/main/java/io/openim/flutter_openim_sdk/manager/FriendshipManager.java index 5626042..ca2eba4 100644 --- a/android/src/main/java/io/openim/flutter_openim_sdk/manager/FriendshipManager.java +++ b/android/src/main/java/io/openim/flutter_openim_sdk/manager/FriendshipManager.java @@ -2,8 +2,8 @@ package io.openim.flutter_openim_sdk.manager; import io.flutter.plugin.common.MethodCall; import io.flutter.plugin.common.MethodChannel; -import io.openim.flutter_openim_sdk.listener.BaseImpl; -import io.openim.flutter_openim_sdk.listener.FriendshipListenerImpl; +import io.openim.flutter_openim_sdk.listener.BaseListener; +import io.openim.flutter_openim_sdk.listener.FriendshipListener; import io.openim.flutter_openim_sdk.util.CommonUtil; import open_im_sdk.Open_im_sdk; @@ -11,55 +11,55 @@ public class FriendshipManager { public void setFriendListener(MethodCall methodCall, MethodChannel.Result result) { - Open_im_sdk.setFriendListener(new FriendshipListenerImpl()); + Open_im_sdk.setFriendListener(new FriendshipListener()); } public void getFriendsInfo(MethodCall methodCall, MethodChannel.Result result) { - Open_im_sdk.getFriendsInfo(new BaseImpl(result), CommonUtil.getUidList(methodCall)); + Open_im_sdk.getFriendsInfo(new BaseListener(result), CommonUtil.getUidList(methodCall)); } public void addFriend(MethodCall methodCall, MethodChannel.Result result) { - Open_im_sdk.addFriend(new BaseImpl(result), CommonUtil.getSDKJsonParam(methodCall)); + Open_im_sdk.addFriend(new BaseListener(result), CommonUtil.getSDKJsonParam(methodCall)); } public void getFriendApplicationList(MethodCall methodCall, MethodChannel.Result result) { - Open_im_sdk.getFriendApplicationList(new BaseImpl(result)); + Open_im_sdk.getFriendApplicationList(new BaseListener(result)); } public void getFriendList(MethodCall methodCall, MethodChannel.Result result) { - Open_im_sdk.getFriendList(new BaseImpl(result)); + Open_im_sdk.getFriendList(new BaseListener(result)); } public void setFriendInfo(MethodCall methodCall, MethodChannel.Result result) { - Open_im_sdk.setFriendInfo(CommonUtil.getSDKJsonParam(methodCall), new BaseImpl(result)); + Open_im_sdk.setFriendInfo(CommonUtil.getSDKJsonParam(methodCall), new BaseListener(result)); } public void addToBlackList(MethodCall methodCall, MethodChannel.Result result) { - Open_im_sdk.addToBlackList(new BaseImpl(result), CommonUtil.getJsonUid(methodCall)); + Open_im_sdk.addToBlackList(new BaseListener(result), CommonUtil.getJsonUid(methodCall)); } public void getBlackList(MethodCall methodCall, MethodChannel.Result result) { - Open_im_sdk.getBlackList(new BaseImpl(result)); + Open_im_sdk.getBlackList(new BaseListener(result)); } public void deleteFromBlackList(MethodCall methodCall, MethodChannel.Result result) { - Open_im_sdk.deleteFromBlackList(new BaseImpl(result), CommonUtil.getJsonUid(methodCall)); + Open_im_sdk.deleteFromBlackList(new BaseListener(result), CommonUtil.getJsonUid(methodCall)); } public void checkFriend(MethodCall methodCall, MethodChannel.Result result) { - Open_im_sdk.checkFriend(new BaseImpl(result), CommonUtil.getUidList(methodCall)); + Open_im_sdk.checkFriend(new BaseListener(result), CommonUtil.getUidList(methodCall)); } public void deleteFromFriendList(MethodCall methodCall, MethodChannel.Result result) { - Open_im_sdk.deleteFromFriendList(CommonUtil.getJsonUid(methodCall), new BaseImpl(result)); + Open_im_sdk.deleteFromFriendList(CommonUtil.getJsonUid(methodCall), new BaseListener(result)); } public void acceptFriendApplication(MethodCall methodCall, MethodChannel.Result result) { - Open_im_sdk.acceptFriendApplication(new BaseImpl(result), CommonUtil.getJsonUid(methodCall)); + Open_im_sdk.acceptFriendApplication(new BaseListener(result), CommonUtil.getJsonUid(methodCall)); } public void refuseFriendApplication(MethodCall methodCall, MethodChannel.Result result) { - Open_im_sdk.refuseFriendApplication(new BaseImpl(result), CommonUtil.getJsonUid(methodCall)); + Open_im_sdk.refuseFriendApplication(new BaseListener(result), CommonUtil.getJsonUid(methodCall)); } public void forceSyncFriendApplication(MethodCall methodCall, MethodChannel.Result result) { diff --git a/android/src/main/java/io/openim/flutter_openim_sdk/manager/GroupManager.java b/android/src/main/java/io/openim/flutter_openim_sdk/manager/GroupManager.java index 01e169f..31cb5eb 100644 --- a/android/src/main/java/io/openim/flutter_openim_sdk/manager/GroupManager.java +++ b/android/src/main/java/io/openim/flutter_openim_sdk/manager/GroupManager.java @@ -1,6 +1,113 @@ package io.openim.flutter_openim_sdk.manager; +import io.flutter.plugin.common.MethodCall; +import io.flutter.plugin.common.MethodChannel; +import io.openim.flutter_openim_sdk.listener.BaseListener; +import io.openim.flutter_openim_sdk.listener.GroupListener; +import io.openim.flutter_openim_sdk.util.CommonUtil; +import open_im_sdk.Open_im_sdk; + public class GroupManager { + public void setGroupListener(MethodCall methodCall, MethodChannel.Result result) { + Open_im_sdk.setGroupListener(new GroupListener()); + } + + public void inviteUserToGroup(MethodCall methodCall, MethodChannel.Result result) { + Open_im_sdk.inviteUserToGroup( + CommonUtil.getGid(methodCall), + CommonUtil.getGroupOpReason(methodCall), + CommonUtil.getUidList(methodCall), + new BaseListener(result)); + } + + public void kickGroupMember(MethodCall methodCall, MethodChannel.Result result) { + System.out.println("gid:" + CommonUtil.getGid(methodCall)); + System.out.println("reason:" + CommonUtil.getGroupOpReason(methodCall)); + System.out.println("uidList:" + CommonUtil.getUidList(methodCall)); + Open_im_sdk.kickGroupMember( + CommonUtil.getGid(methodCall), + CommonUtil.getGroupOpReason(methodCall), + CommonUtil.getUidList(methodCall), + new BaseListener(result)); + } + + public void getGroupMembersInfo(MethodCall methodCall, MethodChannel.Result result) { + Open_im_sdk.getGroupMembersInfo( + CommonUtil.getGid(methodCall), + CommonUtil.getUidList(methodCall), + new BaseListener(result)); + } + + public void getGroupMemberList(MethodCall methodCall, MethodChannel.Result result) { + Open_im_sdk.getGroupMemberList( + CommonUtil.getGid(methodCall), + CommonUtil.getGroupListFilter(methodCall), + CommonUtil.getGroupListNext(methodCall), + new BaseListener(result)); + } + + + public void getJoinedGroupList(MethodCall methodCall, MethodChannel.Result result) { + Open_im_sdk.getJoinedGroupList(new BaseListener(result)); + } + + public void createGroup(MethodCall methodCall, MethodChannel.Result result) { + Open_im_sdk.createGroup( + CommonUtil.getGroupInfo(methodCall), + CommonUtil.getGroupMemberRoleList(methodCall), + new BaseListener(result)); + } + + public void setGroupInfo(MethodCall methodCall, MethodChannel.Result result) { + Open_im_sdk.setGroupInfo( + CommonUtil.getGroupInfo(methodCall), + new BaseListener(result)); + } + + public void getGroupsInfo(MethodCall methodCall, MethodChannel.Result result) { + Open_im_sdk.getGroupsInfo( + CommonUtil.getGidList(methodCall), + new BaseListener(result)); + } + + public void joinGroup(MethodCall methodCall, MethodChannel.Result result) { + Open_im_sdk.joinGroup( + CommonUtil.getGid(methodCall), + CommonUtil.getGroupOpReason(methodCall), + new BaseListener(result)); + } + + public void quitGroup(MethodCall methodCall, MethodChannel.Result result) { + Open_im_sdk.quitGroup( + CommonUtil.getGid(methodCall), + new BaseListener(result)); + } + + public void transferGroupOwner(MethodCall methodCall, MethodChannel.Result result) { + Open_im_sdk.transferGroupOwner( + CommonUtil.getGid(methodCall), + CommonUtil.getUid(methodCall), + new BaseListener(result)); + } + + public void getGroupApplicationList(MethodCall methodCall, MethodChannel.Result result) { + Open_im_sdk.getGroupApplicationList(new BaseListener(result)); + } + + public void acceptGroupApplication(MethodCall methodCall, MethodChannel.Result result) { + Open_im_sdk.acceptGroupApplication( + CommonUtil.getGroupApplicationInfo(methodCall), + CommonUtil.getGroupOpReason(methodCall), + new BaseListener(result)); + + } + + public void refuseGroupApplication(MethodCall methodCall, MethodChannel.Result result) { + Open_im_sdk.refuseGroupApplication( + CommonUtil.getGroupApplicationInfo(methodCall), + CommonUtil.getGroupOpReason(methodCall), + new BaseListener(result)); -} + } +} \ No newline at end of file diff --git a/android/src/main/java/io/openim/flutter_openim_sdk/manager/IMManager.java b/android/src/main/java/io/openim/flutter_openim_sdk/manager/IMManager.java index dd9f223..83a7a0a 100644 --- a/android/src/main/java/io/openim/flutter_openim_sdk/manager/IMManager.java +++ b/android/src/main/java/io/openim/flutter_openim_sdk/manager/IMManager.java @@ -2,24 +2,24 @@ package io.openim.flutter_openim_sdk.manager; import io.flutter.plugin.common.MethodCall; import io.flutter.plugin.common.MethodChannel; -import io.openim.flutter_openim_sdk.listener.BaseImpl; -import io.openim.flutter_openim_sdk.listener.SDKListenerImpl; +import io.openim.flutter_openim_sdk.listener.BaseListener; +import io.openim.flutter_openim_sdk.listener.SDKListener; import io.openim.flutter_openim_sdk.util.CommonUtil; import open_im_sdk.Open_im_sdk; public class IMManager { public void initSDK(MethodCall methodCall, MethodChannel.Result result) { - Open_im_sdk.initSDK(CommonUtil.getSDKJsonParam(methodCall), new SDKListenerImpl()); + Open_im_sdk.initSDK(CommonUtil.getSDKJsonParam(methodCall), new SDKListener()); CommonUtil.runMainThreadReturn(result, null); } public void login(MethodCall methodCall, MethodChannel.Result result) { - Open_im_sdk.login(CommonUtil.getUid(methodCall), CommonUtil.getToken(methodCall), new BaseImpl(result)); + Open_im_sdk.login(CommonUtil.getUid(methodCall), CommonUtil.getToken(methodCall), new BaseListener(result)); } public void logout(MethodCall methodCall, MethodChannel.Result result) { - Open_im_sdk.logout(new BaseImpl(result)); + Open_im_sdk.logout(new BaseListener(result)); } public void getLoginStatus(MethodCall methodCall, MethodChannel.Result result) { @@ -31,11 +31,11 @@ public class IMManager { } public void getUsersInfo(MethodCall methodCall, MethodChannel.Result result) { - Open_im_sdk.getUsersInfo(CommonUtil.getUidList(methodCall), new BaseImpl(result)); + Open_im_sdk.getUsersInfo(CommonUtil.getUidList(methodCall), new BaseListener(result)); } public void setSelfInfo(MethodCall methodCall, MethodChannel.Result result) { - Open_im_sdk.setSelfInfo(CommonUtil.getSDKJsonParam(methodCall), new BaseImpl(result)); + Open_im_sdk.setSelfInfo(CommonUtil.getSDKJsonParam(methodCall), new BaseListener(result)); } public void forceSyncLoginUerInfo(MethodCall methodCall, MethodChannel.Result result) { diff --git a/android/src/main/java/io/openim/flutter_openim_sdk/manager/MessageManager.java b/android/src/main/java/io/openim/flutter_openim_sdk/manager/MessageManager.java index 143e289..ea2f89a 100644 --- a/android/src/main/java/io/openim/flutter_openim_sdk/manager/MessageManager.java +++ b/android/src/main/java/io/openim/flutter_openim_sdk/manager/MessageManager.java @@ -1,14 +1,12 @@ package io.openim.flutter_openim_sdk.manager; -import android.content.Context; - import java.util.HashMap; import java.util.Map; import io.flutter.plugin.common.MethodCall; import io.flutter.plugin.common.MethodChannel; -import io.openim.flutter_openim_sdk.listener.AdvancedMsgListenerImpl; -import io.openim.flutter_openim_sdk.listener.BaseImpl; +import io.openim.flutter_openim_sdk.listener.AdvancedMsgListener; +import io.openim.flutter_openim_sdk.listener.BaseListener; import io.openim.flutter_openim_sdk.listener.MsgSendProgressListener; import io.openim.flutter_openim_sdk.util.CommonUtil; import open_im_sdk.OnAdvancedMsgListener; @@ -22,7 +20,7 @@ public class MessageManager { public void addAdvancedMsgListener(MethodCall methodCall, MethodChannel.Result result) { String key = methodCall.argument(KEY_ID); if (!listeners.containsKey(key)) { - AdvancedMsgListenerImpl listener = new AdvancedMsgListenerImpl(key); + AdvancedMsgListener listener = new AdvancedMsgListener(key); listeners.put(methodCall.argument(KEY_ID), listener); Open_im_sdk.addAdvancedMsgListener(listener); } @@ -36,19 +34,23 @@ public class MessageManager { public void sendMessage(MethodCall methodCall, MethodChannel.Result result) { MsgSendProgressListener listener = new MsgSendProgressListener(result, methodCall); - Open_im_sdk.sendMessage(listener, CommonUtil.getSendMessageContent(methodCall), CommonUtil.getSendMessageReceiver(methodCall), CommonUtil.geSendMessageGroupId(methodCall), CommonUtil.getSendMessageOnlineOnly(methodCall)); + Open_im_sdk.sendMessage(listener, + CommonUtil.getSendMessageContent(methodCall), + CommonUtil.getSendMessageReceiver(methodCall), + CommonUtil.geSendMessageGroupId(methodCall), + CommonUtil.getSendMessageOnlineOnly(methodCall)); } public void getHistoryMessageList(MethodCall methodCall, MethodChannel.Result result) { - Open_im_sdk.getHistoryMessageList(new BaseImpl(result), CommonUtil.getSDKJsonParam(methodCall)); + Open_im_sdk.getHistoryMessageList(new BaseListener(result), CommonUtil.getSDKJsonParam(methodCall)); } public void revokeMessage(MethodCall methodCall, MethodChannel.Result result) { - Open_im_sdk.revokeMessage(new BaseImpl(result), CommonUtil.getSDKJsonParam(methodCall)); + Open_im_sdk.revokeMessage(new BaseListener(result), CommonUtil.getSDKJsonParam(methodCall)); } public void deleteMessageFromLocalStorage(MethodCall methodCall, MethodChannel.Result result) { - Open_im_sdk.deleteMessageFromLocalStorage(new BaseImpl(result), CommonUtil.getSDKJsonParam(methodCall)); + Open_im_sdk.deleteMessageFromLocalStorage(new BaseListener(result), CommonUtil.getSDKJsonParam(methodCall)); } public void deleteMessages(MethodCall methodCall, MethodChannel.Result result) { @@ -56,46 +58,81 @@ public class MessageManager { } public void insertSingleMessageToLocalStorage(MethodCall methodCall, MethodChannel.Result result) { - Open_im_sdk.insertSingleMessageToLocalStorage(new BaseImpl(result), CommonUtil.getSingleMessageContent(methodCall), CommonUtil.getSingleMessageUserid(methodCall), CommonUtil.getSingleMessageSender(methodCall)); + Open_im_sdk.insertSingleMessageToLocalStorage(new BaseListener(result), + CommonUtil.getSingleMessageContent(methodCall), + CommonUtil.getSingleMessageUserid(methodCall), + CommonUtil.getSingleMessageSender(methodCall)); } public void findMessages(MethodCall methodCall, MethodChannel.Result result) { - Open_im_sdk.findMessages(new BaseImpl(result), CommonUtil.getFindMessageIds(methodCall)); + Open_im_sdk.findMessages(new BaseListener(result), CommonUtil.getFindMessageIds(methodCall)); } public void markSingleMessageHasRead(MethodCall methodCall, MethodChannel.Result result) { - Open_im_sdk.markSingleMessageHasRead(new BaseImpl(result), CommonUtil.getSingleMessageUserid(methodCall)); + Open_im_sdk.markSingleMessageHasRead(new BaseListener(result), CommonUtil.getSingleMessageUserid(methodCall)); + } + + public void markGroupMessageHasRead(MethodCall methodCall, MethodChannel.Result result) { + Open_im_sdk.markGroupMessageHasRead(new BaseListener(result), CommonUtil.getGroupMessageGroupid(methodCall)); + } + + public void markC2CMessageAsRead(MethodCall methodCall, MethodChannel.Result result) { +// Open_im_sdk.markC2CMessageAsRead(new BaseImpl(result), CommonUtil.getSingleMessageUserid(methodCall)); } public void createTextMessage(MethodCall methodCall, MethodChannel.Result result) { - CommonUtil.runMainThreadReturn(result, Open_im_sdk.createTextMessage(CommonUtil.getMessageText(methodCall))); + CommonUtil.runMainThreadReturn(result, + Open_im_sdk.createTextMessage( + CommonUtil.getMessageText(methodCall))); } public void createTextAtMessage(MethodCall methodCall, MethodChannel.Result result) { - CommonUtil.runMainThreadReturn(result, Open_im_sdk.createTextAtMessage(CommonUtil.getMessageText(methodCall), CommonUtil.getAtUserList(methodCall))); + CommonUtil.runMainThreadReturn(result, + Open_im_sdk.createTextAtMessage( + CommonUtil.getMessageText(methodCall), + CommonUtil.getAtUserList(methodCall))); } public void createImageMessage(MethodCall methodCall, MethodChannel.Result result) { - CommonUtil.runMainThreadReturn(result, Open_im_sdk.createImageMessage(CommonUtil.getImagePath(methodCall))); + CommonUtil.runMainThreadReturn(result, + Open_im_sdk.createImageMessage( + CommonUtil.getImagePath(methodCall))); } public void createSoundMessage(MethodCall methodCall, MethodChannel.Result result) { - CommonUtil.runMainThreadReturn(result, Open_im_sdk.createSoundMessage(CommonUtil.getSoundPath(methodCall), CommonUtil.getSoundDuration(methodCall))); + CommonUtil.runMainThreadReturn(result, + Open_im_sdk.createSoundMessage( + CommonUtil.getSoundPath(methodCall), + CommonUtil.getSoundDuration(methodCall))); } public void createVideoMessage(MethodCall methodCall, MethodChannel.Result result) { - CommonUtil.runMainThreadReturn(result, Open_im_sdk.createVideoMessage(CommonUtil.getVideoPath(methodCall), CommonUtil.getVideoType(methodCall), CommonUtil.getVideoDuration(methodCall), CommonUtil.getVideoSnapshotPath(methodCall))); + CommonUtil.runMainThreadReturn(result, + Open_im_sdk.createVideoMessage( + CommonUtil.getVideoPath(methodCall), + CommonUtil.getVideoType(methodCall), + CommonUtil.getVideoDuration(methodCall), + CommonUtil.getVideoSnapshotPath(methodCall))); } public void createFileMessage(MethodCall methodCall, MethodChannel.Result result) { - CommonUtil.runMainThreadReturn(result, Open_im_sdk.createFileMessage(CommonUtil.getFilePath(methodCall), CommonUtil.getFileName(methodCall))); + CommonUtil.runMainThreadReturn(result, + Open_im_sdk.createFileMessage( + CommonUtil.getFilePath(methodCall), + CommonUtil.getFileName(methodCall))); } public void createMergerMessage(MethodCall methodCall, MethodChannel.Result result) { - CommonUtil.runMainThreadReturn(result, Open_im_sdk.createMergerMessage(CommonUtil.getMergerMessageList(methodCall), CommonUtil.getMergerMessageTitle(methodCall), CommonUtil.getSummaryList(methodCall))); + CommonUtil.runMainThreadReturn(result, + Open_im_sdk.createMergerMessage( + CommonUtil.getMergerMessageList(methodCall), + CommonUtil.getMergerMessageTitle(methodCall), + CommonUtil.getSummaryList(methodCall))); } public void createForwardMessage(MethodCall methodCall, MethodChannel.Result result) { - CommonUtil.runMainThreadReturn(result, Open_im_sdk.createForwardMessage(CommonUtil.getForwardMessage(methodCall))); + CommonUtil.runMainThreadReturn(result, + Open_im_sdk.createForwardMessage( + CommonUtil.getForwardMessage(methodCall))); } } diff --git a/android/src/main/java/io/openim/flutter_openim_sdk/util/CommonUtil.java b/android/src/main/java/io/openim/flutter_openim_sdk/util/CommonUtil.java index dbff4bb..d1994ff 100644 --- a/android/src/main/java/io/openim/flutter_openim_sdk/util/CommonUtil.java +++ b/android/src/main/java/io/openim/flutter_openim_sdk/util/CommonUtil.java @@ -85,15 +85,15 @@ public class CommonUtil { /////////////////////////////////////// ////////////////////////////////////// public static String getUid(MethodCall methodCall) { - return getParamValue(methodCall, KEY_LOGIN_UID); + return getParamValue(methodCall, KEY_UID); } public static String getJsonUid(MethodCall methodCall) { - return JsonUtil.toString(getParamValue(methodCall, KEY_LOGIN_UID)); + return JsonUtil.toString(getParamValue(methodCall, KEY_UID)); } public static String getToken(MethodCall methodCall) { - return getParamValue(methodCall, KEY_LOGIN_TOKEN); + return getParamValue(methodCall, KEY_TOKEN); } public static String getMessageText(MethodCall methodCall) { @@ -191,6 +191,10 @@ public class CommonUtil { return getParamValue(methodCall, KEY_SINGLE_MESSAGE_USERID); } + public static String getGroupMessageGroupid(MethodCall methodCall) { + return getParamValue(methodCall, KEY_GROUP_MESSAGE_GROUPID); + } + public static String getSingleMessageSender(MethodCall methodCall) { return getParamValue(methodCall, KEY_SINGLE_MESSAGE_SENDER); } @@ -227,10 +231,41 @@ public class CommonUtil { return getSDKJsonParam(methodCall, KEY_USER_IDS); } + public static String getGid(MethodCall methodCall) { + return getParamValue(methodCall, KEY_GROUP_ID); + } + + public static String getGidList(MethodCall methodCall) { + return getSDKJsonParam(methodCall, KEY_GROUP_IDS); + } + + public static String getGroupOpReason(MethodCall methodCall) { + return getParamValue(methodCall, KEY_GROUP_OP_REASON); + } + + public static int getGroupListFilter(MethodCall methodCall) { + return getParamValue(methodCall, KEY_GROUP_LIST_FILTER); + } + + public static int getGroupListNext(MethodCall methodCall) { + return getParamValue(methodCall, KEY_GROUP_LIST_NEXT); + } + + public static String getGroupInfo(MethodCall methodCall) { + return getSDKJsonParam(methodCall, KEY_GROUP_INFO); + } + + public static String getGroupMemberRoleList(MethodCall methodCall) { + return getSDKJsonParam(methodCall, KEY_GROUP_MEMBER_ROLE_LIST); + } + + public static String getGroupApplicationInfo(MethodCall methodCall) { + return getSDKJsonParam(methodCall, KEY_GROUP_APPLICATION_INFO); + } //login - final static String KEY_LOGIN_UID = "uid"; - final static String KEY_LOGIN_TOKEN = "token"; + final static String KEY_UID = "uid"; + final static String KEY_TOKEN = "token"; //create message body final static String KEY_TEXT = "text"; final static String KEY_AT_USER_LIST = "atUserList"; @@ -257,6 +292,8 @@ public class CommonUtil { final static String KEY_SINGLE_MESSAGE_CONTENT = "message"; final static String KEY_SINGLE_MESSAGE_USERID = "userID"; final static String KEY_SINGLE_MESSAGE_SENDER = "sender"; + //group chat + final static String KEY_GROUP_MESSAGE_GROUPID = "groupID"; // find message final static String KEY_FIND_MESSAGE_IDS = "messageIDList"; // conversation @@ -268,4 +305,15 @@ public class CommonUtil { final static String KEY_CONVERSATION_SESSION_TYPE = "sessionType"; // user info final static String KEY_USER_IDS = "uidList"; + // group + final static String KEY_GROUP_ID = "gid"; + final static String KEY_GROUP_IDS = "gidList"; + final static String KEY_GROUP_OP_REASON = "reason"; + // final static String KEY_GROUP_USER_ID = "uid"; +// final static String KEY_GROUP_USER_IDS = "uidList"; + final static String KEY_GROUP_LIST_FILTER = "filter"; + final static String KEY_GROUP_LIST_NEXT = "next"; + final static String KEY_GROUP_INFO = "gInfo"; + final static String KEY_GROUP_MEMBER_ROLE_LIST = "memberList"; + final static String KEY_GROUP_APPLICATION_INFO = "application"; } diff --git a/lib/flutter_openim_sdk.dart b/lib/flutter_openim_sdk.dart index 3a55311..0325efd 100644 --- a/lib/flutter_openim_sdk.dart +++ b/lib/flutter_openim_sdk.dart @@ -1,8 +1,13 @@ +library flutter_openim_sdk; + +export 'src/enum/conversation_type.dart'; +export 'src/enum/group_role.dart'; export 'src/enum/listener_type.dart'; export 'src/enum/message_type.dart'; export 'src/listener/advanced_msg_listener.dart'; export 'src/listener/conversation_listener.dart'; export 'src/listener/friendship_listener.dart'; +export 'src/listener/group_listener.dart'; export 'src/listener/init_sdk_listener.dart'; export 'src/listener/msg_send_progress_listener.dart'; export 'src/manager/im_conversation_manager.dart'; @@ -13,6 +18,7 @@ export 'src/manager/im_message_manager.dart'; export 'src/manager/im_offline_push_manager.dart'; export 'src/manager/im_signaling_manager.dart'; export 'src/models/conversation_info.dart'; +export 'src/models/group_info.dart'; export 'src/models/message.dart'; export 'src/models/user_info.dart'; export 'src/openim.dart'; diff --git a/lib/src/enum/conversation_type.dart b/lib/src/enum/conversation_type.dart new file mode 100644 index 0000000..688058a --- /dev/null +++ b/lib/src/enum/conversation_type.dart @@ -0,0 +1,4 @@ +class ConversationType{ + static const int single_chat = 1; + static const int group_chat = 2; +} \ No newline at end of file diff --git a/lib/src/enum/group_role.dart b/lib/src/enum/group_role.dart new file mode 100644 index 0000000..ec1874f --- /dev/null +++ b/lib/src/enum/group_role.dart @@ -0,0 +1,5 @@ +class GroupRole { + static const member = 0; + static const owner = 1; + static const admin = 2; +} diff --git a/lib/src/enum/message_type.dart b/lib/src/enum/message_type.dart index 6a10a75..3de1ce4 100644 --- a/lib/src/enum/message_type.dart +++ b/lib/src/enum/message_type.dart @@ -15,4 +15,6 @@ class MessageType { static const file = 105; static const accept_friend = 201; + + static const create_group = 502; } diff --git a/lib/src/listener/group_listener.dart b/lib/src/listener/group_listener.dart new file mode 100644 index 0000000..229acad --- /dev/null +++ b/lib/src/listener/group_listener.dart @@ -0,0 +1,36 @@ +import 'package:flutter_openim_sdk/flutter_openim_sdk.dart'; + +class GroupListener { + void onMemberEnter(String groupId, List list) {} + + void onMemberLeave(String groupId, GroupMembersInfo info) {} + + void onMemberInvited( + String groupId, + GroupMembersInfo opUser, + List list, + ) {} + + void onMemberKicked( + String groupId, + GroupMembersInfo opUser, + List list, + ) {} + + void onGroupCreated(String groupId) {} + + void onGroupInfoChanged(String groupId, GroupInfo info) {} + + void onReceiveJoinApplication( + String groupId, + GroupMembersInfo info, + String opReason, + ) {} + + void onApplicationProcessed( + String groupId, + GroupMembersInfo opUser, + int agreeOrReject, + String opReason, + ) {} +} diff --git a/lib/src/manager/im_conversation_manager.dart b/lib/src/manager/im_conversation_manager.dart index 2354abb..8cdaf2f 100644 --- a/lib/src/manager/im_conversation_manager.dart +++ b/lib/src/manager/im_conversation_manager.dart @@ -20,8 +20,8 @@ class ConversationManager { .then((value) => _toList(value)); } - /// sourceID 若为单聊则为userID,若为群聊则为groupID - /// sessionType 若为单聊则为1,若为群聊则为2 + /// sourceID: userID(single chat) ,groupID(group chat) + /// sessionType: 1(single chat) ,2(group chat) Future getSingleConversation( {required String sourceID, required String sessionType}) { return _channel diff --git a/lib/src/manager/im_group_manager.dart b/lib/src/manager/im_group_manager.dart index 76a435c..c6a352c 100644 --- a/lib/src/manager/im_group_manager.dart +++ b/lib/src/manager/im_group_manager.dart @@ -1,13 +1,20 @@ import 'dart:convert'; import 'package:flutter/services.dart'; +import 'package:flutter_openim_sdk/src/listener/group_listener.dart'; import 'package:flutter_openim_sdk/src/models/group_info.dart'; class GroupManager { MethodChannel _channel; + late GroupListener groupListener; GroupManager(this._channel); + void setGroupListener(GroupListener listener) { + this.groupListener = listener; + _channel.invokeMethod('setGroupListener', _buildParam({})); + } + Future> inviteUserToGroup({ required String groupId, required List uidList, @@ -21,7 +28,7 @@ class GroupManager { 'reason': reason, 'uidList': uidList, })) - .then((value) => _formatJson(value) + .then((value) => (_formatJson(value) as List) .map((e) => GroupInviteResult.fromJson(e)) .toList()); } @@ -55,7 +62,7 @@ class GroupManager { 'gid': groupId, 'uidList': uidList, })) - .then((value) => _formatJson(value) + .then((value) => (_formatJson(value) as List) .map((e) => GroupMembersInfo.fromJson(e)) .toList()); } @@ -80,22 +87,27 @@ class GroupManager { Future> getJoinedGroupList() { return _channel.invokeMethod('getJoinedGroupList', _buildParam({})).then( - (value) => - _formatJson(value).map((e) => GroupInfo.fromJson(e)).toList()); + (value) => (_formatJson(value) as List) + .map((e) => GroupInfo.fromJson(e)) + .toList()); } - Future createGroup({ - required GroupInfo groupInfo, + Future isJoinedGroup({required String gid}) { + return getJoinedGroupList() + .then((list) => list.where((e) => e.groupID == gid).length > 0); + } + + Future createGroup({ + GroupInfo? groupInfo, required List list, }) { - return _channel - .invokeMethod( - 'createGroup', - _buildParam({ - 'gInfo': groupInfo.toJson(), - 'memberList': list.map((e) => e.toJson()).toList() - })) - .then((value) => _formatJson(value)['groupID']); + return _channel.invokeMethod( + 'createGroup', + _buildParam({ + 'gInfo': groupInfo?.toJson(), + 'memberList': list.map((e) => e.toJson()).toList() + })); + /*.then((value) => _formatJson(value)['groupID'])*/ } Future setGroupInfo({ @@ -113,13 +125,15 @@ class GroupManager { }) { return _channel .invokeMethod('getGroupsInfo', _buildParam({'gidList': gidList})) - .then((value) => - _formatJson(value).map((e) => GroupInfo.fromJson(e)).toList()); + .then((value) { + List list = _formatJson(value) ?? []; + return list.map((e) => GroupInfo.fromJson(e)).toList(); + }); } Future joinGroup({ required String gid, - required String reason, + String? reason, }) { return _channel.invokeMethod( 'joinGroup', diff --git a/lib/src/manager/im_manager.dart b/lib/src/manager/im_manager.dart index 24e6056..8499d18 100644 --- a/lib/src/manager/im_manager.dart +++ b/lib/src/manager/im_manager.dart @@ -12,6 +12,7 @@ class IMManager { late OfflinePushManager offlinePushManager; late SignalingManager signalingManager; late InitSDKListener _initSDKListener; + late String logUid; IMManager(this._channel) { conversationManager = ConversationManager(_channel); @@ -55,71 +56,83 @@ class IMManager { } else if (call.method == ListenerType.groupListener) { var args = call.arguments; String type = args['type']; - Map params = args['data'] == null - ? new Map() - : new Map.from(args['data']); - - String groupID = params['groupID'] == null ? '' : params['groupID']; - String opReason = - params['opReason'] == null ? '' : params['opReason']; - bool isAgreeJoin = - params['isAgreeJoin'] == null ? false : params['isAgreeJoin']; - String customData = - params['customData'] == null ? '' : params['customData']; - - Map groupAttributeMap = - params['groupAttributeMap'] == null - ? new Map() - : new Map.from(params['groupAttributeMap']); - - List> memberListMap = - params['memberList'] == null - ? List.empty(growable: true) - : List.from(params['memberList']); - - List> groupMemberChangeInfoListMap = - params['groupMemberChangeInfoList'] == null - ? List.empty(growable: true) - : List.from(params['groupMemberChangeInfoList']); - - List> groupChangeInfoListMap = - params['groupChangeInfoList'] == null - ? List.empty(growable: true) - : List.from(params['groupChangeInfoList']); - + Map map = args['data']; switch (type) { case 'onMemberEnter': + groupManager.groupListener.onMemberEnter( + map['groupId'], + (_formatJson(map['memberList']) as List) + .map((e) => GroupMembersInfo.fromJson(e)) + .toList(), + ); break; case 'onMemberLeave': + groupManager.groupListener.onMemberLeave( + map['groupId'], + GroupMembersInfo.fromJson(_formatJson(map['member'])), + ); break; case 'onMemberInvited': + groupManager.groupListener.onMemberInvited( + map['groupId'], + GroupMembersInfo.fromJson(_formatJson(map['opUser'])), + (_formatJson(map['memberList']) as List) + .map((e) => GroupMembersInfo.fromJson(e)) + .toList(), + ); break; case 'onMemberKicked': - break; - case 'onMemberInfoChanged': + groupManager.groupListener.onMemberKicked( + map['groupId'], + GroupMembersInfo.fromJson(_formatJson(map['opUser'])), + (_formatJson(map['memberList']) as List) + .map((e) => GroupMembersInfo.fromJson(e)) + .toList(), + ); break; case 'onGroupCreated': - break; - case 'onGroupDismissed': - break; - case 'onGroupRecycled': + groupManager.groupListener.onGroupCreated( + map['groupId'], + ); break; case 'onGroupInfoChanged': + groupManager.groupListener.onGroupInfoChanged( + map['groupId'], + GroupInfo.fromJson(_formatJson(map['groupInfo'])), + ); break; case 'onReceiveJoinApplication': + groupManager.groupListener.onReceiveJoinApplication( + map['groupId'], + GroupMembersInfo.fromJson(_formatJson(map['opUser'])), + map['opReason'], + ); break; case 'onApplicationProcessed': + groupManager.groupListener.onApplicationProcessed( + map['groupId'], + GroupMembersInfo.fromJson(_formatJson(map['opUser'])), + map['agreeOrReject'], + map['opReason'], + ); break; - case 'onGrantAdministrator': - break; - case 'onRevokeAdministrator': - break; - case 'onQuitFromGroup': - break; - case 'onReceiveRESTCustomData': - break; - case 'onGroupAttributeChanged': - break; + // case 'onMemberInfoChanged': + // break; + // case 'onGroupDismissed': + // break; + // case 'onGroupRecycled': + // break; + // + // case 'onGrantAdministrator': + // break; + // case 'onRevokeAdministrator': + // break; + // case 'onQuitFromGroup': + // break; + // case 'onReceiveRESTCustomData': + // break; + // case 'onGroupAttributeChanged': + // break; } } else if (call.method == ListenerType.advancedMsgListener) { var type = call.arguments['type']; @@ -266,6 +279,7 @@ class IMManager { } Future login({required String uid, required String token}) { + this.logUid = uid; return _channel.invokeMethod( 'login', _buildParam({'uid': uid, 'token': token}), diff --git a/lib/src/manager/im_message_manager.dart b/lib/src/manager/im_message_manager.dart index 72bab02..edb9bd5 100644 --- a/lib/src/manager/im_message_manager.dart +++ b/lib/src/manager/im_message_manager.dart @@ -103,6 +103,11 @@ class MessageManager { 'markSingleMessageHasRead', _buildParam({'userID': userID})); } + Future markGroupMessageHasRead({required String groupID}) { + return _channel.invokeMethod( + 'markGroupMessageHasRead', _buildParam({'groupID': groupID})); + } + Future createTextMessage({required String text}) { return _channel .invokeMethod('createTextMessage', _buildParam({'text': text})) diff --git a/lib/src/models/conversation_info.dart b/lib/src/models/conversation_info.dart index fe125fa..d164c96 100644 --- a/lib/src/models/conversation_info.dart +++ b/lib/src/models/conversation_info.dart @@ -74,4 +74,8 @@ class ConversationInfo { data['isPinned'] = this.isPinned; return data; } + + bool get isSingleChat => conversationType == ConversationType.single_chat; + + bool get isGroupChat => conversationType == ConversationType.group_chat; } diff --git a/lib/src/models/group_info.dart b/lib/src/models/group_info.dart index a043402..aa6d4f6 100644 --- a/lib/src/models/group_info.dart +++ b/lib/src/models/group_info.dart @@ -1,5 +1,5 @@ class GroupInfo { - String? groupID; + String groupID; String? groupName; String? notification; String? introduction; @@ -9,7 +9,7 @@ class GroupInfo { int? memberCount; GroupInfo( - {this.groupID, + {required this.groupID, this.groupName, this.notification, this.introduction, @@ -18,8 +18,8 @@ class GroupInfo { this.createTime, this.memberCount}); - GroupInfo.fromJson(Map json) { - groupID = json['groupID']; + GroupInfo.fromJson(Map json): groupID = json['groupID'] { + /*groupID = json['groupID'];*/ groupName = json['groupName']; notification = json['notification']; introduction = json['introduction']; @@ -126,7 +126,7 @@ class GroupInviteResult { class GroupMemberRole { String? uid; - int? setRole; //0普通成员,2管理员 + int? setRole; GroupMemberRole({this.uid, this.setRole}); diff --git a/lib/src/models/user_info.dart b/lib/src/models/user_info.dart index f87b953..7f65657 100644 --- a/lib/src/models/user_info.dart +++ b/lib/src/models/user_info.dart @@ -2,16 +2,16 @@ class UserInfo { String uid; String? name; String? icon; - int? gender; // 0 未知,1 男,2 女 + int? gender; String? mobile; String? birth; String? email; String? ex; String? comment; - int? isInBlackList; // 0 不在黑名单,1 在黑名单 + int? isInBlackList; String? reqMessage; String? applyTime; - int? flag; // //0请求添加好友,1同意添加好友,-1拒绝添加好友 + int? flag; UserInfo( {required this.uid, @@ -61,5 +61,25 @@ class UserInfo { return data; } - String get nickname => comment ?? name ?? uid; + String getShowName() { + if (null != comment && comment!.trim().isNotEmpty) { + return comment!; + } else if (null != name && name!.trim().isNotEmpty) { + return name!; + } + return uid; + } + + bool get isMan => gender == 1; + + bool get isWoman => gender == 2; + + /// blacklist + bool get isBlocked => isInBlackList == 1; + + /// friend application + bool get isAgreed => flag == 1; + + /// friend application + bool get isRejected => flag == -1; } diff --git a/lib/src/openim.dart b/lib/src/openim.dart index fe165a2..0c0063f 100644 --- a/lib/src/openim.dart +++ b/lib/src/openim.dart @@ -6,4 +6,6 @@ class OpenIM { const MethodChannel('flutter_openim_sdk'); static IMManager iMManager = IMManager(_channel); + + OpenIM._(); }