fix:新增设置设备方法

This commit is contained in:
SL 2024-12-30 15:55:15 +08:00
parent ea8c1f0443
commit ce1086b471
3 changed files with 20 additions and 7 deletions

View File

@ -1,6 +1,7 @@
<component name="InspectionProjectProfileManager"> <component name="InspectionProjectProfileManager">
<profile version="1.0"> <profile version="1.0">
<option name="myName" value="Project Default" /> <option name="myName" value="Project Default" />
<inspection_tool class="AndroidLintUnsafeImplicitIntentLaunch" enabled="false" level="ERROR" enabled_by_default="false" />
<inspection_tool class="AutoCloseableResource" enabled="true" level="WARNING" enabled_by_default="true"> <inspection_tool class="AutoCloseableResource" enabled="true" level="WARNING" enabled_by_default="true">
<option name="METHOD_MATCHER_CONFIG" value="java.util.Formatter,format,java.io.Writer,append,com.google.common.base.Preconditions,checkNotNull,org.hibernate.Session,close,java.io.PrintWriter,printf,java.io.PrintStream,printf,com.wukong.im.db.WKDBHelper,rawQuery" /> <option name="METHOD_MATCHER_CONFIG" value="java.util.Formatter,format,java.io.Writer,append,com.google.common.base.Preconditions,checkNotNull,org.hibernate.Session,close,java.io.PrintWriter,printf,java.io.PrintStream,printf,com.wukong.im.db.WKDBHelper,rawQuery" />
</inspection_tool> </inspection_tool>

View File

@ -18,7 +18,7 @@ import com.xinbida.wukongim.utils.CryptoUtils;
* 5/20/21 5:25 PM * 5/20/21 5:25 PM
*/ */
public class WKIM { public class WKIM {
private final String Version = "V1.2.3"; private final String Version = "V1.3.3";
private WKIM() { private WKIM() {
@ -34,6 +34,7 @@ public class WKIM {
private boolean isDebug = false; private boolean isDebug = false;
private boolean isWriteLog = false; private boolean isWriteLog = false;
private String deviceId = "";
public boolean isDebug() { public boolean isDebug() {
return isDebug; return isDebug;
@ -43,6 +44,10 @@ public class WKIM {
return isWriteLog; return isWriteLog;
} }
public String getDeviceID(){
return deviceId;
}
public void setWriteLog(boolean isWriteLog) { public void setWriteLog(boolean isWriteLog) {
this.isWriteLog = isWriteLog; this.isWriteLog = isWriteLog;
} }
@ -60,7 +65,9 @@ public class WKIM {
public String getVersion() { public String getVersion() {
return Version; return Version;
} }
public void setDeviceId(String deviceID){
this.deviceId = deviceID;
}
/** /**
* 初始化IM * 初始化IM
* *

View File

@ -180,8 +180,8 @@ public class MsgManager extends BaseManager {
public WKMessageContent getMsgContentModel(int contentType, JSONObject jsonObject) { public WKMessageContent getMsgContentModel(int contentType, JSONObject jsonObject) {
if (jsonObject == null) jsonObject = new JSONObject(); if (jsonObject == null) jsonObject = new JSONObject();
WKMessageContent baseContentMsgModel = getContentMsgModel(contentType, jsonObject); WKMessageContent baseContentMsgModel = getContentMsgModel(contentType, jsonObject);
if (baseContentMsgModel == null){ if (baseContentMsgModel == null) {
baseContentMsgModel = new WKMessageContent(); baseContentMsgModel = new WKMessageContent();
} }
//解析@成员列表 //解析@成员列表
if (jsonObject.has("mention")) { if (jsonObject.has("mention")) {
@ -278,7 +278,7 @@ public class MsgManager extends BaseManager {
} }
} catch (IllegalAccessException | InstantiationException e) { } catch (IllegalAccessException | InstantiationException e) {
WKLoggerUtils.getInstance().e(TAG, "getContentMsgModel decodeMsg error"); WKLoggerUtils.getInstance().e(TAG, "getContentMsgModel decodeMsg error");
return null; return null;
} }
return null; return null;
} }
@ -953,7 +953,7 @@ public class MsgManager extends BaseManager {
List<String> msgIds = new ArrayList<>(); List<String> msgIds = new ArrayList<>();
for (int j = 0, len = list.size(); j < len; j++) { for (int j = 0, len = list.size(); j < len; j++) {
WKMsg wkMsg = WKSyncRecent2WKMsg(list.get(j)); WKMsg wkMsg = WKSyncRecent2WKMsg(list.get(j));
if (wkMsg.type == WKMsgContentType.WK_INSIDE_MSG){ if (wkMsg.type == WKMsgContentType.WK_INSIDE_MSG) {
continue; continue;
} }
msgList.add(wkMsg); msgList.add(wkMsg);
@ -1330,6 +1330,11 @@ public class MsgManager extends BaseManager {
} }
public String createClientMsgNO() { public String createClientMsgNO() {
return UUID.randomUUID().toString().replaceAll("-", "") + "1"; String deviceId = WKIM.getInstance().getDeviceID();
if (TextUtils.isEmpty(deviceId)) {
deviceId = "unknown";
}
String uuid = UUID.randomUUID().toString().replaceAll("-", "");
return uuid + "_" + deviceId + "_1";
} }
} }