Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

Commit

Permalink
Merge branch 'release'
Browse files Browse the repository at this point in the history
* release:
  问题:[fix]5.1.2+1发版信息 原因及方案: Reviewer: 来源:
  问题:【fix】41611 【转发】聊天页面选中消息后,点击转发按钮没反应 原因及方案: Reviewer: 来源:
  fix:修复引用消息无法正常发送的问题(Android)
  问题:【fix】更新5.1.2+1 发版信息 原因及方案: Reviewer: 来源:
  fix:修复 Android 端 localPath 为空字符串的时候导致,localPath 和 name 数据异常的问题
  问题:【fix】升级到2.2.2后找不到c方法 原因及方案: Reviewer: 来源:
  问题:【fix】修复聊天室某些情况消息没有走回调的问题 原因及方案: Reviewer: 来源:
  问题:【fix】去掉不该有的return。 增加了聊天室测试用例 原因及方案: Reviewer: 来源:
  问题:【fix】安卓加了设置推送的方法。iOS不加会抛异常 原因及方案: Reviewer: 来源:
  pha D18505
  问题:更新 maven 变更文档 原因及方案: Reviewer: 来源:
  • Loading branch information
liyanrongcloud committed Jun 23, 2021
2 parents 3a16247 + adc122b commit 16ce119
Show file tree
Hide file tree
Showing 10 changed files with 387 additions and 246 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## 5.1.2+1

发布日期:2021/6/23

**SDK:**
* 1.适配 flutter 2.2.2。
* 2.修复 Android 端 localPath 为空字符串的时候导致,localPath 和 name 数据异常的问题。


## 5.1.2

发布日期:2021/5/28
Expand Down
123 changes: 117 additions & 6 deletions android/src/main/java/io/rong/flutter/imlib/RCIMFlutterWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.util.ArrayList;
Expand All @@ -34,6 +35,7 @@
import io.rong.imlib.IRongCoreEnum;
import io.rong.imlib.IRongCoreListener;
import io.rong.imlib.MessageTag;
import io.rong.imlib.NativeClient;
import io.rong.imlib.RongCoreClient;
import io.rong.imlib.RongIMClient;
import io.rong.imlib.chatroom.base.RongChatRoomClient;
Expand Down Expand Up @@ -806,9 +808,10 @@ private void sendMessage(Object arg, final Result result) {
// do nothing
}
} else {
content = newMessageContent(objectName, bytes, contentStr);
if (objectName.equalsIgnoreCase("RC:ReferenceMsg")) {
makeReferenceMessage(content, contentStr);
content = makeReferenceMessage(contentStr);
} else {
content = newMessageContent(objectName, bytes, contentStr);
}
}
// 处理引用消息内容丢失的问题
Expand Down Expand Up @@ -876,9 +879,6 @@ public void onError(Message message, RongIMClient.ErrorCode errorCode) {
}

