Skip to content

Commit

Permalink
Merge pull request #545 from easemob/dev_4.0.0+5
Browse files Browse the repository at this point in the history
Dev 4.0.0+5
  • Loading branch information
dujiepeng committed May 15, 2023
2 parents 36473a0 + 3063d12 commit e7175d4
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 28 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
## NEXT

## 4.0.0+5

#### 修复
- 修复下载附件回调不执行。

## 4.0.0+4

#### 修复
Expand Down
10 changes: 0 additions & 10 deletions agora_build.sh

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ public void onSuccess() {
post(() -> {
Map<String, Object> map = new HashMap<>();
map.put("message", EMMessageHelper.toJson(msg));
map.put("localTime", msg.localTime());
map.put("localId", msg.getMsgId());
messageChannel.invokeMethod(EMSDKMethod.onMessageSuccess, map);
});
}
Expand All @@ -454,7 +454,7 @@ public void onProgress(int progress, String status) {
post(() -> {
Map<String, Object> map = new HashMap<>();
map.put("progress", progress);
map.put("localTime", msg.localTime());
map.put("localId", msg.getMsgId());
messageChannel.invokeMethod(EMSDKMethod.onMessageProgressUpdate, map);
});
}
Expand All @@ -467,7 +467,7 @@ public void onError(int code, String desc) {
post(() -> {
Map<String, Object> map = new HashMap<>();
map.put("message", EMMessageHelper.toJson(msg));
map.put("localTime", msg.localTime());
map.put("localId", msg.getMsgId());
map.put("error", data);
messageChannel.invokeMethod(EMSDKMethod.onMessageError, map);
});
Expand All @@ -488,7 +488,7 @@ public void onSuccess() {
post(() -> {
Map<String, Object> map = new HashMap<>();
map.put("message", EMMessageHelper.toJson(msg));
map.put("localTime", msg.localTime());
map.put("localId", msg.getMsgId());
messageChannel.invokeMethod(EMSDKMethod.onMessageSuccess, map);
});
}
Expand All @@ -498,7 +498,7 @@ public void onProgress(int progress, String status) {
post(() -> {
Map<String, Object> map = new HashMap<>();
map.put("progress", progress);
map.put("localTime", msg.localTime());
map.put("localId", msg.getMsgId());
messageChannel.invokeMethod(EMSDKMethod.onMessageProgressUpdate, map);
});
}
Expand All @@ -511,7 +511,7 @@ public void onError(int code, String desc) {
post(() -> {
Map<String, Object> map = new HashMap<>();
map.put("message", EMMessageHelper.toJson(msg));
map.put("localTime", msg.localTime());
map.put("localId", msg.getMsgId());
map.put("error", data);
messageChannel.invokeMethod(EMSDKMethod.onMessageError, map);
});
Expand Down
61 changes: 61 additions & 0 deletions common_replace.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import os
import shutil
import re
import argparse

def parse_args():
"""
解析命令行参数
"""
parser = argparse.ArgumentParser(description='过滤Dart文件中的中文或英文注释',
add_help=True)
parser.add_argument('language', choices=['chinese', 'english'], help='要过滤的注释语言')
parser.add_argument('src_folder', help='要过滤的源文件夹')
parser.add_argument('dst_folder', help='要输出过滤后文件的目标文件夹')
parser.add_argument('--file-type', '-t', default='.dart', help='要过滤的文件类型(默认为.dart)')
return parser.parse_args()

def filter_folder(src_folder, dst_folder, file_type, language):
"""
过滤指定文件夹中的文件,并输出到目标文件夹
"""
for root, dirs, files in os.walk(src_folder):
for file in files:
if file.endswith(file_type):
src_path = os.path.join(root, file)
dst_path = os.path.join(dst_folder, os.path.relpath(src_path, start=src_folder))
os.makedirs(os.path.dirname(dst_path), exist_ok=True)
if not os.path.basename(src_path) == ".DS_Store":
shutil.copy2(src_path, dst_path)
filter_comments(dst_path, language)
else:
src_path = os.path.join(root, file)
dst_path = os.path.join(dst_folder, os.path.relpath(src_path, start=src_folder))
os.makedirs(os.path.dirname(dst_path), exist_ok=True)
if not os.path.basename(src_path) == ".DS_Store":
shutil.copy2(src_path, dst_path)

def filter_comments(file_path, language):
"""
过滤文件中的中文或英文注释
"""
with open(file_path, 'r', encoding='utf-8') as f:
content = f.read()
if language == 'chinese':
pattern = r'~chinese[\s\S]*?~end'
elif language == 'english':
pattern = r'~english[\s\S]*?~end'
else:
return
filtered_content = re.sub(pattern, '', content)
filtered_content = filtered_content.replace('~chinese', '').replace('~english', '').replace('~end', '')

with open(file_path, 'w', encoding='utf-8') as f:
f.write(filtered_content)

if __name__ == '__main__':
args = parse_args()
filter_folder(args.src_folder, args.dst_folder, args.file_type, args.language)
2 changes: 1 addition & 1 deletion example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ subprojects {
project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
1 change: 1 addition & 0 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@
files = (
);
inputPaths = (
"${TARGET_BUILD_DIR}/${INFOPLIST_PATH}",
);
name = "Thin Binary";
outputPaths = (
Expand Down
11 changes: 6 additions & 5 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:flutter/material.dart';
import 'package:im_flutter_sdk/im_flutter_sdk.dart';

var appKey = "<#Your AppKey#>";
var appKey = "easemob-demo#flutter";

void main() {
runApp(const MyApp());
Expand Down Expand Up @@ -167,14 +167,14 @@ class _MyHomePageState extends State<MyHomePage> {
"UNIQUE_HANDLER_ID",
ChatMessageEvent(
onSuccess: (msgId, msg) {
_addLogToConsole("send message succeed");
_addLogToConsole("on message succeed");
},
onProgress: (msgId, progress) {
_addLogToConsole("send message succeed");
_addLogToConsole("on message progress");
},
onError: (msgId, msg, error) {
_addLogToConsole(
"send message failed, code: ${error.code}, desc: ${error.description}",
"on message failed, code: ${error.code}, desc: ${error.description}",
);
},
));
Expand Down Expand Up @@ -223,8 +223,9 @@ class _MyHomePageState extends State<MyHomePage> {
break;
case MessageType.FILE:
{
EMClient.getInstance.chatManager.downloadAttachment(msg);
_addLogToConsole(
"receive image message, from: ${msg.from}",
"receive file message, from: ${msg.from}",
);
}
break;
Expand Down
12 changes: 6 additions & 6 deletions ios/Classes/EMChatManagerWrapper.m
Original file line number Diff line number Diff line change
Expand Up @@ -472,22 +472,22 @@ - (void)downloadAttachment:(NSDictionary *)param
[weakSelf.messageChannel invokeMethod:ChatOnMessageProgressUpdate
arguments:@{
@"progress":@(progress),
@"localTime":@(msg.localTime)
@"localId":msg.messageId
}];
} completion:^(EMChatMessage *message, EMError *error)
{
if (error) {
[weakSelf.messageChannel invokeMethod:ChatOnMessageError
arguments:@{
@"error":[error toJson],
@"localTime":@(msg.localTime),
@"localId":msg.messageId,
@"message":[message toJson]
}];
}else {
[weakSelf.messageChannel invokeMethod:ChatOnMessageSuccess
arguments:@{
@"message":[message toJson],
@"localTime":@(msg.localTime)
@"localId":msg.messageId
}];
}
}];
Expand All @@ -510,22 +510,22 @@ - (void)downloadThumbnail:(NSDictionary *)param
[weakSelf.messageChannel invokeMethod:ChatOnMessageProgressUpdate
arguments:@{
@"progress":@(progress),
@"localTime":@(msg.localTime)
@"localId":msg.messageId
}];
} completion:^(EMChatMessage *message, EMError *error)
{
if (error) {
[weakSelf.messageChannel invokeMethod:ChatOnMessageError
arguments:@{
@"error":[error toJson],
@"localTime":@(msg.localTime),
@"localId":msg.messageId,
@"message":[message toJson]
}];
}else {
[weakSelf.messageChannel invokeMethod:ChatOnMessageSuccess
arguments:@{
@"message":[message toJson],
@"localTime":@(msg.localTime)
@"localId":msg.messageId
}];
}
}];
Expand Down

0 comments on commit e7175d4

Please sign in to comment.