diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..41cc7d8
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,3 @@
+## 0.0.1
+
+* TODO: Describe initial release.
diff --git a/LICENSE b/LICENSE
index 261eeb9..ba75c69 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,201 +1 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
+TODO: Add your license here.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..9146470
--- /dev/null
+++ b/README.md
@@ -0,0 +1,15 @@
+# flutter_openim_sdk
+
+A new Flutter project.
+
+## Getting Started
+
+This project is a starting point for a Flutter
+[plug-in package](https://flutter.dev/developing-packages/),
+a specialized package that includes platform-specific implementation code for
+Android and/or iOS.
+
+For help getting started with Flutter, view our
+[online documentation](https://flutter.dev/docs), which offers tutorials,
+samples, guidance on mobile development, and a full API reference.
+
diff --git a/android/.gitignore b/android/.gitignore
new file mode 100644
index 0000000..c6cbe56
--- /dev/null
+++ b/android/.gitignore
@@ -0,0 +1,8 @@
+*.iml
+.gradle
+/local.properties
+/.idea/workspace.xml
+/.idea/libraries
+.DS_Store
+/build
+/captures
diff --git a/android/build.gradle b/android/build.gradle
new file mode 100644
index 0000000..34ff708
--- /dev/null
+++ b/android/build.gradle
@@ -0,0 +1,52 @@
+group 'io.openim.flutter_openim_sdk'
+version '1.0'
+
+buildscript {
+ repositories {
+ maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
+ maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' }
+ maven { url 'http://maven.aliyun.com/nexus/content/repositories/google' }
+ maven { url 'http://maven.aliyun.com/nexus/content/repositories/gradle-plugin' }
+ google()
+ maven {
+ url 'http://127.0.0.1:8081/repository/maven-releases/' //这个路径就是Browse下maven-release右边有一个copy按钮,复制出来的。
+ }
+ mavenCentral()
+ }
+
+ dependencies {
+ classpath 'com.android.tools.build:gradle:3.5.1'
+ }
+}
+
+rootProject.allprojects {
+ repositories {
+ maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
+ maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' }
+ maven { url 'http://maven.aliyun.com/nexus/content/repositories/google' }
+ maven { url 'http://maven.aliyun.com/nexus/content/repositories/gradle-plugin' }
+ google()
+ maven {
+ url 'http://127.0.0.1:8081/repository/maven-releases' //这个路径就是Browse下maven-release右边有一个copy按钮,复制出来的。
+ }
+ mavenCentral()
+ }
+}
+
+apply plugin: 'com.android.library'
+
+android {
+ compileSdkVersion 30
+
+ defaultConfig {
+ minSdkVersion 21
+ }
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_8
+ targetCompatibility JavaVersion.VERSION_1_8
+ }
+}
+dependencies {
+ implementation 'com.alibaba:fastjson:1.1.72.android'
+ implementation 'io.openim:localsdk:1.1.4@aar'//graoupId:artifactId:version@aar
+}
\ No newline at end of file
diff --git a/android/gradle.properties b/android/gradle.properties
new file mode 100644
index 0000000..be9024e
--- /dev/null
+++ b/android/gradle.properties
@@ -0,0 +1,4 @@
+org.gradle.jvmargs=-Xmx1536M
+android.useAndroidX=true
+android.enableJetifier=true
+android.enableDexingArtifactTransform=false
\ No newline at end of file
diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..3c9d085
--- /dev/null
+++ b/android/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,5 @@
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
diff --git a/android/settings.gradle b/android/settings.gradle
new file mode 100644
index 0000000..dc38937
--- /dev/null
+++ b/android/settings.gradle
@@ -0,0 +1 @@
+rootProject.name = 'flutter_openim_sdk'
diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..20bc59f
--- /dev/null
+++ b/android/src/main/AndroidManifest.xml
@@ -0,0 +1,3 @@
+
+
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
new file mode 100644
index 0000000..62bdc3e
--- /dev/null
+++ b/android/src/main/java/io/openim/flutter_openim_sdk/FlutterOpenimSdkPlugin.java
@@ -0,0 +1,82 @@
+package io.openim.flutter_openim_sdk;
+
+import android.content.Context;
+
+import androidx.annotation.NonNull;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import io.flutter.embedding.engine.plugins.FlutterPlugin;
+import io.flutter.plugin.common.EventChannel;
+import io.flutter.plugin.common.MethodCall;
+import io.flutter.plugin.common.MethodChannel;
+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.IMManager;
+import io.openim.flutter_openim_sdk.manager.MessageManager;
+import io.openim.flutter_openim_sdk.util.CommonUtil;
+
+
+/**
+ * FlutterOpenimSdkPlugin
+ */
+public class FlutterOpenimSdkPlugin implements FlutterPlugin, MethodCallHandler {
+ /// The MethodChannel that will the communication between Flutter and native Android
+ ///
+ /// This local reference serves to register the plugin with the Flutter Engine and unregister it
+ /// when the Flutter Engine is detached from the Activity
+ public static MethodChannel channel;
+ private static IMManager imManager;
+ private static FriendshipManager friendshipManager;
+ private static MessageManager messageManager;
+ private static ConversationManager conversationManager;
+
+ public FlutterOpenimSdkPlugin() {
+ }
+
+ private FlutterOpenimSdkPlugin(Context context, MethodChannel channel) {
+ FlutterOpenimSdkPlugin.imManager = new IMManager(channel);
+ FlutterOpenimSdkPlugin.friendshipManager = new FriendshipManager(channel);
+ FlutterOpenimSdkPlugin.messageManager = new MessageManager(channel);
+ FlutterOpenimSdkPlugin.conversationManager = new ConversationManager(channel);
+ }
+
+ @Override
+ public void onAttachedToEngine(@NonNull FlutterPluginBinding flutterPluginBinding) {
+ channel = new MethodChannel(flutterPluginBinding.getBinaryMessenger(), "flutter_openim_sdk");
+ channel.setMethodCallHandler(new FlutterOpenimSdkPlugin(flutterPluginBinding.getApplicationContext(), channel));
+// channel.setMethodCallHandler(this);
+ }
+
+ @Override
+ public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
+ parse(call, result);
+ }
+
+ @Override
+ public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {
+ channel.setMethodCallHandler(null);
+ }
+
+ void parse(@NonNull MethodCall call, @NonNull Result result) {
+ try {
+ String managerName = CommonUtil.getParamValue(call, "ManagerName");
+ Field field = FlutterOpenimSdkPlugin.class.getDeclaredField(managerName);
+ Method method = field.get(new Object()).getClass().getDeclaredMethod(call.method, MethodCall.class, Result.class);
+ System.out.println("flutter call native { class:" + managerName + ", method:" + method.getName() + " }");
+ method.invoke(field.get(new Object()), call, result);
+ } catch (NoSuchFieldException e) {
+ e.printStackTrace();
+ } catch (NoSuchMethodException e) {
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ }
+ }
+}
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/AdvancedMsgListenerImpl.java
new file mode 100644
index 0000000..80c8b70
--- /dev/null
+++ b/android/src/main/java/io/openim/flutter_openim_sdk/listener/AdvancedMsgListenerImpl.java
@@ -0,0 +1,36 @@
+package io.openim.flutter_openim_sdk.listener;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import io.flutter.plugin.common.MethodChannel;
+import io.openim.flutter_openim_sdk.util.CommonUtil;
+import open_im_sdk.OnAdvancedMsgListener;
+
+public class AdvancedMsgListenerImpl implements OnAdvancedMsgListener {
+ final MethodChannel channel;
+ final Map values = new HashMap<>();
+
+ public AdvancedMsgListenerImpl(MethodChannel channel, String id) {
+ this.channel = channel;
+ this.values.put("id", id);
+ }
+
+ @Override
+ public void onRecvC2CReadReceipt(String s) {
+ values.put("message", s);
+ CommonUtil.emitEvent(channel, "advancedMsgListener", "onRecvC2CReadReceipt", values);
+ }
+
+ @Override
+ public void onRecvMessageRevoked(String s) {
+ values.put("message", s);
+ CommonUtil.emitEvent(channel, "advancedMsgListener", "onRecvMessageRevoked", values);
+ }
+
+ @Override
+ public void onRecvNewMessage(String s) {
+ values.put("message", s);
+ CommonUtil.emitEvent(channel, "advancedMsgListener", "onRecvNewMessage", values);
+ }
+}
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/BaseImpl.java
new file mode 100644
index 0000000..f3a8f15
--- /dev/null
+++ b/android/src/main/java/io/openim/flutter_openim_sdk/listener/BaseImpl.java
@@ -0,0 +1,27 @@
+package io.openim.flutter_openim_sdk.listener;
+
+
+import io.flutter.plugin.common.MethodChannel;
+import io.openim.flutter_openim_sdk.util.CommonUtil;
+import open_im_sdk.Base;
+
+public class BaseImpl implements Base {
+
+ MethodChannel.Result result;
+
+ public BaseImpl(MethodChannel.Result result) {
+ this.result = result;
+ }
+
+ @Override
+ public void onError(long l, String s) {
+ System.out.println("BaseImpl:" + s);
+ CommonUtil.runMainThreadReturnError(result, l, s, null);
+ }
+
+ @Override
+ public void onSuccess(String s) {
+ System.out.println("BaseImpl:" + s);
+ CommonUtil.runMainThreadReturn(result, s);
+ }
+}
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/ConversationListenerImpl.java
new file mode 100644
index 0000000..fea99c6
--- /dev/null
+++ b/android/src/main/java/io/openim/flutter_openim_sdk/listener/ConversationListenerImpl.java
@@ -0,0 +1,43 @@
+package io.openim.flutter_openim_sdk.listener;
+
+import io.flutter.plugin.common.MethodChannel;
+import io.openim.flutter_openim_sdk.util.CommonUtil;
+import open_im_sdk.OnConversationListener;
+
+public class ConversationListenerImpl implements OnConversationListener {
+ private final MethodChannel channel;
+
+ public ConversationListenerImpl(MethodChannel channel) {
+ this.channel = channel;
+ }
+
+ @Override
+ public void onConversationChanged(String s) {
+ CommonUtil.emitEvent(channel, "conversationListener", "onConversationChanged", s);
+ }
+
+ @Override
+ public void onNewConversation(String s) {
+ CommonUtil.emitEvent(channel, "conversationListener", "onNewConversation", s);
+ }
+
+ @Override
+ public void onSyncServerFailed() {
+ CommonUtil.emitEvent(channel, "conversationListener", "onSyncServerFailed", null);
+ }
+
+ @Override
+ public void onSyncServerFinish() {
+ CommonUtil.emitEvent(channel, "conversationListener", "onSyncServerFinish", null);
+ }
+
+ @Override
+ public void onSyncServerStart() {
+ CommonUtil.emitEvent(channel, "conversationListener", "onSyncServerStart", null);
+ }
+
+ @Override
+ public void onTotalUnreadMessageCountChanged(int i) {
+ CommonUtil.emitEvent(channel, "conversationListener", "onTotalUnreadMessageCountChanged", i);
+ }
+}
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/FriendshipListenerImpl.java
new file mode 100644
index 0000000..cca93b6
--- /dev/null
+++ b/android/src/main/java/io/openim/flutter_openim_sdk/listener/FriendshipListenerImpl.java
@@ -0,0 +1,58 @@
+package io.openim.flutter_openim_sdk.listener;
+
+import io.flutter.plugin.common.MethodChannel;
+import io.openim.flutter_openim_sdk.util.CommonUtil;
+import open_im_sdk.OnFriendshipListener;
+
+public class FriendshipListenerImpl implements OnFriendshipListener {
+ private final MethodChannel channel;
+
+ public FriendshipListenerImpl(MethodChannel channel) {
+ this.channel = channel;
+ }
+
+ @Override
+ public void onBlackListAdd(String s) {
+ CommonUtil.emitEvent(channel, "friendListener", "onBlackListAdd", s);
+ }
+
+ @Override
+ public void onBlackListDeleted(String s) {
+ CommonUtil.emitEvent(channel, "friendListener", "onBlackListDeleted", s);
+ }
+
+ @Override
+ public void onFriendApplicationListAccept(String s) {
+ CommonUtil.emitEvent(channel, "friendListener", "onFriendApplicationListAccept", s);
+ }
+
+ @Override
+ public void onFriendApplicationListAdded(String s) {
+ CommonUtil.emitEvent(channel, "friendListener", "onFriendApplicationListAdded", s);
+ }
+
+ @Override
+ public void onFriendApplicationListDeleted(String s) {
+ CommonUtil.emitEvent(channel, "friendListener", "onFriendApplicationListDeleted", s);
+ }
+
+ @Override
+ public void onFriendApplicationListReject(String s) {
+ CommonUtil.emitEvent(channel, "friendListener", "onFriendApplicationListReject", s);
+ }
+
+ @Override
+ public void onFriendInfoChanged(String s) {
+ CommonUtil.emitEvent(channel, "friendListener", "onFriendInfoChanged", s);
+ }
+
+ @Override
+ public void onFriendListAdded(String s) {
+ CommonUtil.emitEvent(channel, "friendListener", "onFriendListAdded", s);
+ }
+
+ @Override
+ public void onFriendListDeleted(String s) {
+ CommonUtil.emitEvent(channel, "friendListener", "onFriendListDeleted", s);
+ }
+}
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/SDKListenerImpl.java
new file mode 100644
index 0000000..fc775e7
--- /dev/null
+++ b/android/src/main/java/io/openim/flutter_openim_sdk/listener/SDKListenerImpl.java
@@ -0,0 +1,44 @@
+package io.openim.flutter_openim_sdk.listener;
+
+
+import io.flutter.plugin.common.MethodChannel;
+import io.openim.flutter_openim_sdk.util.CommonUtil;
+import open_im_sdk.IMSDKListener;
+
+public class SDKListenerImpl implements IMSDKListener {
+ final private MethodChannel channel;
+
+ public SDKListenerImpl(MethodChannel channel) {
+ this.channel = channel;
+ }
+
+ @Override
+ public void onConnectFailed(long l, String s) {
+ CommonUtil.emitEvent(channel, "initSDKListener", "onConnectFailed", l, s, null);
+ }
+
+ @Override
+ public void onConnectSuccess() {
+ CommonUtil.emitEvent(channel, "initSDKListener", "onConnectSuccess", null);
+ }
+
+ @Override
+ public void onConnecting() {
+ CommonUtil.emitEvent(channel, "initSDKListener", "onConnecting", null);
+ }
+
+ @Override
+ public void onKickedOffline() {
+ CommonUtil.emitEvent(channel, "initSDKListener", "onKickedOffline", null);
+ }
+
+ @Override
+ public void onSelfInfoUpdated(String s) {
+ CommonUtil.emitEvent(channel, "initSDKListener", "onSelfInfoUpdated", s);
+ }
+
+ @Override
+ public void onUserTokenExpired() {
+ CommonUtil.emitEvent(channel, "initSDKListener", "onUserTokenExpired", null);
+ }
+}
diff --git a/android/src/main/java/io/openim/flutter_openim_sdk/listener/SendMsgProgressListener.java b/android/src/main/java/io/openim/flutter_openim_sdk/listener/SendMsgProgressListener.java
new file mode 100644
index 0000000..17ad4de
--- /dev/null
+++ b/android/src/main/java/io/openim/flutter_openim_sdk/listener/SendMsgProgressListener.java
@@ -0,0 +1,45 @@
+package io.openim.flutter_openim_sdk.listener;
+
+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.util.CommonUtil;
+import open_im_sdk.SendMsgCallBack;
+
+public class SendMsgProgressListener implements SendMsgCallBack {
+
+
+ public SendMsgProgressListener(MethodChannel.Result result, MethodChannel channel, MethodCall call) {
+ this.result = result;
+ this.channel = channel;
+ this.call = call;
+ }
+
+ final private MethodChannel.Result result;
+ final private MethodChannel channel;
+ final private MethodCall call;
+ final Map values = new HashMap<>();
+
+
+ @Override
+ public void onError(long l, String s) {
+ System.out.println("=================onError============" + s);
+ CommonUtil.runMainThreadReturnError(result, l, s, null);
+ }
+
+ @Override
+ public void onProgress(long l) {
+ System.out.println("================onProgress============" + l);
+ values.put("clientMsgID", CommonUtil.getSendMessageClientMsgID(call));
+ values.put("progress", l);
+ CommonUtil.emitEvent(channel, "messageProgressListener", "onProgress", values);
+ }
+
+ @Override
+ public void onSuccess(String s) {
+ System.out.println("=================onSuccess============" + s);
+ CommonUtil.runMainThreadReturn(result, 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
new file mode 100644
index 0000000..0276a50
--- /dev/null
+++ b/android/src/main/java/io/openim/flutter_openim_sdk/manager/ConversationManager.java
@@ -0,0 +1,48 @@
+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.util.CommonUtil;
+import open_im_sdk.Open_im_sdk;
+
+public class ConversationManager {
+ final private MethodChannel channel;
+
+ public ConversationManager(MethodChannel channel) {
+ this.channel = channel;
+ }
+
+ public void setConversationListener(MethodCall methodCall, MethodChannel.Result result) {
+ Open_im_sdk.setConversationListener(new ConversationListenerImpl(channel));
+ }
+
+ public void getAllConversationList(MethodCall methodCall, MethodChannel.Result result) {
+ Open_im_sdk.getAllConversationList(new BaseImpl(result));
+ }
+
+ public void getOneConversation(MethodCall methodCall, MethodChannel.Result result) {
+ Open_im_sdk.getOneConversation(CommonUtil.getConversationId(methodCall), new BaseImpl(result));
+ }
+
+ public void getMultipleConversation(MethodCall methodCall, MethodChannel.Result result) {
+ Open_im_sdk.getMultipleConversation(CommonUtil.getConversationIds(methodCall), new BaseImpl(result));
+ }
+
+ public void deleteConversation(MethodCall methodCall, MethodChannel.Result result) {
+ Open_im_sdk.deleteConversation(CommonUtil.getConversationId(methodCall), new BaseImpl(result));
+ }
+
+ public void setConversationDraft(MethodCall methodCall, MethodChannel.Result result) {
+ Open_im_sdk.setConversationDraft(CommonUtil.getConversationId(methodCall), CommonUtil.getConversationDraft(methodCall), new BaseImpl(result));
+ }
+
+ public void pinConversation(MethodCall methodCall, MethodChannel.Result result) {
+ Open_im_sdk.pinConversation(CommonUtil.getConversationId(methodCall), CommonUtil.isPinnedConversation(methodCall), new BaseImpl(result));
+ }
+
+ public void getTotalUnreadMsgCount(MethodCall methodCall, MethodChannel.Result result) {
+ Open_im_sdk.getTotalUnreadMsgCount(new BaseImpl(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
new file mode 100644
index 0000000..fc6d90b
--- /dev/null
+++ b/android/src/main/java/io/openim/flutter_openim_sdk/manager/FriendshipManager.java
@@ -0,0 +1,81 @@
+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.util.CommonUtil;
+import open_im_sdk.Open_im_sdk;
+
+public class FriendshipManager {
+
+ final private MethodChannel channel;
+
+ public FriendshipManager(MethodChannel channel) {
+ this.channel = channel;
+ }
+
+ public void setFriendListener(MethodCall methodCall, MethodChannel.Result result) {
+ Open_im_sdk.setFriendListener(new FriendshipListenerImpl(channel));
+ }
+
+ public void getFriendsInfo(MethodCall methodCall, MethodChannel.Result result) {
+ Open_im_sdk.getFriendsInfo(new BaseImpl(result), CommonUtil.getSDKJsonParam(methodCall));
+ }
+
+ public void addFriend(MethodCall methodCall, MethodChannel.Result result) {
+ Open_im_sdk.addFriend(new BaseImpl(result), CommonUtil.getSDKJsonParam(methodCall));
+ }
+
+ public void getFriendApplicationList(MethodCall methodCall, MethodChannel.Result result) {
+ Open_im_sdk.getFriendApplicationList(new BaseImpl(result));
+ }
+
+ public void getFriendList(MethodCall methodCall, MethodChannel.Result result) {
+ Open_im_sdk.getFriendList(new BaseImpl(result));
+ }
+
+ public void setFriendInfo(MethodCall methodCall, MethodChannel.Result result) {
+ Open_im_sdk.setFriendInfo(CommonUtil.getSDKJsonParam(methodCall), new BaseImpl(result));
+ }
+
+ public void addToBlackList(MethodCall methodCall, MethodChannel.Result result) {
+ Open_im_sdk.addToBlackList(new BaseImpl(result), CommonUtil.getSDKJsonParam(methodCall));
+ }
+
+ public void getBlackList(MethodCall methodCall, MethodChannel.Result result) {
+ Open_im_sdk.getBlackList(new BaseImpl(result));
+ }
+
+ public void deleteFromBlackList(MethodCall methodCall, MethodChannel.Result result) {
+ Open_im_sdk.deleteFromBlackList(new BaseImpl(result), CommonUtil.getSDKJsonParam(methodCall));
+ }
+
+ public void checkFriend(MethodCall methodCall, MethodChannel.Result result) {
+ Open_im_sdk.checkFriend(new BaseImpl(result), CommonUtil.getSDKJsonParam(methodCall));
+ }
+
+ public void deleteFromFriendList(MethodCall methodCall, MethodChannel.Result result) {
+ Open_im_sdk.deleteFromFriendList(CommonUtil.getSDKJsonParam(methodCall), new BaseImpl(result));
+ }
+
+ public void acceptFriendApplication(MethodCall methodCall, MethodChannel.Result result) {
+ Open_im_sdk.acceptFriendApplication(new BaseImpl(result), CommonUtil.getSDKJsonParam(methodCall));
+ }
+
+ public void refuseFriendApplication(MethodCall methodCall, MethodChannel.Result result) {
+ Open_im_sdk.refuseFriendApplication(new BaseImpl(result), CommonUtil.getSDKJsonParam(methodCall));
+ }
+
+ public void forceSyncFriendApplication(MethodCall methodCall, MethodChannel.Result result) {
+ Open_im_sdk.forceSyncFriendApplication();
+ }
+
+ public void forceSyncFriend(MethodCall methodCall, MethodChannel.Result result) {
+ Open_im_sdk.forceSyncFriend();
+ }
+
+ public void forceSyncBlackList(MethodCall methodCall, MethodChannel.Result result) {
+ Open_im_sdk.forceSyncBlackList();
+ }
+}
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
new file mode 100644
index 0000000..b47ab80
--- /dev/null
+++ b/android/src/main/java/io/openim/flutter_openim_sdk/manager/IMManager.java
@@ -0,0 +1,50 @@
+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.util.CommonUtil;
+import open_im_sdk.Open_im_sdk;
+
+public class IMManager {
+
+ final private MethodChannel channel;
+
+ public IMManager(MethodChannel channel) {
+ this.channel = channel;
+ }
+
+ public void initSDK(MethodCall methodCall, MethodChannel.Result result) {
+ Open_im_sdk.initSDK(CommonUtil.getSDKJsonParam(methodCall), new SDKListenerImpl(channel));
+ 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));
+ }
+
+ public void logout(MethodCall methodCall, MethodChannel.Result result) {
+ Open_im_sdk.logout(new BaseImpl(result));
+ }
+
+ public void getLoginStatus(MethodCall methodCall, MethodChannel.Result result) {
+ CommonUtil.runMainThreadReturn(result, Open_im_sdk.getLoginStatus());
+ }
+
+ public void getLoginUid(MethodCall methodCall, MethodChannel.Result result) {
+ CommonUtil.runMainThreadReturn(result, Open_im_sdk.getLoginUid());
+ }
+
+ public void getUsersInfo(MethodCall methodCall, MethodChannel.Result result) {
+ Open_im_sdk.getUsersInfo(CommonUtil.getSDKJsonParam(methodCall), new BaseImpl(result));
+ }
+
+ public void setSelfInfo(MethodCall methodCall, MethodChannel.Result result) {
+ Open_im_sdk.setSelfInfo(CommonUtil.getSDKJsonParam(methodCall), new BaseImpl(result));
+ }
+
+ public void forceSyncLoginUerInfo(MethodCall methodCall, MethodChannel.Result result) {
+ Open_im_sdk.forceSyncLoginUerInfo();
+ }
+}
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
new file mode 100644
index 0000000..f45bef1
--- /dev/null
+++ b/android/src/main/java/io/openim/flutter_openim_sdk/manager/MessageManager.java
@@ -0,0 +1,108 @@
+package io.openim.flutter_openim_sdk.manager;
+
+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.SendMsgProgressListener;
+import io.openim.flutter_openim_sdk.util.CommonUtil;
+import open_im_sdk.OnAdvancedMsgListener;
+import open_im_sdk.Open_im_sdk;
+
+
+public class MessageManager {
+ private final static String KEY_ID = "id";
+ private final MethodChannel channel;
+ private final static Map listeners = new HashMap<>();
+
+
+ public MessageManager(MethodChannel channel) {
+ this.channel = channel;
+ }
+
+ public void addAdvancedMsgListener(MethodCall methodCall, MethodChannel.Result result) {
+ String key = methodCall.argument(KEY_ID);
+ if (!listeners.containsKey(key)) {
+ AdvancedMsgListenerImpl listener = new AdvancedMsgListenerImpl(channel, key);
+ listeners.put(methodCall.argument(KEY_ID), listener);
+ Open_im_sdk.addAdvancedMsgListener(listener);
+ System.out.println("=================add msg listener======" + listener);
+ }
+ }
+
+ public void removeAdvancedMsgListener(MethodCall methodCall, MethodChannel.Result result) {
+ String key = methodCall.argument(KEY_ID);
+ OnAdvancedMsgListener listener = listeners.remove(key);
+ Open_im_sdk.removeAdvancedMsgListener(listener);
+ System.out.println("=================remove msg listener======" + listener);
+ }
+
+ public void sendMessage(MethodCall methodCall, MethodChannel.Result result) {
+ SendMsgProgressListener listener = new SendMsgProgressListener(result, channel, methodCall);
+ System.out.println("===============sendMessage===============");
+ 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));
+ }
+
+ public void revokeMessage(MethodCall methodCall, MethodChannel.Result result) {
+ Open_im_sdk.revokeMessage(new BaseImpl(result), CommonUtil.getSDKJsonParam(methodCall));
+ }
+
+ public void deleteMessageFromLocalStorage(MethodCall methodCall, MethodChannel.Result result) {
+ Open_im_sdk.deleteMessageFromLocalStorage(new BaseImpl(result), CommonUtil.getSDKJsonParam(methodCall));
+ }
+
+ public void deleteMessages(MethodCall methodCall, MethodChannel.Result result) {
+// Open_im_sdk.deleteMessages(new BaseImpl(result), CommonUtil.getSDKJsonParam(methodCall));
+ }
+
+ public void insertSingleMessageToLocalStorage(MethodCall methodCall, MethodChannel.Result result) {
+ Open_im_sdk.insertSingleMessageToLocalStorage(new BaseImpl(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));
+ }
+
+ public void markSingleMessageHasRead(MethodCall methodCall, MethodChannel.Result result) {
+ Open_im_sdk.markSingleMessageHasRead(new BaseImpl(result), CommonUtil.getSingleMessageUserid(methodCall));
+ }
+
+ public void createTextMessage(MethodCall methodCall, MethodChannel.Result result) {
+ 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)));
+ }
+
+ public void createImageMessage(MethodCall methodCall, MethodChannel.Result result) {
+ 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)));
+ }
+
+ 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)));
+ }
+
+ public void createFileMessage(MethodCall methodCall, MethodChannel.Result result) {
+ 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)));
+ }
+
+ public void createForwardMessage(MethodCall methodCall, MethodChannel.Result result) {
+ 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
new file mode 100644
index 0000000..1970761
--- /dev/null
+++ b/android/src/main/java/io/openim/flutter_openim_sdk/util/CommonUtil.java
@@ -0,0 +1,286 @@
+package io.openim.flutter_openim_sdk.util;
+
+import android.os.Handler;
+import android.os.Looper;
+
+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.FlutterOpenimSdkPlugin;
+
+
+public class CommonUtil {
+ /**
+ * 主线程处理器
+ */
+ private final static Handler MAIN_HANDLER = new Handler(Looper.getMainLooper());
+
+ public static T getParamValue(MethodCall methodCall, String param) {
+ return methodCall.argument(param);
+ }
+
+ public static String getSDKJsonParam(MethodCall methodCall, String key) {
+ return JsonUtil.toString(methodCall.argument(key));
+ }
+
+ public static String getSDKJsonParam(MethodCall methodCall) {
+ return JsonUtil.toString(methodCall.arguments);
+ }
+
+ public static void runMainThreadReturn(final MethodChannel.Result result, final Object param) {
+ MAIN_HANDLER.post(new Runnable() {
+ @Override
+ public void run() {
+ result.success(param);
+ }
+ });
+ }
+
+ public static void runMainThread(Runnable runnable) {
+ MAIN_HANDLER.post(runnable);
+ }
+
+ /**
+ * 运行主线程返回错误结果执行
+ *
+ * @param result 返回结果对象
+ * @param errorCode 错误码
+ * @param errorMessage 错误信息
+ * @param errorDetails 错误内容
+ */
+ public static void runMainThreadReturnError(final MethodChannel.Result result, final String errorCode, final String errorMessage, final Object errorDetails) {
+ MAIN_HANDLER.post(new Runnable() {
+ @Override
+ public void run() {
+ result.error(errorCode, errorMessage, errorDetails);
+ }
+ });
+ }
+
+ public static void runMainThreadReturnError(final MethodChannel.Result result, final long errorCode, final String errorMessage, final Object errorDetails) {
+ runMainThreadReturnError(result, String.valueOf(errorCode), errorMessage, errorDetails);
+ }
+
+/*
+
+ public static void returnError(final MethodChannel.Result result, int i, String s) {
+ HashMap err = new HashMap();
+ err.put("code", i);
+ err.put("desc", s);
+ result.success(err);
+ }
+
+ public static void returnError(final MethodChannel.Result result, int i, String s, HashMap data) {
+ HashMap err = new HashMap();
+ err.put("code", i);
+ err.put("desc", s);
+ err.put("data", data);
+ result.success(err);
+ }
+
+ public static void returnSuccess(final MethodChannel.Result result, T data) {
+ HashMap succ = new HashMap();
+ succ.put("code", 0);
+ succ.put("desc", "ok");
+ succ.put("data", data);
+ result.success(succ);
+ }
+*/
+
+
+ public static void emitEvent(MethodChannel channel, String method, String type, Long errCode, String errMsg, T data) {
+ runMainThread(new Runnable() {
+ @Override
+ public void run() {
+ HashMap res = new HashMap();
+// if (null != type) {
+ res.put("type", type);
+// }
+ if (null != data) {
+ res.put("data", data);
+ }
+ if (null != errCode) {
+ res.put("errCode", errCode);
+ }
+ if (null != errMsg) {
+ res.put("errMsg", errMsg);
+ }
+ System.out.println("native call flutter { method:" + method + ", type:" + type + " }");
+ FlutterOpenimSdkPlugin.channel.invokeMethod(method, res);
+ }
+ });
+ }
+
+ public static void emitEvent(MethodChannel channel, String method, String type, T data) {
+ emitEvent(channel, method, type, null, null, data);
+ }
+
+
+ ///////////////////////////////////////
+ //////////////////////////////////////
+ public static String getUid(MethodCall methodCall) {
+ return getParamValue(methodCall, KEY_LOGIN_UID);
+ }
+
+ public static String getToken(MethodCall methodCall) {
+ return getParamValue(methodCall, KEY_LOGIN_TOKEN);
+ }
+
+ public static String getMessageText(MethodCall methodCall) {
+ return getParamValue(methodCall, KEY_TEXT);
+ }
+
+ public static String getAtUserList(MethodCall methodCall) {
+// return methodCall.argument(KEY_AT_USER_LIST);
+ return getSDKJsonParam(methodCall, KEY_AT_USER_LIST);
+ }
+
+ public static String getImagePath(MethodCall methodCall) {
+ return getParamValue(methodCall, KEY_IMAGE_PATH);
+ }
+
+ public static String getSoundPath(MethodCall methodCall) {
+ return getParamValue(methodCall, KEY_SOUND_PATH);
+ }
+
+ public static long getSoundDuration(MethodCall methodCall) {
+ Integer i = getParamValue(methodCall, KEY_SOUND_DURATION);
+ return Long.valueOf(i);
+ }
+
+ public static String getVideoPath(MethodCall methodCall) {
+ return getParamValue(methodCall, KEY_VIDEO_PATH);
+ }
+
+ public static String getVideoType(MethodCall methodCall) {
+ return getParamValue(methodCall, KEY_VIDEO_TYPE);
+ }
+
+ public static long getVideoDuration(MethodCall methodCall) {
+ Integer i = getParamValue(methodCall, KEY_VIDEO_DURATION);
+ return Long.valueOf(i);
+ }
+
+ public static String getVideoSnapshotPath(MethodCall methodCall) {
+ return getParamValue(methodCall, KEY_VIDEO_SNAPSHOT_PATH);
+ }
+
+ public static String getFilePath(MethodCall methodCall) {
+ return getParamValue(methodCall, KEY_FILE_PATH);
+ }
+
+ public static String getFileName(MethodCall methodCall) {
+ return getParamValue(methodCall, KEY_FILE_NAME);
+ }
+
+ public static String getMergerMessageList(MethodCall methodCall) {
+// return methodCall.argument(KEY_MERGER_MESSAGE_LIST);
+ return getSDKJsonParam(methodCall, KEY_MERGER_MESSAGE_LIST);
+ }
+
+ public static String getMergerMessageTitle(MethodCall methodCall) {
+ return getParamValue(methodCall, KEY_MERGER_MESSAGE_TITLE);
+ }
+
+ public static String getSummaryList(MethodCall methodCall) {
+// return methodCall.argument(KEY_SUMMARY_LIST);
+ return getSDKJsonParam(methodCall, KEY_SUMMARY_LIST);
+ }
+
+ public static String getForwardMessage(MethodCall methodCall) {
+// return methodCall.argument(KEY_FORWARD_MESSAGE);
+ return getSDKJsonParam(methodCall, KEY_FORWARD_MESSAGE);
+ }
+
+ public static String getSendMessageContent(MethodCall methodCall) {
+ return getSDKJsonParam(methodCall, KEY_SEND_MESSAGE_CONTENT);
+ }
+
+ public static Object getSendMessageClientMsgID(MethodCall methodCall) {
+ Map map = getParamValue(methodCall, KEY_SEND_MESSAGE_CONTENT);
+ return map.get(KEY_SEND_MESSAGE_CONTENT_CLIENT_ID);
+ }
+
+ public static String getSendMessageReceiver(MethodCall methodCall) {
+ return getParamValue(methodCall, KEY_SEND_MESSAGE_RECEIVER);
+ }
+
+ public static String geSendMessageGroupId(MethodCall methodCall) {
+ return getParamValue(methodCall, KEY_SEND_MESSAGE_GROUP_ID);
+ }
+
+ public static boolean getSendMessageOnlineOnly(MethodCall methodCall) {
+ return getParamValue(methodCall, KEY_SEND_MESSAGE_ONLINE_ONLY);
+ }
+
+ public static String getSingleMessageContent(MethodCall methodCall) {
+ return getParamValue(methodCall, KEY_SINGLE_MESSAGE_CONTENT);
+ }
+
+ public static String getSingleMessageUserid(MethodCall methodCall) {
+ return getParamValue(methodCall, KEY_SINGLE_MESSAGE_USERID);
+ }
+
+ public static String getSingleMessageSender(MethodCall methodCall) {
+ return getParamValue(methodCall, KEY_SINGLE_MESSAGE_SENDER);
+ }
+
+ public static String getFindMessageIds(MethodCall methodCall) {
+ return getSDKJsonParam(methodCall, KEY_FIND_MESSAGE_IDS);
+ }
+
+ public static String getConversationId(MethodCall methodCall) {
+ return getParamValue(methodCall, KEY_CONVERSATION_ID);
+ }
+
+ public static String getConversationIds(MethodCall methodCall) {
+ return getSDKJsonParam(methodCall, KEY_CONVERSATION_IDS);
+ }
+
+ public static String getConversationDraft(MethodCall methodCall) {
+ return getParamValue(methodCall, KEY_CONVERSATION_DRAFT);
+ }
+
+ public static boolean isPinnedConversation(MethodCall methodCall) {
+ return getParamValue(methodCall, KEY_CONVERSATION_PINNED);
+ }
+
+ //login
+ final static String KEY_LOGIN_UID = "uid";
+ final static String KEY_LOGIN_TOKEN = "token";
+ //create message body
+ final static String KEY_TEXT = "text";
+ final static String KEY_AT_USER_LIST = "atUserList";
+ final static String KEY_IMAGE_PATH = "imagePath";
+ final static String KEY_SOUND_PATH = "soundPath";
+ final static String KEY_SOUND_DURATION = "duration";
+ final static String KEY_VIDEO_PATH = "videoPath";
+ final static String KEY_VIDEO_TYPE = "videoType";
+ final static String KEY_VIDEO_DURATION = "duration";
+ final static String KEY_VIDEO_SNAPSHOT_PATH = "snapshotPath";
+ final static String KEY_FILE_PATH = "filePath";
+ final static String KEY_FILE_NAME = "fileName";
+ final static String KEY_MERGER_MESSAGE_LIST = "messageList";
+ final static String KEY_MERGER_MESSAGE_TITLE = "title";
+ final static String KEY_SUMMARY_LIST = "summaryList";
+ final static String KEY_FORWARD_MESSAGE = "message";
+ //send message
+ final static String KEY_SEND_MESSAGE_CONTENT = "message";
+ final static String KEY_SEND_MESSAGE_CONTENT_CLIENT_ID = "clientMsgID";
+ final static String KEY_SEND_MESSAGE_RECEIVER = "receiver";
+ final static String KEY_SEND_MESSAGE_GROUP_ID = "groupID";
+ final static String KEY_SEND_MESSAGE_ONLINE_ONLY = "onlineUserOnly";
+ //single chat
+ final static String KEY_SINGLE_MESSAGE_CONTENT = "message";
+ final static String KEY_SINGLE_MESSAGE_USERID = "userID";
+ final static String KEY_SINGLE_MESSAGE_SENDER = "sender";
+ // find message
+ final static String KEY_FIND_MESSAGE_IDS = "messageIDList";
+ // conversation
+ final static String KEY_CONVERSATION_ID = "conversationID";
+ final static String KEY_CONVERSATION_IDS = "conversationIDList";
+ final static String KEY_CONVERSATION_DRAFT = "draftText";
+ final static String KEY_CONVERSATION_PINNED = "isPinned";
+}
diff --git a/android/src/main/java/io/openim/flutter_openim_sdk/util/JsonUtil.java b/android/src/main/java/io/openim/flutter_openim_sdk/util/JsonUtil.java
new file mode 100644
index 0000000..498ad9d
--- /dev/null
+++ b/android/src/main/java/io/openim/flutter_openim_sdk/util/JsonUtil.java
@@ -0,0 +1,70 @@
+package io.openim.flutter_openim_sdk.util;
+
+
+import android.text.TextUtils;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.TypeReference;
+
+import java.util.List;
+import java.util.Map;
+
+import static com.alibaba.fastjson.JSON.parseObject;
+
+public class JsonUtil {
+
+ public static String toString(Object object) {
+ if (object == null) {
+ return "";
+ }
+ try {
+ return JSON.toJSONString(object);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return "";
+ }
+
+
+ public static T toObj(String jsonData, Class clazz) {
+ T t = null;
+ if (TextUtils.isEmpty(jsonData)) {
+ return null;
+ }
+ try {
+ t = parseObject(jsonData, clazz);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return t;
+ }
+
+
+ public static List toList(String jsonData, Class clazz) {
+ List list = null;
+ try {
+ list = JSON.parseArray(jsonData, clazz);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return list;
+ }
+
+
+ /**
+ * json转化为Map fastjson 使用方式
+ */
+ public static Map toMap(String jsonData) {
+ if (TextUtils.isEmpty(jsonData)) {
+ return null;
+ }
+ Map map = null;
+ try {
+ map = parseObject(jsonData, new TypeReference