@@ -56,9 +56,9 @@ android { | |||
// manifestPlaceholders = [ | |||
// AMAP_KEY : "1fd4e93e3b4b13747da41f484c955fe2", /// 高德地图key | |||
// ] | |||
// ndk { | |||
// abiFilters 'armeabi-v7a' | |||
// } | |||
// ndk { | |||
// abiFilters 'armeabi-v7a' | |||
// } | |||
multiDexEnabled true | |||
manifestPlaceholders = [ | |||
JPUSH_PKGNAME : 'com.cyhd.henhoandroid', | |||
@@ -75,7 +75,7 @@ android { | |||
OPPO_APPKEY : "OP-cd9ece5049514019842f54d537068018", // OPPO平台注册的appkey | |||
OPPO_APPID : "OP-30233397", // OPPO平台注册的appid | |||
OPPO_APPSECRET: "OP-您的应用对应OPPO的APPSECRET",//OPPO平台注册的appsecret | |||
OPPO_APPSECRET: "OP-4c16a9e57e614e72ae518fbb4a55f439",//OPPO平台注册的appsecret | |||
// | |||
// MEIZU_APPKEY:"MZ-您的应用对应的魅族appkey",//魅族平台注册的appkey | |||
@@ -1169,7 +1169,7 @@ | |||
"translation_butler_tips": "您的实时贴身翻译,随时随地帮您解决语言不通", | |||
"choose_language": "请选择要翻译的语言", | |||
"translation_butler_rules": "呼叫管家需要预付H币,管家服务时长为5分钟", | |||
"translation_butler_scenes": "您当所在场景", | |||
"translation_butler_scenes": "您所在场景", | |||
"translation_butler_scenes_tips": "根据大数据显示,选择了场景并描述问题的用户得到了更有效的帮助哦!", | |||
"translation_butler_call": "呼叫管家", | |||
"travel_my_location": "我的位置", | |||
@@ -6,6 +6,6 @@ export "FLUTTER_TARGET=/Users/random/code/flutter/project/hibok/lib/main.dart" | |||
export "FLUTTER_BUILD_DIR=build" | |||
export "SYMROOT=${SOURCE_ROOT}/../build/ios" | |||
export "FLUTTER_FRAMEWORK_DIR=/Users/random/sdk/flutter_sdk/bin/cache/artifacts/engine/ios" | |||
export "FLUTTER_BUILD_NAME=1.1.0" | |||
export "FLUTTER_BUILD_NUMBER=15" | |||
export "FLUTTER_BUILD_NAME=1.1.1" | |||
export "FLUTTER_BUILD_NUMBER=16" | |||
export "TRACK_WIDGET_CREATION=true" |
@@ -803,7 +803,7 @@ | |||
CODE_SIGN_IDENTITY = "Apple Development"; | |||
CODE_SIGN_STYLE = Automatic; | |||
CURRENT_PROJECT_VERSION = 14; | |||
DEVELOPMENT_TEAM = ""; | |||
DEVELOPMENT_TEAM = QJ9M3998Q6; | |||
EMBEDDED_CONTENT_CONTAINS_SWIFT_CODE = YES; | |||
ENABLE_BITCODE = NO; | |||
FRAMEWORK_SEARCH_PATHS = ( | |||
@@ -715,7 +715,7 @@ class _ChatPageState extends State<ChatPage> { | |||
return Container( | |||
padding: EdgeInsets.fromLTRB(10, 10, 10, 10), | |||
color: Colors.white, | |||
decoration: BoxDecoration(color: Colors.white,border: Border(bottom: BorderSide(color: Colors.grey, width: .3))), | |||
child: Row( | |||
children: <Widget>[ | |||
ClipRRect( | |||
@@ -137,8 +137,18 @@ class _ChatPageItemState extends State<ChatPageItem> | |||
if (msg.time == widget.msg.time) { | |||
if (mounted) { | |||
updateTextList(); | |||
if (!mounted) { | |||
return; | |||
if (msg.transTag == 5 || msg.transTag == 6) { | |||
print('人工翻译失败'); | |||
//更新最新的金额 | |||
HttpUtil().getWealth(context, (data) { | |||
if (mounted) { | |||
Provider.of<MoneyChangeProvider>(context) | |||
.initMoney(data['CoinValue']); | |||
Provider.of<VoucherChangeProvider>(context) | |||
.initVoucher(data['Voucher']); | |||
} | |||
}); | |||
} | |||
setState(() { | |||
print('更新翻译文字'); | |||
@@ -1097,6 +1107,16 @@ class _ChatPageItemState extends State<ChatPageItem> | |||
curTextType %= textList.length; | |||
}); | |||
}); | |||
} else if (transTag == 5 || transTag == 6) { | |||
//人工翻译失败 | |||
userTranslateWidget = _translateItemWidget(0xe670, '人工翻译失败', null); | |||
machineTranslateWidget = | |||
_translateItemWidget(0xe671, I18n.of(context).robot_retranslate, () { | |||
setState(() { | |||
curTextType += 1; | |||
curTextType %= textList.length; | |||
}); | |||
}); | |||
} else if (transTag == 4 || transTag == 10) { | |||
//4人工翻译完成,未评论 10人工翻译完成已评论 | |||
userTranslateWidget = InkWell( | |||
@@ -1382,10 +1402,15 @@ class _ChatPageItemState extends State<ChatPageItem> | |||
double width = 130; | |||
double minWidth = 0; | |||
if (textList.length > 0) { | |||
if (textList.length > 0 && textList[curTextType].length>0) { | |||
print('textList哒哒哒哒哒 ${textList[curTextType]}'); | |||
width = _getTextWidth(textList[curTextType]) + 20; | |||
width = min(width, Screen.width - 120); | |||
if(width<130){ | |||
width=130; | |||
} | |||
showMsg.add(Padding( | |||
padding: EdgeInsets.symmetric(vertical: 5), | |||
child: Divider( | |||
@@ -77,7 +77,13 @@ class _DownloadItemState extends State<DownloadItem> { | |||
_downloadWidget() { | |||
if (widget.msg.localFile != null) { | |||
if (widget.msg.msgType == ChatType.ShortVideoChatType.value) { | |||
return Icon(Icons.play_circle_outline, color: Colors.white); | |||
return Container( | |||
padding: EdgeInsets.all(5), | |||
decoration: BoxDecoration( | |||
color: Colors.grey.withAlpha(150), | |||
borderRadius: BorderRadius.circular(8)), | |||
child: Icon(Icons.play_circle_outline, color: Colors.white70), | |||
); | |||
} | |||
} else { | |||
if (widget.msg.state == MsgState.DownloadFailed) { | |||
@@ -118,7 +124,13 @@ class _DownloadItemState extends State<DownloadItem> { | |||
); | |||
} else if (widget.msg.state < MsgState.Downloading) { | |||
if (widget.msg.msgType == ChatType.ShortVideoChatType.value) { | |||
return Icon(Icons.play_circle_outline, color: Colors.white); | |||
return Container( | |||
padding: EdgeInsets.all(5), | |||
decoration: BoxDecoration( | |||
color: Colors.grey.withAlpha(150), | |||
borderRadius: BorderRadius.circular(8)), | |||
child: Icon(Icons.play_circle_outline, color: Colors.white70), | |||
); | |||
} | |||
} | |||
} | |||
@@ -136,8 +136,17 @@ class _GroupChatPageItemState extends State<GroupChatPageItem> | |||
if (msg.time == widget.msg.time) { | |||
if (mounted) { | |||
updateTextList(); | |||
if (!mounted) { | |||
return; | |||
if (msg.transTag == 5 || msg.transTag == 6) { | |||
print('人工翻译失败'); | |||
//更新最新的金额 | |||
HttpUtil().getWealth(context, (data) { | |||
if (mounted) { | |||
Provider.of<MoneyChangeProvider>(context) | |||
.initMoney(data['CoinValue']); | |||
Provider.of<VoucherChangeProvider>(context) | |||
.initVoucher(data['Voucher']); | |||
} | |||
}); | |||
} | |||
setState(() { | |||
print('更新翻译文字'); | |||
@@ -1082,6 +1091,16 @@ class _GroupChatPageItemState extends State<GroupChatPageItem> | |||
curTextType %= textList.length; | |||
}); | |||
}); | |||
} else if (transTag == 5 || transTag == 6) { | |||
//人工翻译失败 | |||
userTranslateWidget = _translateItemWidget(0xe670, '人工翻译失败', null); | |||
machineTranslateWidget = | |||
_translateItemWidget(0xe671, I18n.of(context).robot_retranslate, () { | |||
setState(() { | |||
curTextType += 1; | |||
curTextType %= textList.length; | |||
}); | |||
}); | |||
} else if (transTag == 4 || transTag == 10) { | |||
//4人工翻译完成,未评论 10人工翻译完成已评论 | |||
userTranslateWidget = InkWell( | |||
@@ -1348,11 +1367,15 @@ class _GroupChatPageItemState extends State<GroupChatPageItem> | |||
double width = 130; | |||
double minWidth = 0; | |||
if (textList.length > 0) { | |||
if (textList.length > 0 && textList[curTextType].length>0) { | |||
width = _getTextWidth(textList[curTextType]) + 20; | |||
width = min(width, Screen.width - 120); | |||
minWidth = max(width, 150); | |||
if(width<130){ | |||
width=130; | |||
} | |||
showMsg.add(Padding( | |||
padding: EdgeInsets.symmetric(vertical: 5), | |||
child: Divider( | |||
@@ -161,7 +161,7 @@ class _RecordViewState extends State<RecordView> { | |||
tipStr = I18n.of(context).voice_tips; | |||
} | |||
return Container( | |||
return InkWell(onTap: (){},child: Container( | |||
width: double.infinity, | |||
height: double.infinity, | |||
padding: EdgeInsets.only(top: 10, bottom: 20), | |||
@@ -224,7 +224,7 @@ class _RecordViewState extends State<RecordView> { | |||
} | |||
}else | |||
{ | |||
cancelRecorder(); | |||
cancelRecorder(); | |||
} | |||
}, | |||
onLongPressEnd: (LongPressEndDetails details) { | |||
@@ -262,7 +262,7 @@ class _RecordViewState extends State<RecordView> { | |||
child: Text(tipStr, textScaleFactor: 1.0,), | |||
) | |||
], | |||
)); | |||
)),); | |||
} | |||
checkValideArea(Offset position) { | |||
@@ -1,3 +1,5 @@ | |||
import 'dart:math'; | |||
import 'package:chat/data/group_data_mgr.dart'; | |||
import 'package:chat/models/ChatMsg.dart'; | |||
import 'package:chat/models/last_msg_provider.dart'; | |||
@@ -112,6 +114,38 @@ class ChatDataMgr { | |||
return record; | |||
} | |||
//获取该记录之前的前3条聊天记录 | |||
getForeChatRecord(MsgModel msgModel) { | |||
List res = []; | |||
List record; | |||
if (msgModel.channelType == ChatChannelType.Group.value) { | |||
record = groupRecordMap[msgModel.sessionId]; | |||
} else { | |||
record = msgRecordMap[msgModel.sessionId]; | |||
} | |||
int curIndex = 0; | |||
if (record != null && record.length > 0) { | |||
for (var i = 0; i < record.length; i++) { | |||
if (record[i].time == msgModel.time) { | |||
curIndex = i; | |||
break; | |||
} | |||
} | |||
} | |||
int maxLen = min(curIndex + 1, record.length); | |||
for (var i = curIndex + 1; i < maxLen; i++) { | |||
var shortDesc = record[i].shortRecordForTranslator(); | |||
print(shortDesc); | |||
res.add(shortDesc); | |||
} | |||
return res; | |||
} | |||
//获取企业号聊天记录 | |||
List<MsgModel> getCompanyRecord() { | |||
var record = msgRecordMap[MsgHandler.curActiveSession]; | |||
@@ -176,6 +176,32 @@ class GroupInfoMgr { | |||
return ''; | |||
} | |||
//获取群名 | |||
getGroupName(int groupId) { | |||
for (var i = 0; i < groupInfoList.length; i++) { | |||
var info = groupInfoList[i]; | |||
if (info.sessionId == groupId) { | |||
if (info.name != null && info.name != '') { | |||
return info.name; | |||
} else { | |||
var members = info.getMembersInGroup(); | |||
String res = ''; | |||
int nums = members.length > 4 ? 4 : members.length; | |||
for (int i = 0; i < nums; i++) { | |||
if (i != 0) { | |||
res += '、'; | |||
} | |||
String name = members[i].refName; | |||
res += name.length > 8 ? name.substring(0, 8) + '..' : name; | |||
} | |||
return res; | |||
} | |||
} | |||
} | |||
return ''; | |||
} | |||
//获取群信息 | |||
Future<GroupInfoModel> getGroupInfo(int sessionId, | |||
{bool isSave = true}) async { | |||
@@ -34,6 +34,7 @@ import 'package:shared_preferences/shared_preferences.dart'; | |||
import 'package:chat/utils/my_bottom_navigation_bar.dart' as myBottm; | |||
import 'friend_page.dart'; | |||
import 'group_chat_page.dart'; | |||
class NavigationIconView { | |||
final BottomNavigationBarItem item; | |||
@@ -361,79 +362,22 @@ class _HomeMainState extends State<HomeMain> { | |||
I18n.of(context).me | |||
]; | |||
_navigationViews = [ | |||
NavigationIconView( | |||
title: _titles[2], | |||
icon: IconData( | |||
0xe67c, | |||
fontFamily: 'iconfont', | |||
), | |||
isShowdot: true, | |||
iconSize: 29), | |||
NavigationIconView( | |||
title: _titles[0], | |||
isShowdot: true, | |||
iconMargin: EdgeInsets.only(top: 2), | |||
type: 5, | |||
icon: IconData( | |||
0xe66e, | |||
fontFamily: 'iconfont', | |||
), | |||
iconSize: 26.5), | |||
NavigationIconView( | |||
title: _titles[1], | |||
icon: IconData( | |||
0xe656, | |||
fontFamily: 'iconfont', | |||
), | |||
isCenter: true, | |||
iconSize: 31), | |||
NavigationIconView( | |||
title: _titles[1], | |||
isShowdot: true, | |||
icon: IconData( | |||
0xe60b, | |||
fontFamily: 'iconfont', | |||
), | |||
type: 6, | |||
iconSize: 26.5), | |||
NavigationIconView( | |||
title: _titles[3], | |||
icon: IconData( | |||
0xe67b, | |||
fontFamily: 'iconfont', | |||
), | |||
iconSize: 26.5), | |||
]; | |||
_pages = [ | |||
RealTimeHelperPage(), | |||
FriendPage(), | |||
FindPage(), | |||
ConversActionPage(), | |||
// GroupChatListPage(), | |||
ProfilePage( | |||
userId: UserData().basicInfo.userId, | |||
), | |||
]; | |||
// _navigationViews = [ | |||
// NavigationIconView( | |||
// title: _titles[1], | |||
// isShowdot: true, | |||
// title: _titles[2], | |||
// icon: IconData( | |||
// 0xe60b, | |||
// 0xe67c, | |||
// fontFamily: 'iconfont', | |||
// ), | |||
// type: 1, | |||
// iconSize: 26.5), | |||
// isShowdot: true, | |||
// iconSize: 29), | |||
// NavigationIconView( | |||
// title: _titles[0], | |||
// isShowdot: true, | |||
// iconMargin: EdgeInsets.only(top: 2), | |||
// type: 5, | |||
// icon: IconData( | |||
// 0xe663, | |||
// 0xe66e, | |||
// fontFamily: 'iconfont', | |||
// ), | |||
// iconSize: 26.5), | |||
@@ -445,17 +389,15 @@ class _HomeMainState extends State<HomeMain> { | |||
// ), | |||
// isCenter: true, | |||
// iconSize: 31), | |||
// | |||
// NavigationIconView( | |||
// title: _titles[3], | |||
// title: _titles[1], | |||
// isShowdot: true, | |||
// icon: IconData( | |||
// 0xe66e, | |||
// 0xe60b, | |||
// fontFamily: 'iconfont', | |||
// ), | |||
// type: 4, | |||
// type: 6, | |||
// iconSize: 26.5), | |||
// | |||
// NavigationIconView( | |||
// title: _titles[3], | |||
// icon: IconData( | |||
@@ -466,16 +408,75 @@ class _HomeMainState extends State<HomeMain> { | |||
// ]; | |||
// | |||
// _pages = [ | |||
// ConversActionPage(), | |||
//// RealTimeHelperPage(), | |||
// RealTimeHelperPage(), | |||
// FriendPage(), | |||
// FindPage(), | |||
//// ConversActionPage(), | |||
// GroupChatListPage(), | |||
// ConversActionPage(), | |||
//// GroupChatListPage(), | |||
// ProfilePage( | |||
// userId: UserData().basicInfo.userId, | |||
// ), | |||
// ]; | |||
_navigationViews = [ | |||
NavigationIconView( | |||
title: _titles[1], | |||
isShowdot: true, | |||
icon: IconData( | |||
0xe60b, | |||
fontFamily: 'iconfont', | |||
), | |||
type: 1, | |||
iconSize: 26.5), | |||
NavigationIconView( | |||
title: _titles[0], | |||
isShowdot: true, | |||
iconMargin: EdgeInsets.only(top: 2), | |||
type: 5, | |||
icon: IconData( | |||
0xe663, | |||
fontFamily: 'iconfont', | |||
), | |||
iconSize: 26.5), | |||
NavigationIconView( | |||
title: _titles[1], | |||
icon: IconData( | |||
0xe656, | |||
fontFamily: 'iconfont', | |||
), | |||
isCenter: true, | |||
iconSize: 31), | |||
NavigationIconView( | |||
title: _titles[3], | |||
isShowdot: true, | |||
icon: IconData( | |||
0xe66e, | |||
fontFamily: 'iconfont', | |||
), | |||
type: 4, | |||
iconSize: 26.5), | |||
NavigationIconView( | |||
title: _titles[3], | |||
icon: IconData( | |||
0xe67b, | |||
fontFamily: 'iconfont', | |||
), | |||
iconSize: 26.5), | |||
]; | |||
_pages = [ | |||
ConversActionPage(), | |||
// RealTimeHelperPage(), | |||
FriendPage(), | |||
FindPage(), | |||
// ConversActionPage(), | |||
GroupChatListPage(), | |||
ProfilePage( | |||
userId: UserData().basicInfo.userId, | |||
), | |||
]; | |||
} | |||
@override | |||
@@ -1,10 +1,17 @@ | |||
import 'dart:typed_data'; | |||
import 'dart:convert'; | |||
import 'package:chat/data/UserData.dart'; | |||
import 'package:chat/data/constants.dart'; | |||
import 'package:chat/generated/i18n.dart'; | |||
import 'package:chat/proto/chat.pb.dart'; | |||
import 'package:chat/proto/chat.pbenum.dart'; | |||
import 'package:chat/proto/transhousekeeper.pb.dart'; | |||
import 'package:chat/utils/date_utils.dart'; | |||
import 'package:chat/utils/file_cache_mgr.dart'; | |||
import 'package:chat/utils/sql_util.dart'; | |||
import 'package:chat/data/group_data_mgr.dart'; | |||
import 'package:chat/utils/upload_util.dart'; | |||
class MsgState { | |||
static const int None = 0; //默认 | |||
@@ -134,31 +141,36 @@ class MsgModel { | |||
//获得翻译的结果数组 | |||
getTransTextList() { | |||
List<String> textList = []; | |||
if (translateContent != null && translateContent.length > 0) { | |||
try { | |||
var transTxt = utf8.decode(translateContent); | |||
if (transTxt.contains('[ ')) { | |||
transTxt = transTxt.replaceAll('[ ', '['); | |||
} | |||
if (transTxt.contains(' ]')) { | |||
transTxt = transTxt.replaceAll(' ]', ']'); | |||
} | |||
if (transTag == 5 || transTag == 6) { | |||
print('人工翻译失败'); | |||
} else { | |||
try { | |||
var transTxt = utf8.decode(translateContent); | |||
if (transTxt.contains('[ ')) { | |||
transTxt = transTxt.replaceAll('[ ', '['); | |||
} | |||
if (transTxt.contains(' ]')) { | |||
transTxt = transTxt.replaceAll(' ]', ']'); | |||
} | |||
print('翻译结果:$transTxt'); | |||
print('翻译结果:$transTxt'); | |||
if (altUsers != null && altUsers.length > 0) { | |||
var alterStr = ''; | |||
for (var i = 0; i < altUsers.length; i++) { | |||
var name = GroupInfoMgr().getGroupFdName(sessionId, altUsers[i]); | |||
alterStr = '@$name $alterStr'; | |||
if (altUsers != null && altUsers.length > 0) { | |||
var alterStr = ''; | |||
for (var i = 0; i < altUsers.length; i++) { | |||
var name = GroupInfoMgr().getGroupFdName(sessionId, altUsers[i]); | |||
alterStr = '@$name $alterStr'; | |||
} | |||
transTxt = '$alterStr $transTxt'; | |||
} | |||
transTxt = '$alterStr $transTxt'; | |||
} | |||
textList.add(transTxt); | |||
} catch (e) { | |||
var origin = utf8.decode(msgContent); | |||
print('译文异常,原文 $origin 发送人 $from 发送时间$time'); | |||
textList.add(transTxt); | |||
} catch (e) { | |||
var origin = utf8.decode(msgContent); | |||
print('译文异常,原文 $origin 发送人 $from 发送时间$time'); | |||
} | |||
} | |||
} | |||
@@ -196,4 +208,84 @@ class MsgModel { | |||
return textList; | |||
} | |||
getFileUrl() { | |||
var fullUrl = UploadUtil().getFullUrl(extraFile, sessionId, channelType); | |||
if (extraFile.contains('http://')) { | |||
fullUrl = extraFile; | |||
} | |||
return fullUrl; | |||
} | |||
//发送给翻译人员的记录 | |||
shortRecordForTranslator() { | |||
String desc = ''; | |||
switch (ChatType.valueOf(msgType)) { | |||
case ChatType.TextChatType: | |||
desc = utf8.decode(msgContent); | |||
break; | |||
case ChatType.EmoticonType: | |||
desc = '[${I18n.of(Constants.getCurrentContext()).emoji}]'; | |||
break; | |||
case ChatType.ImageChatType: | |||
case ChatType.ShortVideoChatType: | |||
case ChatType.ShortVoiceChatType: | |||
case ChatType.FileChatType: | |||
desc = getFileUrl(); | |||
break; | |||
case ChatType.PlaceChatType: | |||
desc = '[${I18n.of(Constants.getCurrentContext()).locate}]'; | |||
break; | |||
case ChatType.GiftChatType: | |||
GiftChat giftChat = GiftChat.fromBuffer(msgContent); | |||
if (giftChat.tuId == UserData().basicInfo.userId) { | |||
desc = I18n.of(Constants.getCurrentContext()).you_get; | |||
} else { | |||
desc = I18n.of(Constants.getCurrentContext()).you_give; | |||
} | |||
break; | |||
case ChatType.RedWalletChatType: | |||
if (from == 0) { | |||
//服务器通知消息 | |||
RedWallet wallet = RedWallet.fromBuffer(msgContent); | |||
if (wallet.state == RedWalletState.Received) { | |||
var myId = UserData().basicInfo.userId; | |||
if (wallet.suId == myId) { | |||
desc = I18n.of(Constants.getCurrentContext()) | |||
.get_money | |||
.replaceFirst('/s1', '好友'); | |||
} else { | |||
desc = I18n.of(Constants.getCurrentContext()) | |||
.you_get_money | |||
.replaceFirst('/s1', '好友'); | |||
} | |||
} else if (wallet.state == RedWalletState.Expire) { | |||
desc = I18n.of(Constants.getCurrentContext()).money_over; | |||
} else { | |||
print('WWWWW${wallet.state}'); | |||
} | |||
} else { | |||
desc = '[${I18n.of(Constants.getCurrentContext()).red_money}]'; | |||
} | |||
break; | |||
case ChatType.GroupChatNoticeType: | |||
desc = '群聊通知消息'; | |||
break; | |||
default: | |||
} | |||
return { | |||
'SendTime': DateUtils() | |||
.getFormartData(timeSamp: time, format: 'yyyy:MM:dd hh:mm:ss'), | |||
'Content': desc, | |||
'UserId': from | |||
}; | |||
} | |||
} |
@@ -290,6 +290,38 @@ class QuoteMsg extends $pb.GeneratedMessage { | |||
void clearContent() => clearField(5); | |||
} | |||
class HumanTransFail extends $pb.GeneratedMessage { | |||
static final $pb.BuilderInfo _i = $pb.BuilderInfo('HumanTransFail', package: const $pb.PackageName('yl_pb')) | |||
..a<$core.int>(1, 'money', $pb.PbFieldType.OU3) | |||
..a<$core.int>(2, 'ticket', $pb.PbFieldType.OU3) | |||
..hasRequiredFields = false | |||
; | |||
HumanTransFail._() : super(); | |||
factory HumanTransFail() => create(); | |||
factory HumanTransFail.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); | |||
factory HumanTransFail.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); | |||
HumanTransFail clone() => HumanTransFail()..mergeFromMessage(this); | |||
HumanTransFail copyWith(void Function(HumanTransFail) updates) => super.copyWith((message) => updates(message as HumanTransFail)); | |||
$pb.BuilderInfo get info_ => _i; | |||
@$core.pragma('dart2js:noInline') | |||
static HumanTransFail create() => HumanTransFail._(); | |||
HumanTransFail createEmptyInstance() => create(); | |||
static $pb.PbList<HumanTransFail> createRepeated() => $pb.PbList<HumanTransFail>(); | |||
static HumanTransFail getDefault() => _defaultInstance ??= create()..freeze(); | |||
static HumanTransFail _defaultInstance; | |||
$core.int get money => $_get(0, 0); | |||
set money($core.int v) { $_setUnsignedInt32(0, v); } | |||
$core.bool hasMoney() => $_has(0); | |||
void clearMoney() => clearField(1); | |||
$core.int get ticket => $_get(1, 0); | |||
set ticket($core.int v) { $_setUnsignedInt32(1, v); } | |||
$core.bool hasTicket() => $_has(1); | |||
void clearTicket() => clearField(2); | |||
} | |||
class ChatSendReq extends $pb.GeneratedMessage { | |||
static final $pb.BuilderInfo _i = $pb.BuilderInfo('ChatSendReq', package: const $pb.PackageName('yl_pb')) | |||
..e<ChatChannelType>(1, 'channelType', $pb.PbFieldType.OE, ChatChannelType.Session, ChatChannelType.valueOf, ChatChannelType.values) | |||
@@ -148,6 +148,14 @@ const QuoteMsg$json = const { | |||
], | |||
}; | |||
const HumanTransFail$json = const { | |||
'1': 'HumanTransFail', | |||
'2': const [ | |||
const {'1': 'Money', '3': 1, '4': 1, '5': 13, '10': 'Money'}, | |||
const {'1': 'Ticket', '3': 2, '4': 1, '5': 13, '10': 'Ticket'}, | |||
], | |||
}; | |||
const ChatSendReq$json = const { | |||
'1': 'ChatSendReq', | |||
'2': const [ | |||
@@ -9,18 +9,18 @@ enum ChatChannelType { | |||
} | |||
enum ChatType { | |||
TextChatType = 0; //文字聊天 | |||
ImageChatType = 1; //图片 | |||
ShortVoiceChatType = 2; //短语音 | |||
ShortVideoChatType = 3; //短视频 | |||
RealtimeCallVoiceType = 4; //实时通话-语音 | |||
RealtimeCallVideoType = 5; //实时通话-视频 | |||
RedWalletChatType = 6; //红包 | |||
PlaceChatType = 7; //地址类型 | |||
EmoticonType = 8; //表情 | |||
GroupChatNoticeType = 9; //群公告类型 | |||
GiftChatType = 10; //礼物聊天类型 | |||
FileChatType = 11; //文件聊天类型 | |||
TextChatType = 0; //文字聊天 | |||
ImageChatType = 1; //图片 | |||
ShortVoiceChatType = 2; //短语音 | |||
ShortVideoChatType = 3; //短视频 | |||
RealtimeCallVoiceType = 4; //实时通话-语音 | |||
RealtimeCallVideoType = 5; //实时通话-视频 | |||
RedWalletChatType = 6; //红包 | |||
PlaceChatType = 7; //地址类型 | |||
EmoticonType = 8; //表情 | |||
GroupChatNoticeType = 9; //群公告类型 | |||
GiftChatType = 10; //礼物聊天类型 | |||
FileChatType = 11; //文件聊天类型 | |||
} | |||
enum RedWalletState { | |||
@@ -88,6 +88,12 @@ message QuoteMsg{ | |||
optional string Content = 5; //消息附件地址 | |||
} | |||
//翻译失败返回消息结果 | |||
message HumanTransFail { | |||
optional uint32 Money = 1; //退回h币 | |||
optional uint32 Ticket = 2; //退回翻译券 | |||
} | |||
//-------------------------------------------------------------------------消息-------------------------------------------------------------------------------------------------- | |||
// MsgId=1 聊天消息发送请求 | |||
message ChatSendReq { | |||
@@ -1102,11 +1102,20 @@ class HttpUtil { | |||
showToast('请稍后再试'); | |||
return; | |||
} | |||
data['content'] = base64Encode(File(msgModel.localFile).readAsBytesSync()); | |||
data['content'] = | |||
base64Encode(File(msgModel.localFile).readAsBytesSync()); | |||
print('语音转换的文字: ${utf8.decode(msgModel.enTranslateContent)}'); | |||
data['vcontent'] = base64Encode(msgModel.enTranslateContent); | |||
} | |||
if (msgModel.channelType == ChatChannelType.Group.value) { | |||
data['theme'] = GroupInfoMgr().getGroupName(msgModel.sessionId); | |||
} else { | |||
data['theme'] = ''; | |||
} | |||
data['list'] = ChatDataMgr().getForeChatRecord(msgModel); | |||
data["tuserids"] = [UserData().basicInfo.userId]; | |||
data['duration'] = | |||
msgModel.extraInfo != null ? msgModel.extraInfo ~/ 1000 : 0; | |||
@@ -125,12 +125,12 @@ class MsgHandler { | |||
static createSendMsg(ChatType chatType, content, | |||
{int extra, | |||
int friendId, | |||
String localFile, | |||
MsgModel refMsg, | |||
String refShortTxt, | |||
List<int> altUsers, | |||
ChatChannelType channelType = ChatChannelType.Session}) { | |||
int friendId, | |||
String localFile, | |||
MsgModel refMsg, | |||
String refShortTxt, | |||
List<int> altUsers, | |||
ChatChannelType channelType = ChatChannelType.Session}) { | |||
MsgModel msg; | |||
if (content is String) { | |||
@@ -248,7 +248,7 @@ class MsgHandler { | |||
seq.channelType = ChatChannelType.CSD; | |||
} else { | |||
seq.channelType = | |||
isGroup ? ChatChannelType.Group : ChatChannelType.Session; | |||
isGroup ? ChatChannelType.Group : ChatChannelType.Session; | |||
} | |||
NetWork().sendMsg(ComId.Chat, 5, seq); | |||
@@ -258,7 +258,6 @@ class MsgHandler { | |||
static int mLastClickTime = 0; | |||
static int timeInterval = 2500; | |||
static handlerReceiveMsg(PushChat chat) async { | |||
bool isGroup = false; | |||
bool isTranslateHK = false; | |||
if (chat.channelType == ChatChannelType.Group) { | |||
@@ -267,7 +266,7 @@ class MsgHandler { | |||
} else if (chat.channelType == ChatChannelType.TransHK) { | |||
print('聊天管家消息'); | |||
isTranslateHK = true; | |||
}else if (chat.channelType == ChatChannelType.CSD) { | |||
} else if (chat.channelType == ChatChannelType.CSD) { | |||
print('反馈消息'); | |||
} | |||
@@ -276,6 +275,7 @@ class MsgHandler { | |||
//更新消息 | |||
print('服务器更新消息'); | |||
MsgModel findMsg; | |||
int sessionId = chat.targetId; | |||
var msgList; | |||
@@ -305,6 +305,7 @@ class MsgHandler { | |||
ChatDataMgr().updateLastMsgWithTranslateMsg(chat); | |||
SqlUtil().updateUserTranslateContent(chat.targetId, | |||
chat.sendTime.toInt(), chat.humanTranslate, chat.translateState); | |||
MessageMgr().emit('Update Translate Message', findMsg); | |||
} else if (chat.translateState == 3 || chat.translateState == 2) { | |||
print('机器翻译结果更新'); | |||
@@ -318,10 +319,20 @@ class MsgHandler { | |||
chat.tencentTranslate, | |||
chat.googleTranslate, | |||
chat.translateState); | |||
} | |||
MessageMgr().emit('Update Translate Message', findMsg); | |||
} else if (chat.translateState == 5 || chat.translateState == 6) { | |||
//5翻译失败,6翻译跳过 | |||
print('人工翻译结果更新${chat.targetId},${chat.translateState}'); | |||
findMsg.translateContent = chat.humanTranslate; | |||
var failMsg = HumanTransFail.fromBuffer(chat.humanTranslate); | |||
print('翻译失败消息 : 退还 金币 ${failMsg.money} 券${failMsg.ticket} '); | |||
MessageMgr().emit('Update Translate Message', findMsg); | |||
}else{ | |||
SqlUtil().updateUserTranslateContent(chat.targetId, | |||
chat.sendTime.toInt(), chat.humanTranslate, chat.translateState); | |||
MessageMgr().emit('Update Translate Message', findMsg); | |||
} | |||
} else { | |||
debugPrint2('更新消息找不到!!!!!!'); | |||
} | |||
} else { | |||
@@ -420,51 +431,46 @@ class MsgHandler { | |||
} | |||
} else if (isTranslateHK) { | |||
var myId = UserData().basicInfo.userId; | |||
TransHKChatNotice notice = TransHKChatNotice.fromBuffer(chat.contentBuff); | |||
BaseUserInfo friendId ; | |||
TranslateHKMgr().isUser = myId== notice.employer.id; ///判断自己是翻译官还是用户 | |||
TransHKChatNotice notice = | |||
TransHKChatNotice.fromBuffer(chat.contentBuff); | |||
BaseUserInfo friendId; | |||
TranslateHKMgr().isUser = myId == notice.employer.id; | |||
if(myId== notice.employer.id){ | |||
friendId =notice.inter; | |||
}else{ | |||
///判断自己是翻译官还是用户 | |||
if (myId == notice.employer.id) { | |||
friendId = notice.inter; | |||
} else { | |||
friendId = notice.employer; | |||
} | |||
print('friend id: ${friendId.id} '); | |||
print('结束chat.sendTime ${chat.sendTime}'); | |||
int sessionId = chat.targetId; | |||
if (chat.cType == ChatType.GroupChatNoticeType) { | |||
msgModel = MsgModel(0, friendId.id, chat.cType.value, | |||
chat.contentBuff, chat.sendTime.toInt(), sessionId, | |||
channelType: ChatChannelType.Session.value); | |||
} | |||
///接到开始翻译管家消息-打开翻译管家聊天页面 | |||
if(notice.noticeType==TransHKChatNoticeType.StartChat){ | |||
if(ChatPage.isChatPageActive){ | |||
if (notice.noticeType == TransHKChatNoticeType.StartChat) { | |||
if (ChatPage.isChatPageActive) { | |||
Navigator.of(context).pop(); | |||
} | |||
Future.delayed(Duration(seconds: 1),(){ | |||
Future.delayed(Duration(seconds: 1), () { | |||
TranslateHKMgr().orderStatus = TranslateHKMgr.ORDER_STATUS_EMPTY; | |||
MessageMgr().emit(MessageMgr.TRANSLATE_HK_REFRESH_ORDER ); | |||
MessageMgr().emit(MessageMgr.TRANSLATE_HK_REFRESH_ORDER); | |||
curActiveSession = sessionId; | |||
print('curActiveSession:$curActiveSession'); | |||
MessageMgr().emit(MessageMgr.TRANSLATE_HK_START_CHAT, friendId.id); | |||
MessageMgr() | |||
.emit(MessageMgr.TRANSLATE_HK_START_CHAT, friendId.id); | |||
}); | |||
}else if(notice.noticeType==TransHKChatNoticeType.EndChat){ | |||
} else if (notice.noticeType == TransHKChatNoticeType.EndChat) { | |||
print('chat.contentBuff cccc'); | |||
MessageMgr().emit(MessageMgr.TRANSLATE_HK_END_CHAT, friendId.id); | |||
} | |||
} else { | |||
//私聊通知消息 | |||
@@ -509,7 +515,9 @@ class MsgHandler { | |||
showGroup = groupInfo.messageFree == 0; | |||
} | |||
bool isAt = false;///@的消息无论开不开群打扰都要显示推送 | |||
bool isAt = false; | |||
///@的消息无论开不开群打扰都要显示推送 | |||
if (chat.altUserIds.length > 0) { | |||
print('存在@消息'); | |||
msgModel.altUsers = chat.altUserIds; | |||
@@ -523,8 +531,6 @@ class MsgHandler { | |||
} | |||
} | |||
if (showGroup || isAt) { | |||
int nowTime = DateTime.now().millisecondsSinceEpoch; | |||
@@ -618,7 +624,8 @@ class MsgHandler { | |||
debugPrint2('消息为空,无法保存'); | |||
return; | |||
} | |||
debugPrint2('收到消息,准备保存 会话Id:${msgModel.sessionId} friendId: ${msgModel.friendId} ChatType: ${msgModel.channelType}'); | |||
debugPrint2( | |||
'收到消息,准备保存 会话Id:${msgModel.sessionId} friendId: ${msgModel.friendId} ChatType: ${msgModel.channelType}'); | |||
// showToast('收到消息,准备保存 会话Id:${msgModel.sessionId} friendId: ${msgModel.friendId} ChatType: ${msgModel.channelType}'); | |||
ChatDataMgr().saveMsg(msgModel); | |||
if (msgModel.msgType == ChatType.ShortVoiceChatType.value) { | |||
@@ -863,8 +870,7 @@ class MsgHandler { | |||
ChatDataMgr().updateRecordWithUnreadMsg(noticeList); | |||
} | |||
static int msgCount=0; | |||
static int msgCount = 0; | |||
static handlerServerMsg(int comId, int msgId, List<int> content) { | |||
switch (comId) { | |||
@@ -947,10 +953,9 @@ class MsgHandler { | |||
LocalNotificationUtil.instance | |||
.show(I18n.of(context).notice, I18n.of(context).new_video_msg); | |||
playAudioRing(); | |||
if(TranslateHKMgr().order==null){ | |||
if (TranslateHKMgr().order == null) { | |||
MessageMgr().emit('Receive AudioChat Request', friendId); | |||
} | |||
} | |||
} else if (msgId == 14) { | |||
var msgContent = PushRealtimeCallRespond.fromBuffer(content); | |||
@@ -1014,13 +1019,13 @@ class MsgHandler { | |||
handlerCancelTranslateOrder(content); | |||
} else if (msgId == 20) { | |||
handlerDeliveryInterpreterOrderPush(content); | |||
}else if(msgId==21){ | |||
} else if (msgId == 21) { | |||
handlerCancellationTransHKOrderPush(content); | |||
}else if(msgId==8){ | |||
} else if (msgId == 8) { | |||
handlerEndTransHKOrderRes(content); | |||
}else if(msgId==10){ | |||
} else if (msgId == 10) { | |||
handlerTransHKInterSetIsReceiptRes(content); | |||
}else if(msgId==31){ | |||
} else if (msgId == 31) { | |||
handlerAnotherOrderRes(content); | |||
} | |||
break; | |||
@@ -1034,7 +1039,7 @@ class MsgHandler { | |||
switch (type) { | |||
case 'notice': | |||
///由于极光本地推送点击事件无反应,暂时不走这,由远端推 | |||
///由于极光本地推送点击事件无反应,暂时不走这,由远端推 | |||
String messageJson = map['message']; | |||
Map messageMap = json.decode(messageJson); | |||
@@ -1168,9 +1173,9 @@ class MsgHandler { | |||
Navigator.pushReplacement(context, | |||
MaterialPageRoute<void>(builder: (BuildContext context) { | |||
return GroupChatPage( | |||
key: Key('GroupChat'), groupInfoModel: groupInfoModel); | |||
})); | |||
return GroupChatPage( | |||
key: Key('GroupChat'), groupInfoModel: groupInfoModel); | |||
})); | |||
} else { | |||
switch (res.errorCode) { | |||
case 3007: | |||
@@ -1311,10 +1316,11 @@ class MsgHandler { | |||
} | |||
//发布翻译管家帮助订单 | |||
static sendCreateTranslateOrder(int fromLanguage,int toLanguage,int scences,String extraDesc) { | |||
TranslateHKMgr().isUser=true; | |||
debugPrint2('发布翻译管家帮助订单 fromLanguage:$fromLanguage toLanguage: $toLanguage | ${fromLanguage|toLanguage}' ); | |||
static sendCreateTranslateOrder( | |||
int fromLanguage, int toLanguage, int scences, String extraDesc) { | |||
TranslateHKMgr().isUser = true; | |||
debugPrint2( | |||
'发布翻译管家帮助订单 fromLanguage:$fromLanguage toLanguage: $toLanguage | ${fromLanguage | toLanguage}'); | |||
var seq = IssueTransHKOrderReq.create(); | |||
seq.tLanguage = fromLanguage | toLanguage; | |||
seq.scenes = scences; | |||
@@ -1337,30 +1343,25 @@ class MsgHandler { | |||
} else { | |||
debugPrint2('发布翻译管家帮助订单失败 ${res.errorCode}'); | |||
String errorStr=I18n.of(context).translation_butler_order_failed; | |||
switch(res.errorCode){ | |||
String errorStr = I18n.of(context).translation_butler_order_failed; | |||
switch (res.errorCode) { | |||
case 5014: | |||
case 5014: | |||
errorStr=I18n.of(context).translation_butler_order_failed2; | |||
errorStr = I18n.of(context).translation_butler_order_failed2; | |||
break; | |||
case 5015: | |||
errorStr=I18n.of(context).not_enough; | |||
errorStr = I18n.of(context).not_enough; | |||
break; | |||
} | |||
showToast('$errorStr -${res.errorCode}',duration: Duration(seconds: 3)); | |||
showToast('$errorStr -${res.errorCode}', duration: Duration(seconds: 3)); | |||
TranslateHKMgr().orderStatus = TranslateHKMgr.ORDER_STATUS_EMPTY; | |||
MessageMgr().emit(MessageMgr.TRANSLATE_HK_REFRESH_ORDER); | |||
} | |||
} | |||
//翻译官开启/关闭接收订单 | |||
static translateReceiptOrStopOrder(bool isReceipt) { | |||
debugPrint2('翻译官开启/关闭接收订单 请求 $isReceipt' ); | |||
debugPrint2('翻译官开启/关闭接收订单 请求 $isReceipt'); | |||
var seq = TransHKInterSetIsReceiptReq.create(); | |||
seq.isReceipt = isReceipt; | |||
@@ -1372,7 +1373,8 @@ class MsgHandler { | |||
debugPrint2('翻译官开启/关闭接收订单 回应'); | |||
var res = TransHKInterSetIsReceiptRes.fromBuffer(msgContent); | |||
if (res.errorCode == 0) { | |||
MessageMgr().emit(MessageMgr.TRANSLATE_HK_IS_RECEIVED_ORDER,res.isReceipt); | |||
MessageMgr() | |||
.emit(MessageMgr.TRANSLATE_HK_IS_RECEIVED_ORDER, res.isReceipt); | |||
debugPrint2('翻译官开启/关闭接收订单 回应成功: ${res.isReceipt}'); | |||
} else { | |||
@@ -1380,7 +1382,6 @@ class MsgHandler { | |||
} | |||
} | |||
//撤销订单消息 | |||
static sendCancelTranslateOrder() { | |||
debugPrint2('取消订单 orderid:${TranslateHKMgr().orderId}'); | |||
@@ -1409,31 +1410,28 @@ class MsgHandler { | |||
'OrderId: ${res.orderId} createTime: ${res.createTime} tLanguage:${res.tLanguage} scenes:${res.scenes} desc${res.desc}'); | |||
TranslateOrder order = new TranslateOrder(); | |||
order.orderId=res.orderId; | |||
order.desc=res.desc; | |||
order.createTime=res.createTime.toInt(); | |||
order.tLanguage=res.tLanguage.toInt(); | |||
order.scenes=res.scenes.toInt(); | |||
order.orderId = res.orderId; | |||
order.desc = res.desc; | |||
order.createTime = res.createTime.toInt(); | |||
order.tLanguage = res.tLanguage.toInt(); | |||
order.scenes = res.scenes.toInt(); | |||
order.userName = res.employer.niceName; | |||
TranslateHKMgr().order = order; | |||
MessageMgr().emit(MessageMgr.TRANSLATE_HK_RECEIVE_ORDER, order); | |||
} | |||
//派送订单已被取消 | |||
static handlerCancellationTransHKOrderPush(List<int> msgContent) { | |||
var res = CancellationTransHKOrderPush.fromBuffer(msgContent); | |||
debugPrint2('派送订单已被取消: orderId${res.orderId}'); | |||
// print('OrderId: ${res.orderId} createTime: ${res.createTime} tLanguage:${res.tLanguage} scenes:${res.scenes} desc${res.desc}'); | |||
TranslateHKMgr().order = null; | |||
MessageMgr().emit(MessageMgr.TRANSLATE_HK_CANCEL_ORDER); | |||
showToast(I18n.of(context).translation_butler_order_time_out,duration: Duration(seconds: 3)); | |||
showToast(I18n.of(context).translation_butler_order_time_out, | |||
duration: Duration(seconds: 3)); | |||
} | |||
//接收订单请求 | |||
static sendReceiveOrder() { | |||
TranslateOrder order = TranslateHKMgr().order; | |||
@@ -1456,12 +1454,9 @@ class MsgHandler { | |||
} | |||
} | |||
//用户发送再来一单请求 | |||
static sendAnotherOrderReq() { | |||
debugPrint2('用户发送再来一单请求 orderId:${ TranslateHKMgr().orderId}'); | |||
debugPrint2('用户发送再来一单请求 orderId:${TranslateHKMgr().orderId}'); | |||
var seq = AnotherOrderReq.create(); | |||
seq.orderId = TranslateHKMgr().orderId; | |||
@@ -1481,11 +1476,9 @@ class MsgHandler { | |||
} | |||
} | |||
//用户主动结束翻译管家服务 | |||
static sendEndTransHKOrderReq() { | |||
debugPrint2('用户主动结束翻译管家服务 ${TranslateHKMgr().orderId}' ); | |||
debugPrint2('用户主动结束翻译管家服务 ${TranslateHKMgr().orderId}'); | |||
var seq = EndTransHKOrderReq.create(); | |||
seq.orderId = TranslateHKMgr().orderId; | |||
NetWork().sendMsg(ComId.TranslateOrder, 7, seq); | |||
@@ -1496,7 +1489,6 @@ class MsgHandler { | |||
debugPrint2('用户主动结束翻译管家服务'); | |||
var res = EndTransHKOrderRes.fromBuffer(msgContent); | |||
if (res.errorCode == 0) { | |||
// GroupInfoMgr().updateMemberMsgFree(res.groupId, res.messageFree); | |||
debugPrint2('用户主动结束翻译管家服务 成功: '); | |||
} else { | |||
@@ -1504,11 +1496,6 @@ class MsgHandler { | |||
} | |||
} | |||
//消息免打扰请求结果 | |||
static handlerGroupIsShowMenberNiceName(List<int> msgContent) { | |||
print('设置是否显示群昵称'); | |||
@@ -418,7 +418,7 @@ packages: | |||
name: flutter_inapp_purchase | |||
url: "https://pub.flutter-io.cn" | |||
source: hosted | |||
version: "2.0.6" | |||
version: "2.0.4" | |||
flutter_local_notifications: | |||
dependency: "direct main" | |||
description: | |||
@@ -1,7 +1,7 @@ | |||
name: chat | |||
description: A new Flutter project. | |||
#修改版本号后get-clean | |||
version: 1.1.0+15 | |||
version: 1.1.1+16 | |||
environment: | |||
sdk: ">=2.1.0 <3.0.0" | |||