部分定义
这个提交包含在:
父节点
0428571b34
当前提交
30cfc892c1
@ -0,0 +1,44 @@
|
|||||||
|
package cn.org.bjca.trust.android.lib.im;
|
||||||
|
|
||||||
|
import android.content.ContentProvider;
|
||||||
|
import android.content.ContentValues;
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.net.Uri;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
public class PushProvider extends ContentProvider {
|
||||||
|
@Override
|
||||||
|
public boolean onCreate() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public Cursor query(@NonNull Uri uri, @Nullable String[] projection, @Nullable String selection, @Nullable String[] selectionArgs, @Nullable String sortOrder) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public String getType(@NonNull Uri uri) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public Uri insert(@NonNull Uri uri, @Nullable ContentValues values) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int delete(@NonNull Uri uri, @Nullable String selection, @Nullable String[] selectionArgs) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int update(@NonNull Uri uri, @Nullable ContentValues values, @Nullable String selection, @Nullable String[] selectionArgs) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
package cn.org.bjca.trust.android.lib.im;
|
||||||
|
|
||||||
|
import cn.org.bjca.trust.android.lib.im.kit.SdkInterface;
|
||||||
|
import cn.org.bjca.trust.android.lib.im.manager.PushSdkManager;
|
||||||
|
|
||||||
|
public class SzyxPush {
|
||||||
|
|
||||||
|
private static final class SdkInterfaceHolder {
|
||||||
|
static final SdkInterface instance = new PushSdkManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SdkInterface getInstance() {
|
||||||
|
return SdkInterfaceHolder.instance;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
package cn.org.bjca.trust.android.lib.im.bean;
|
||||||
|
|
||||||
|
public class IMUserFullInfo {
|
||||||
|
}
|
||||||
@ -0,0 +1,56 @@
|
|||||||
|
package cn.org.bjca.trust.android.lib.im.bean;
|
||||||
|
|
||||||
|
import cn.org.bjca.trust.android.lib.im.bean.message.TextMessage;
|
||||||
|
import cn.org.bjca.trust.android.lib.im.enums.MsgType;
|
||||||
|
|
||||||
|
public class SZYXMessage {
|
||||||
|
/**
|
||||||
|
* 消息id
|
||||||
|
*/
|
||||||
|
private String msgId;
|
||||||
|
/**
|
||||||
|
*发送者信息
|
||||||
|
*/
|
||||||
|
private UserInfo fromClient;
|
||||||
|
/**
|
||||||
|
*接收者信息
|
||||||
|
*/
|
||||||
|
private UserInfo toClient;
|
||||||
|
/**
|
||||||
|
*真实讲话人
|
||||||
|
*/
|
||||||
|
private UserInfo speaker;
|
||||||
|
/**
|
||||||
|
*自定义信息
|
||||||
|
*/
|
||||||
|
private String describe;
|
||||||
|
/**
|
||||||
|
*是不是群消息
|
||||||
|
*/
|
||||||
|
private boolean isGroup;
|
||||||
|
/**
|
||||||
|
*是不是接收消息
|
||||||
|
*/
|
||||||
|
private boolean isArrive;
|
||||||
|
/**
|
||||||
|
*消息发送状态
|
||||||
|
*/
|
||||||
|
private boolean isSuccess;
|
||||||
|
/**
|
||||||
|
*时间戳
|
||||||
|
*/
|
||||||
|
private long timestamp;
|
||||||
|
/**
|
||||||
|
*租户编号
|
||||||
|
*/
|
||||||
|
private String tenantNo;
|
||||||
|
/**
|
||||||
|
*消息序列号
|
||||||
|
*/
|
||||||
|
private long seq;
|
||||||
|
/**
|
||||||
|
* 消息类型
|
||||||
|
*/
|
||||||
|
private MsgType msgType;
|
||||||
|
private TextMessage textMessage;
|
||||||
|
}
|
||||||
@ -0,0 +1,44 @@
|
|||||||
|
package cn.org.bjca.trust.android.lib.im.bean;
|
||||||
|
|
||||||
|
public class UserInfo {
|
||||||
|
private String userId;
|
||||||
|
private String nickName;
|
||||||
|
private String faceUrl;
|
||||||
|
private String gender;
|
||||||
|
|
||||||
|
public UserInfo(String userId) {
|
||||||
|
this.userId = userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUserId() {
|
||||||
|
return userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserId(String userId) {
|
||||||
|
this.userId = userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNickName() {
|
||||||
|
return nickName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNickName(String nickName) {
|
||||||
|
this.nickName = nickName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFaceUrl() {
|
||||||
|
return faceUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFaceUrl(String faceUrl) {
|
||||||
|
this.faceUrl = faceUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGender() {
|
||||||
|
return gender;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGender(String gender) {
|
||||||
|
this.gender = gender;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
package cn.org.bjca.trust.android.lib.im.bean.message;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
public class TextMessage {
|
||||||
|
private String text;
|
||||||
|
|
||||||
|
public TextMessage(String text) {
|
||||||
|
this.text = text;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getText() {
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setText(String text) {
|
||||||
|
this.text = text;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "TextMessage{" +
|
||||||
|
"text='" + text + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,35 @@
|
|||||||
|
package cn.org.bjca.trust.android.lib.im.enums;
|
||||||
|
|
||||||
|
public enum MsgType {
|
||||||
|
UNKNOWN(-1) /* 未知 */,
|
||||||
|
Text(1) /* 文本 */,
|
||||||
|
Voice(2) /* 语音 */,
|
||||||
|
Image(3) /* 图片 */,
|
||||||
|
Location(4) /* 位置 */,
|
||||||
|
Video(5) /* 视频 */,
|
||||||
|
File(6) /* 文件 */,
|
||||||
|
At(7) /* @我 */,
|
||||||
|
READ(8) /* 已读 */,
|
||||||
|
REVOKE(9) /* 撤回 */,
|
||||||
|
DELETE(10) /* 删除 */,
|
||||||
|
Other(101) /* 自定义消息 */,
|
||||||
|
|
||||||
|
Notify(999);
|
||||||
|
|
||||||
|
private int type = -1;
|
||||||
|
MsgType(final int type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
public int type() {
|
||||||
|
return this.type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MsgType getType(final int type) {
|
||||||
|
for (final MsgType value : MsgType.values()) {
|
||||||
|
if (value.type == type) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return UNKNOWN;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,34 @@
|
|||||||
|
package cn.org.bjca.trust.android.lib.im.enums;
|
||||||
|
|
||||||
|
public enum PacketType {
|
||||||
|
//连接请求
|
||||||
|
CONNECT(10),
|
||||||
|
CONNACK(11),
|
||||||
|
//发送消息
|
||||||
|
SEND(20),
|
||||||
|
SENDACK(21),
|
||||||
|
//心跳包
|
||||||
|
PING(30),
|
||||||
|
PANG(31),
|
||||||
|
// 离线通知
|
||||||
|
DISCONNECT(40),
|
||||||
|
UNKNOWN(-1);
|
||||||
|
|
||||||
|
private int type = -1;
|
||||||
|
PacketType(final int type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int type() {
|
||||||
|
return this.type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static PacketType getType(final int type) {
|
||||||
|
for (final PacketType value : PacketType.values()) {
|
||||||
|
if (value.type == type) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return UNKNOWN;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
package cn.org.bjca.trust.android.lib.im.kit;
|
||||||
|
|
||||||
|
public interface IMSDKCallback {
|
||||||
|
void success();
|
||||||
|
void failed (int code, String error);
|
||||||
|
}
|
||||||
@ -0,0 +1,33 @@
|
|||||||
|
package cn.org.bjca.trust.android.lib.im.kit;
|
||||||
|
|
||||||
|
import cn.org.bjca.trust.android.lib.im.bean.IMUserFullInfo;
|
||||||
|
|
||||||
|
public interface IMSDKListener {
|
||||||
|
/**
|
||||||
|
* 连接中
|
||||||
|
*/
|
||||||
|
void onConnecting ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 连接成功
|
||||||
|
*/
|
||||||
|
void onConnectSuccess ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
*连接失败
|
||||||
|
* @param code 错误码
|
||||||
|
* @param error 错误信息
|
||||||
|
*/
|
||||||
|
void onConnectFailed (int code, String error);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*用户被踢出
|
||||||
|
*/
|
||||||
|
void onKickedOffline ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
*用户信息变更
|
||||||
|
*/
|
||||||
|
void onSelfInfoUpdated (IMUserFullInfo info);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
package cn.org.bjca.trust.android.lib.im.kit;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import cn.org.bjca.trust.android.lib.im.bean.SZYXMessage;
|
||||||
|
|
||||||
|
public interface MsgListener {
|
||||||
|
void messageArrive(List<SZYXMessage> messages);
|
||||||
|
}
|
||||||
@ -0,0 +1,26 @@
|
|||||||
|
package cn.org.bjca.trust.android.lib.im.kit;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
public interface SdkInterface {
|
||||||
|
|
||||||
|
void addIMSDKListener(IMSDKListener listener);
|
||||||
|
|
||||||
|
void removeIMSDKListener(IMSDKListener listener);
|
||||||
|
|
||||||
|
void init(Context context, String sdkAppID, IMSDKCallback callback);
|
||||||
|
|
||||||
|
void login(String userID, String userSig, IMSDKCallback callback);
|
||||||
|
|
||||||
|
void logout( IMSDKCallback callback);
|
||||||
|
|
||||||
|
void addMsgListener(MsgListener listener);
|
||||||
|
|
||||||
|
void removeMsgListener(MsgListener listener);
|
||||||
|
|
||||||
|
void sendMsgForTextToC(String toUserId, String text, IMSDKCallback callback);
|
||||||
|
|
||||||
|
void sendMsgForTextToG(String toGroupId, String text, IMSDKCallback callback);
|
||||||
|
|
||||||
|
String getVersion();
|
||||||
|
}
|
||||||
@ -0,0 +1,60 @@
|
|||||||
|
package cn.org.bjca.trust.android.lib.im.manager;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import cn.org.bjca.trust.android.lib.im.kit.IMSDKCallback;
|
||||||
|
import cn.org.bjca.trust.android.lib.im.kit.IMSDKListener;
|
||||||
|
import cn.org.bjca.trust.android.lib.im.kit.MsgListener;
|
||||||
|
import cn.org.bjca.trust.android.lib.im.kit.SdkInterface;
|
||||||
|
|
||||||
|
public class PushSdkManager implements SdkInterface {
|
||||||
|
@Override
|
||||||
|
public void addIMSDKListener(IMSDKListener listener) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeIMSDKListener(IMSDKListener listener) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(Context context, String sdkAppID, IMSDKCallback callback) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void login(String userID, String userSig, IMSDKCallback callback) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void logout(IMSDKCallback callback) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addMsgListener(MsgListener listener) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeMsgListener(MsgListener listener) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendMsgForTextToC(String toUserId, String text, IMSDKCallback callback) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendMsgForTextToG(String toGroupId, String text, IMSDKCallback callback) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getVersion() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -3,6 +3,7 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools">
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
<application
|
<application
|
||||||
|
android:name=".MyApplication"
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||||
android:fullBackupContent="@xml/backup_rules"
|
android:fullBackupContent="@xml/backup_rules"
|
||||||
|
|||||||
@ -0,0 +1,52 @@
|
|||||||
|
package cn.org.bjca.trust.android.imdemo;
|
||||||
|
|
||||||
|
import android.app.Application;
|
||||||
|
|
||||||
|
import cn.org.bjca.trust.android.lib.im.SzyxPush;
|
||||||
|
import cn.org.bjca.trust.android.lib.im.bean.IMUserFullInfo;
|
||||||
|
import cn.org.bjca.trust.android.lib.im.kit.IMSDKCallback;
|
||||||
|
import cn.org.bjca.trust.android.lib.im.kit.IMSDKListener;
|
||||||
|
|
||||||
|
public class MyApplication extends Application {
|
||||||
|
@Override
|
||||||
|
public void onCreate() {
|
||||||
|
super.onCreate();
|
||||||
|
SzyxPush.getInstance().addIMSDKListener(new IMSDKListener() {
|
||||||
|
@Override
|
||||||
|
public void onConnecting() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onConnectSuccess() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onConnectFailed(int code, String error) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onKickedOffline() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSelfInfoUpdated(IMUserFullInfo info) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
SzyxPush.getInstance().init(this, "202305161853245", new IMSDKCallback() {
|
||||||
|
@Override
|
||||||
|
public void success() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void failed(int code, String error) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
正在加载...
在新工单中引用
屏蔽一个用户