private void makeReferenceMessage(MessageContent content, String contentStr) {
if (content == null || TextUtils.isEmpty(contentStr)) {
return;
}
JSONObject jsonObject = null;
String objName;
try {
Expand All @@ -901,6 +901,109 @@ private void makeReferenceMessage(MessageContent content, String contentStr) {
}
}

private MessageContent makeReferenceMessage(String contentStr) {
if (TextUtils.isEmpty(contentStr)) {
return null;
}
try {
JSONObject jsonObj = new JSONObject(contentStr);
String userId = "";
if (jsonObj.has("referMsgUserId")) {
userId = jsonObj.getString("referMsgUserId");
}

String editSendText = "";
if (jsonObj.has("content")) {
editSendText = jsonObj.getString("content");
}
String objName = "";
if (jsonObj.has("objName")) {
objName = jsonObj.getString("objName");
}

MessageContent messageContent = null;
if (jsonObj.has("referMsg") && !TextUtils.isEmpty(objName)) {
JSONObject jsonObject = (JSONObject) jsonObj.get("referMsg");
byte[] bytes = jsonObject.toString().getBytes("UTF-8");
messageContent = newMessageContent(objName, bytes, jsonObject.toString());
// this.setContent(NativeClient.getInstance().newMessageContent(this.getObjName(), bytes));
}

ReferenceMessage referenceMessage = ReferenceMessage.obtainMessage(userId, messageContent);
referenceMessage.setEditSendText(editSendText);

String extra = "";
if (jsonObj.has("extra")) {
extra = jsonObj.getString("extra");
}
referenceMessage.setExtra(extra);

if (jsonObj.has("user")) {
referenceMessage.setUserInfo(parseJsonToUserInfo(jsonObj.getJSONObject("user")));
}

if (jsonObj.has("mentionedInfo")) {
referenceMessage.setMentionedInfo(parseJsonToMentionInfo(jsonObj.getJSONObject("mentionedInfo")));
}
return referenceMessage;
} catch (JSONException var6) {
RLog.e("ReferenceMessage", "JSONException " + var6.getMessage());
} catch (UnsupportedEncodingException var7) {
RLog.e("ReferenceMessage", "ReferenceMessage UnsupportedEncodingException", var7);
}
return null;
}

public UserInfo parseJsonToUserInfo(JSONObject jsonObj) {
UserInfo info = null;
String id = jsonObj.optString("id");
String name = jsonObj.optString("name");
String icon = jsonObj.optString("portrait");
String extra = jsonObj.optString("extra");
if (TextUtils.isEmpty(icon)) {
icon = jsonObj.optString("icon");
}

if (!TextUtils.isEmpty(id) && !TextUtils.isEmpty(name)) {
Uri portrait = icon != null ? Uri.parse(icon) : null;
info = new UserInfo(id, name, portrait);
info.setExtra(extra);
}

return info;
}

protected MentionedInfo parseJsonToMentionInfo(JSONObject jsonObject) {
MentionedInfo.MentionedType type = MentionedInfo.MentionedType.valueOf(jsonObject.optInt("type"));
JSONArray userList = jsonObject.optJSONArray("userIdList");
String mentionContent = jsonObject.optString("mentionedContent");
if (type.equals(MentionedInfo.MentionedType.NONE)) {
return null;
} else {
MentionedInfo mentionedInfo;
if (type.equals(MentionedInfo.MentionedType.ALL)) {
mentionedInfo = new MentionedInfo(type, (List) null, mentionContent);
} else {
List<String> list = new ArrayList();
if (userList == null || userList.length() <= 0) {
return null;
}

try {
for (int i = 0; i < userList.length(); ++i) {
list.add((String) userList.get(i));
}
} catch (JSONException var8) {
var8.printStackTrace();
}

mentionedInfo = new MentionedInfo(type, list, mentionContent);
}

return mentionedInfo;
}
}

private void sendMediaMessage(Object arg, final Result result) {
final String LOG_TAG = "sendMediaMessage";
// RCLog.i(LOG_TAG + " start param:" + arg.toString());
Expand Down Expand Up @@ -1020,7 +1123,9 @@ private void sendMediaMessage(Object arg, final Result result) {
try {
JSONObject jsonObject = new JSONObject(contentStr);
String localPath = (String) jsonObject.get("localPath");
localPath = getCorrectLocalPath(localPath);
if (!TextUtils.isEmpty(localPath)) {
localPath = getCorrectLocalPath(localPath);
}
Uri uri = Uri.parse(localPath);
content = FileMessage.obtain(uri);
if (jsonObject.has("type")) {
Expand All @@ -1046,6 +1151,12 @@ private void sendMediaMessage(Object arg, final Result result) {
((FileMessage) content).setSize(size.intValue());
}
}
if (jsonObject.has("name")) {
String name = jsonObject.optString("name");
if (!TextUtils.isEmpty(name)) {
((FileMessage) content).setName(name);
}
}
} catch (JSONException e) {
e.printStackTrace();
}
Expand Down
4 changes: 4 additions & 0 deletions example/lib/im/pages/conversation_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1156,6 +1156,7 @@ class _ConversationPageState extends State<ConversationPage>
multiSelect = false;
RongIMClient.deleteMessageByIds(messageIds, (int code) {
if (code == 0) {
selectedMessageIds.clear();
onGetHistoryMessages();
_refreshUI();
}
Expand All @@ -1168,6 +1169,9 @@ class _ConversationPageState extends State<ConversationPage>
bool isAllowCombine = true;
for (int msgId in selectedMessageIds) {
Message forwardMsg = await RongIMClient.getMessage(msgId);
if (forwardMsg == null) {
return;
}
if (!CombineMessageUtils.allowForward(forwardMsg.objectName)) {
isAllowCombine = false;
}
Expand Down
23 changes: 18 additions & 5 deletions example/lib/other/chatroom_debug_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class _ChatRoomDebugPageState extends State<ChatRoomDebugPage> {
"退出聊天室 1",
"获取聊天室历史消息",
"加入已存在的聊天室 1",
"聊天室发送消息",
];

RongIMClient.onJoinChatRoom = (String targetId, int status) {
Expand All @@ -44,13 +45,14 @@ class _ChatRoomDebugPageState extends State<ChatRoomDebugPage> {
timeInSecForIos: 2);
};

RongIMClient.onChatRoomReset = (String targetId) {
Fluttertoast.showToast(msg: "聊天室被重制 $targetId ",timeInSecForIos: 2);
RongIMClient.onChatRoomReset = (String targetId) {
Fluttertoast.showToast(msg: "聊天室被重制 $targetId ", timeInSecForIos: 2);
};

RongIMClient.onChatRoomDestroyed = (String targetId, int type) {
Fluttertoast.showToast(
msg: "聊天室被销毁 $targetId " + (type == 0 ? "开发者主动销毁" : "聊天室长时间不活跃,被系统自动回收"),
RongIMClient.onChatRoomDestroyed = (String targetId, int type) {
Fluttertoast.showToast(
msg: "聊天室被销毁 $targetId " +
(type == 0 ? "开发者主动销毁" : "聊天室长时间不活跃,被系统自动回收"),
timeInSecForIos: 2);
};

Expand All @@ -65,6 +67,7 @@ class _ChatRoomDebugPageState extends State<ChatRoomDebugPage> {
RongIMClient.chatRoomKVDidRemove = (String roomId, Map entry) {
DialogUtil.showAlertDiaLog(context, "chatRoomKVDidRemove $roomId $entry");
};

}

void _didTap(int index) {
Expand Down Expand Up @@ -100,6 +103,9 @@ class _ChatRoomDebugPageState extends State<ChatRoomDebugPage> {
case 9:
_joinExistChatRoom();
break;
case 10:
_sendChatMessage();
break;
}
}

Expand Down Expand Up @@ -165,6 +171,13 @@ class _ChatRoomDebugPageState extends State<ChatRoomDebugPage> {
RongIMClient.quitChatRoom(targetId);
}

void _sendChatMessage() async {
TextMessage msg = new TextMessage();
msg.content = "测试文本消息携带用户信息";
Message message =
await RongIMClient.sendMessage(RCConversationType.ChatRoom, targetId, msg);
}

void _getChatRoomHistoryMessage() {
RongIMClient.getRemoteChatRoomHistoryMessages(
targetId, 0, 20, RCTimestampOrder.RC_Timestamp_Desc,
Expand Down
1 change: 1 addition & 0 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ dependencies:
rxdart: ^0.24.0
flutter_cache_manager: ^1.2.0
connectivity: ^0.4.8+2
ffi: ^1.0.0


dev_dependencies:
Expand Down
2 changes: 1 addition & 1 deletion ios/Classes/RCIMFlutterDefine.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ static NSString *RCMethodKeyGetConversationsFromTagByPage = @"getConversationsFr
static NSString *RCMethodKeyGetUnreadCountByTag = @"getUnreadCountByTag";
static NSString *RCMethodKeySetConversationToTopInTag = @"setConversationToTopInTag";
static NSString *RCMethodKeyGetConversationTopStatusInTag = @"getConversationTopStatusInTag";

static NSString *RCMethodKeySetAndroidPushConfig = @"setAndroidPushConfig";

// 聊天室状态存储
static NSString *RCMethodKeySetChatRoomEntry = @"SetChatRoomEntry";
Expand Down
2 changes: 2 additions & 0 deletions ios/Classes/RCIMFlutterWrapper.m
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
[self setConversationToTopInTag:call.arguments result:result];
}else if([RCMethodKeyGetConversationTopStatusInTag isEqualToString:call.method]){
[self getConversationTopStatusInTag:call.arguments result:result];
}else if ([RCMethodKeySetAndroidPushConfig isEqualToString:call.method]){
//配合安卓做的安卓推送。这里不写会抛异常。所以写了个空方法
}
else {
result(FlutterMethodNotImplemented);
Expand Down
4 changes: 2 additions & 2 deletions lib/src/info/connection_status_convert.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ class ConnectionStatusConvert {
return RCConnectionStatus.KickedByOtherClient;
} else if (originCode == 1) {
return RCConnectionStatus.NetworkUnavailable;
} else if (originCode == 31004) {
} else if (originCode == 15) {
return RCConnectionStatus.TokenIncorrect;
} else if (originCode == 31011) {
} else if (originCode == 16) {
return RCConnectionStatus.UserBlocked;
} else if (originCode == 12) {
return RCConnectionStatus.DisConnected;
Expand Down
Loading

0 comments on commit 16ce119

Please sign in to comment.