From ac1aaef3159afe9034abfb9daa23120ab9ed321b Mon Sep 17 00:00:00 2001 From: ZCM <772112648@qq.com> Date: Wed, 25 Mar 2020 10:10:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=96=87=E4=BB=B6=E5=A4=8D?= =?UTF-8?q?=E5=88=B6=E4=B8=8B=E8=BD=BD=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- i18n/en-US.json | 3 ++- i18n/ja-JP.json | 3 ++- i18n/ko-KR.json | 3 ++- i18n/vi-VN.json | 3 ++- i18n/zh-CN.json | 3 ++- i18n/zh-HK.json | 3 ++- lib/chat/ChatPageItem.dart | 37 +++++++++++++++++++++++------------ lib/chat/group_chat_item.dart | 26 ++++++++++++++++++------ lib/generated/i18n.dart | 17 ++++++++++++++++ lib/utils/upload_util.dart | 9 +++++++++ 10 files changed, 82 insertions(+), 25 deletions(-) diff --git a/i18n/en-US.json b/i18n/en-US.json index 2bca025..4dbf198 100644 --- a/i18n/en-US.json +++ b/i18n/en-US.json @@ -1223,5 +1223,6 @@ "man_retranslate":"人工重译", "robot_retranslate":"机器重译", "see_original":"查看原文", - "forward":"Forward" + "forward":"Forward", + "copy_download_url":"复制下载地址" } \ No newline at end of file diff --git a/i18n/ja-JP.json b/i18n/ja-JP.json index 32d88b8..526cffc 100644 --- a/i18n/ja-JP.json +++ b/i18n/ja-JP.json @@ -1223,5 +1223,6 @@ "man_retranslate":"人工重译", "robot_retranslate":"机器重译", "see_original":"查看原文", - "forward":"转发" + "forward":"转发", + "copy_download_url":"复制下载地址" } \ No newline at end of file diff --git a/i18n/ko-KR.json b/i18n/ko-KR.json index cd55d56..b44caeb 100644 --- a/i18n/ko-KR.json +++ b/i18n/ko-KR.json @@ -1223,5 +1223,6 @@ "man_retranslate":"人工重译", "robot_retranslate":"机器重译", "see_original":"查看原文", - "forward":"转发" + "forward":"转发", + "copy_download_url":"复制下载地址" } \ No newline at end of file diff --git a/i18n/vi-VN.json b/i18n/vi-VN.json index 7508d4a..e789546 100644 --- a/i18n/vi-VN.json +++ b/i18n/vi-VN.json @@ -1223,5 +1223,6 @@ "man_retranslate":"人工重译", "robot_retranslate":"机器重译", "see_original":"查看原文", - "forward":"转发" + "forward":"转发", + "copy_download_url":"复制下载地址" } \ No newline at end of file diff --git a/i18n/zh-CN.json b/i18n/zh-CN.json index dbcf39d..af64e22 100644 --- a/i18n/zh-CN.json +++ b/i18n/zh-CN.json @@ -1223,5 +1223,6 @@ "man_retranslate":"人工重译", "robot_retranslate":"机器重译", "see_original":"查看原文", - "forward":"转发" + "forward":"转发", + "copy_download_url":"复制下载地址" } \ No newline at end of file diff --git a/i18n/zh-HK.json b/i18n/zh-HK.json index 798b7f6..bd48da2 100644 --- a/i18n/zh-HK.json +++ b/i18n/zh-HK.json @@ -1223,5 +1223,6 @@ "man_retranslate":"人工重譯", "robot_retranslate":"機器重譯", "see_original":"查看原文", - "forward":"转发" + "forward":"转发", + "copy_download_url":"複製下載地址" } \ No newline at end of file diff --git a/lib/chat/ChatPageItem.dart b/lib/chat/ChatPageItem.dart index c33346f..065c086 100644 --- a/lib/chat/ChatPageItem.dart +++ b/lib/chat/ChatPageItem.dart @@ -253,8 +253,6 @@ class _ChatPageItemState extends State } else { ///todo 翻译管家系统通知消息 - - if (type == ChatType.GroupChatNoticeType.value) { var res = GroupChatNotice.fromBuffer(widget.msg.msgContent); @@ -621,21 +619,21 @@ class _ChatPageItemState extends State Widget wrapItemWithMenu(item) { List actionsFunc = []; List actions = [ - I18n.of(context).delete, + I18n.of(context).forward, I18n.of(context).reply, - I18n.of(context).forward + I18n.of(context).delete, ]; actionsFunc.add(() { - MessageMgr().emit('Delete Select Message', widget.msg); + print('转发消息'); + AppNavigator.pushForwardPage(context, widget.msg); }); actionsFunc.add(() { print('发送引用的消息'); MessageMgr().emit('Reply Select Message', widget.msg); }); actionsFunc.add(() { - print('转发消息'); - AppNavigator.pushForwardPage(context, widget.msg); + MessageMgr().emit('Delete Select Message', widget.msg); }); if (widget.msg.msgType == ChatType.TextChatType.value) { @@ -649,6 +647,14 @@ class _ChatPageItemState extends State }); } + //如果是文件增加复制下载地址 + if (widget.msg.msgType == ChatType.FileChatType.value) { + actions.insert(0, I18n.of(context).copy_download_url); + actionsFunc.insert(0, () { + UploadUtil().copyFileUrl(widget.msg, context); + }); + } + if (widget.msg.msgType == ChatType.ShortVoiceChatType.value) { var soundPlayMode = Provider.of(context).soundPlayMode; @@ -663,7 +669,7 @@ class _ChatPageItemState extends State }); } // String date2 = DateTime.fromMillisecondsSinceEpoch(widget.msg.time).toString(); - return WPopupMenu( + return WPopupMenu( child: item, actions: actions, onLongPressStart: () { @@ -830,14 +836,17 @@ class _ChatPageItemState extends State if (transTag == 1) { //机器翻译中 - userTranslateWidget = _translateItemWidget(0xe670, I18n.of(context).man_retranslate, null); + userTranslateWidget = + _translateItemWidget(0xe670, I18n.of(context).man_retranslate, null); machineTranslateWidget = _translateItemWidget(0xe671, I18n.of(context).robotTranslate, null); } else if (transTag == 2) { //人工翻译中 - userTranslateWidget = _translateItemWidget(0xe670, I18n.of(context).ManTranslate, null); - machineTranslateWidget = _translateItemWidget(0xe671, I18n.of(context).robot_retranslate, () { + userTranslateWidget = + _translateItemWidget(0xe670, I18n.of(context).ManTranslate, null); + machineTranslateWidget = + _translateItemWidget(0xe671, I18n.of(context).robot_retranslate, () { setState(() { curTextType += 1; curTextType %= textList.length; @@ -889,7 +898,8 @@ class _ChatPageItemState extends State }); } }); - machineTranslateWidget = _translateItemWidget(0xe671, I18n.of(context).robot_retranslate, () { + machineTranslateWidget = + _translateItemWidget(0xe671, I18n.of(context).robot_retranslate, () { setState(() { curTextType += 1; curTextType %= textList.length; @@ -944,7 +954,8 @@ class _ChatPageItemState extends State )) ], ))); - machineTranslateWidget = _translateItemWidget(0xe675, I18n.of(context).see_original, () { + machineTranslateWidget = + _translateItemWidget(0xe675, I18n.of(context).see_original, () { setState(() { curTextType = textList.length - 1; }); diff --git a/lib/chat/group_chat_item.dart b/lib/chat/group_chat_item.dart index 764c1bc..f02bb20 100644 --- a/lib/chat/group_chat_item.dart +++ b/lib/chat/group_chat_item.dart @@ -563,11 +563,12 @@ class _GroupChatPageItemState extends State Widget wrapItemWithMenu(item) { List actionsFunc = []; - List actions = [I18n.of(context).delete, I18n.of(context).reply,I18n.of(context).forward]; + List actions = [ + I18n.of(context).reply, + I18n.of(context).forward, + I18n.of(context).delete, + ]; - actionsFunc.add(() { - MessageMgr().emit('Delete Select Message', widget.msg); - }); actionsFunc.add(() { print('发送引用的消息'); MessageMgr().emit('Reply Select Message', widget.msg); @@ -576,6 +577,9 @@ class _GroupChatPageItemState extends State print('转发消息'); AppNavigator.pushForwardPage(context, widget.msg); }); + actionsFunc.add(() { + MessageMgr().emit('Delete Select Message', widget.msg); + }); if (widget.msg.msgType == ChatType.TextChatType.value) { actions.insert(0, I18n.of(context).copy); @@ -587,6 +591,15 @@ class _GroupChatPageItemState extends State Clipboard.setData(clipboardData); }); } + + //如果是文件增加复制下载地址 + if (widget.msg.msgType == ChatType.FileChatType.value) { + actions.insert(0, I18n.of(context).copy_download_url); + actionsFunc.insert(0, () { + UploadUtil().copyFileUrl(widget.msg, context); + }); + } + if (widget.msg.msgType == ChatType.ShortVoiceChatType.value) { var soundPlayMode = Provider.of(context).soundPlayMode; @@ -1308,8 +1321,9 @@ class _GroupChatPageItemState extends State onTap: () { AppNavigator.pushProfileInfoPage(context, memberModel.memberId, fromWhere: 2, - addMode: - !FriendListMgr().isMyFriend(memberModel.memberId) ? 1 : 0); + addMode: !FriendListMgr().isMyFriend(memberModel.memberId) + ? 1 + : 0); }, onLongPress: () { print('long press user'); diff --git a/lib/generated/i18n.dart b/lib/generated/i18n.dart index c69a47a..5546728 100644 --- a/lib/generated/i18n.dart +++ b/lib/generated/i18n.dart @@ -2483,6 +2483,8 @@ class I18n implements WidgetsLocalizations { String get see_original => "查看原文"; /// "Forward" String get forward => "Forward"; + /// "复制下载地址" + String get copy_download_url => "复制下载地址"; } class _I18n_en_US extends I18n { @@ -6170,6 +6172,9 @@ class _I18n_vi_VN extends I18n { /// "转发" @override String get forward => "转发"; + /// "复制下载地址" + @override + String get copy_download_url => "复制下载地址"; @override TextDirection get textDirection => TextDirection.ltr; @@ -9853,6 +9858,9 @@ class _I18n_zh_HK extends I18n { /// "转发" @override String get forward => "转发"; + /// "複製下載地址" + @override + String get copy_download_url => "複製下載地址"; @override TextDirection get textDirection => TextDirection.ltr; @@ -13536,6 +13544,9 @@ class _I18n_zh_CN extends _I18n_zh_HK { /// "转发" @override String get forward => "转发"; + /// "复制下载地址" + @override + String get copy_download_url => "复制下载地址"; @override TextDirection get textDirection => TextDirection.ltr; @@ -17219,6 +17230,9 @@ class _I18n_ko_KR extends I18n { /// "转发" @override String get forward => "转发"; + /// "复制下载地址" + @override + String get copy_download_url => "复制下载地址"; @override TextDirection get textDirection => TextDirection.ltr; @@ -20902,6 +20916,9 @@ class _I18n_ja_JP extends I18n { /// "转发" @override String get forward => "转发"; + /// "复制下载地址" + @override + String get copy_download_url => "复制下载地址"; @override TextDirection get textDirection => TextDirection.ltr; diff --git a/lib/utils/upload_util.dart b/lib/utils/upload_util.dart index fb0ffde..3580f9c 100644 --- a/lib/utils/upload_util.dart +++ b/lib/utils/upload_util.dart @@ -10,6 +10,8 @@ import 'package:chat/utils/file_cache_mgr.dart'; import 'package:convert/convert.dart'; import 'package:dio/dio.dart'; import 'package:crypto/crypto.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'dart:async'; import 'package:http_parser/http_parser.dart'; import 'package:chat/utils/MessageMgr.dart'; @@ -187,6 +189,13 @@ class UploadUtil { 'downloadchatfile?targetid=$sessionid&channeltype=$channelType&userid=${UserData().basicInfo.userId}&fileid=$imgData&sign=$sign'; } + copyFileUrl(MsgModel msg, BuildContext context) { + var url = getFullUrl(msg.extraFile, msg.sessionId, msg.channelType); + ClipboardData clipboardData = new ClipboardData(text: url); + Clipboard.setData(clipboardData); + showToast(I18n.of(context).successful_copy); + } + Future downloadFile(MsgModel msg, {CancelToken cancelToken}) async { Response response;