更新打包apk配置文件信息和代码修改
This commit is contained in:
parent
ba45554dfa
commit
e7c60497ad
|
|
@ -25,6 +25,10 @@ apply plugin: 'com.android.application'
|
|||
apply plugin: 'kotlin-android'
|
||||
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
|
||||
|
||||
def keystorePropertiesFile = rootProject.file("key.properties")
|
||||
def keystoreProperties = new Properties()
|
||||
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
|
||||
|
||||
android {
|
||||
compileSdkVersion flutter.compileSdkVersion
|
||||
ndkVersion flutter.ndkVersion
|
||||
|
|
@ -48,18 +52,37 @@ android {
|
|||
// You can update the following values to match your application needs.
|
||||
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
|
||||
minSdkVersion flutter.minSdkVersion
|
||||
targetSdkVersion flutter.targetSdkVersion
|
||||
// targetSdkVersion flutter.targetSdkVersion
|
||||
targetSdkVersion 33
|
||||
versionCode flutterVersionCode.toInteger()
|
||||
versionName flutterVersionName
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
release {
|
||||
keyAlias keystoreProperties['keyAlias']
|
||||
keyPassword keystoreProperties['keyPassword']
|
||||
storeFile file(keystoreProperties['storeFile'])
|
||||
storePassword keystoreProperties['storePassword']
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
// TODO: Add your own signing config for the release build.
|
||||
// Signing with the debug keys for now, so `flutter run --release` works.
|
||||
signingConfig signingConfigs.release
|
||||
}
|
||||
debug {
|
||||
signingConfig signingConfigs.debug
|
||||
}
|
||||
}
|
||||
|
||||
// buildTypes {
|
||||
// release {
|
||||
// // TODO: Add your own signing config for the release build.
|
||||
// // Signing with the debug keys for now, so `flutter run --release` works.
|
||||
// signingConfig signingConfigs.debug
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
flutter {
|
||||
|
|
|
|||
|
|
@ -84,17 +84,13 @@ class _CreateRoomPageState extends State<CreateRoomPage> {
|
|||
|
||||
_onJoin(agoraToken, userName, roomId, ClientRole.Broadcaster);
|
||||
|
||||
// Future.delayed(Duration(seconds: 3), () {
|
||||
// _onJoin(agoraToken, userName, roomId, ClientRole.Broadcaster);
|
||||
// });
|
||||
|
||||
// if (agoraToken != null && agoraToken.isNotEmpty) {
|
||||
// _engine = await RtcEngine.create(APP_ID); // 初始化引擎
|
||||
// _engine.joinChannel(agoraToken, roomId, null, int.parse(uid)); // 加入频道
|
||||
|
||||
// timer = Timer.periodic(Duration(seconds: 1), (timer) async {
|
||||
// _lodingCreate(agoraToken);
|
||||
// });
|
||||
// timer = Timer.periodic(Duration(seconds: 1), (timer) async {
|
||||
// _lodingCreate(agoraToken);
|
||||
// });
|
||||
// }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ class _PalRoomPageState extends State<PalRoomPage> {
|
|||
|
||||
late RtcEngine _engine; // RtcEngine 声网实例变量
|
||||
late IOWebSocketChannel _wsChannel; // webSocket 实例变量
|
||||
|
||||
late Timer timer; // 轮询定时器
|
||||
// 房间座位
|
||||
List _list = [
|
||||
{'nickname': '', 'flag': false, 'image': 'images/palRoom/voice2.png'},
|
||||
|
|
@ -75,14 +75,6 @@ class _PalRoomPageState extends State<PalRoomPage> {
|
|||
super.initState();
|
||||
|
||||
initialize();
|
||||
|
||||
// if (widget.role == ClientRole.Broadcaster) {
|
||||
// _infoStrings.insert(0, {'type': 'system', 'content': '您身份为主播,已经上麦状态'});
|
||||
// } else if (widget.role == ClientRole.Audience) {
|
||||
// _infoStrings.insert(0, {'type': 'system', 'content': '您身份为观众,点击麦克风图标上麦'});
|
||||
// }
|
||||
|
||||
wsInitalize();
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
@ -92,14 +84,15 @@ class _PalRoomPageState extends State<PalRoomPage> {
|
|||
_engine.leaveChannel();
|
||||
_engine.destroy();
|
||||
_wsChannel.sink.close();
|
||||
timer.cancel();
|
||||
}
|
||||
|
||||
Future<void> initialize() async {
|
||||
_infoStrings.insert(0, {
|
||||
'type': 'system',
|
||||
'content':
|
||||
'|令牌:${widget.agoraToken}|用户名:${widget.userName}|房间:${widget.channelName}|身份:${widget.role}'
|
||||
});
|
||||
// _infoStrings.insert(0, {
|
||||
// 'type': 'system',
|
||||
// 'content':
|
||||
// '|令牌:${widget.agoraToken}|用户名:${widget.userName}|房间:${widget.channelName}|身份:${widget.role}'
|
||||
// });
|
||||
|
||||
// 判断appid是否存在
|
||||
if (APP_ID.isEmpty) {
|
||||
|
|
@ -113,6 +106,12 @@ class _PalRoomPageState extends State<PalRoomPage> {
|
|||
return;
|
||||
}
|
||||
|
||||
if (widget.role == ClientRole.Broadcaster) {
|
||||
_infoStrings.insert(0, {'type': 'system', 'content': '您身份为主播,已经上麦状态'});
|
||||
} else if (widget.role == ClientRole.Audience) {
|
||||
_infoStrings.insert(0, {'type': 'system', 'content': '您身份为观众,点击麦克风图标上麦'});
|
||||
}
|
||||
|
||||
_engine = await RtcEngine.create(APP_ID); // 初始化引擎
|
||||
await _engine.enableAudio(); // 启用音频模块
|
||||
await _engine.setDefaultAudioRouteToSpeakerphone(
|
||||
|
|
@ -120,35 +119,62 @@ class _PalRoomPageState extends State<PalRoomPage> {
|
|||
await _engine.setAudioProfile(AudioProfile.SpeechStandard,
|
||||
AudioScenario.ChatRoomEntertainment); // 设置音频编码属性和音频场景
|
||||
await _engine.setChannelProfile(ChannelProfile.LiveBroadcasting);
|
||||
await _engine.setClientRole(widget.role!);
|
||||
|
||||
_addAgoraEventHandlers(); // 调用状态文字信息列表方法
|
||||
|
||||
if (widget.role == ClientRole.Broadcaster) {
|
||||
await _engine.setClientRole(ClientRole.Broadcaster);
|
||||
}
|
||||
// if (widget.role == ClientRole.Broadcaster) {
|
||||
// await _engine.setClientRole(ClientRole.Broadcaster);
|
||||
// }
|
||||
|
||||
String uid = await Storage.get('id');
|
||||
|
||||
await _engine.joinChannel(
|
||||
widget.agoraToken, widget.channelName, null, int.parse(uid)); // 加入频道
|
||||
|
||||
_detail();
|
||||
timer = Timer.periodic(Duration(seconds: 1), (timer) async {
|
||||
_lodingCreate();
|
||||
});
|
||||
}
|
||||
|
||||
wsInitalize() async {
|
||||
String uid = await Storage.get('id');
|
||||
_wsChannel = IOWebSocketChannel.connect(
|
||||
'ws://101.35.117.69:9093/chat/api/chat/room/${int.parse(uid)}'); // 建立链接
|
||||
void _lodingCreate() async {
|
||||
var res =
|
||||
await MyHttpUtil().get("/chat/api/room/create/${widget.channelName}");
|
||||
String userName = await Storage.get('userName'); // 用户名
|
||||
print('_lodingCreate:${res.data}');
|
||||
if (res.data == true) {
|
||||
timer.cancel();
|
||||
wsInitalize();
|
||||
_detail();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> wsInitalize() async {
|
||||
Map<String, dynamic> headers = new Map();
|
||||
var token = await Storage.get('token');
|
||||
|
||||
print('/=/=/=/=/=//=/=/=/=/=//=/=/=/=/=//=/=/=/=/=/');
|
||||
|
||||
headers['Authorization'] = 'Bearer ${token}';
|
||||
|
||||
print(headers);
|
||||
print(widget.channelName);
|
||||
|
||||
_wsChannel = IOWebSocketChannel.connect(
|
||||
'ws://101.35.117.69:9093/chat/api/chat/room/${widget.channelName}',
|
||||
headers: headers,
|
||||
); // 建立链接
|
||||
|
||||
print('/=/=/=/=/=//=/=/=/=/=//=/=/=/=/=//=/=/=/=/=/');
|
||||
|
||||
print('object');
|
||||
_wsChannel.stream.listen((data) {
|
||||
var aa = jsonDecode(data);
|
||||
print('收到服务器数据:${aa}');
|
||||
var information = jsonDecode(data);
|
||||
print('收到服务器数据:${information}');
|
||||
setState(() {
|
||||
_infoStrings.insert(0, {
|
||||
'type': 'speak',
|
||||
'content': '${aa['message']}',
|
||||
'name': '${aa['username']}'
|
||||
'content': '${information['message']}',
|
||||
'name': '${information['nickname']}'
|
||||
});
|
||||
});
|
||||
}, onDone: () {
|
||||
|
|
@ -194,6 +220,12 @@ class _PalRoomPageState extends State<PalRoomPage> {
|
|||
}
|
||||
|
||||
print('-----------------${_list}-----------------');
|
||||
|
||||
// // 房间空无一人的时候返回首页
|
||||
// if (newUserList.isEmpty) {
|
||||
// Navigator.of(context).pushReplacementNamed('/');
|
||||
// return;
|
||||
// }
|
||||
}
|
||||
|
||||
void _addAgoraEventHandlers() {
|
||||
|
|
@ -209,7 +241,7 @@ class _PalRoomPageState extends State<PalRoomPage> {
|
|||
_detail();
|
||||
// 用户加入
|
||||
setState(() {
|
||||
final info = '用户加入: uid $uid';
|
||||
final info = '用户用户$uid加入房间';
|
||||
_infoStrings.insert(0, {'type': 'system', 'content': info});
|
||||
// _users.add(uid);
|
||||
});
|
||||
|
|
@ -218,7 +250,7 @@ class _PalRoomPageState extends State<PalRoomPage> {
|
|||
_detail();
|
||||
// 加入频道成功
|
||||
setState(() {
|
||||
final info = '加入频道成功: $channel, uid: $uid';
|
||||
final info = '用户$uid加入频道号$channel成功';
|
||||
_infoStrings.insert(0, {'type': 'system', 'content': info});
|
||||
});
|
||||
},
|
||||
|
|
@ -234,7 +266,7 @@ class _PalRoomPageState extends State<PalRoomPage> {
|
|||
_detail();
|
||||
// 用户离开当前频道
|
||||
setState(() {
|
||||
final info = '用户离开当前频道: $uid , reason: $reason';
|
||||
final info = '用户$uid离开当前频道, reason: $reason';
|
||||
_infoStrings.insert(0, {'type': 'system', 'content': info});
|
||||
// _users.remove(uid);
|
||||
});
|
||||
|
|
@ -251,7 +283,7 @@ class _PalRoomPageState extends State<PalRoomPage> {
|
|||
_detail();
|
||||
// 成功重新加入频道回调
|
||||
setState(() {
|
||||
final info = '用户成功重新加入: $uid';
|
||||
final info = '用户$uid重新加入成功';
|
||||
_infoStrings.insert(0, {'type': 'system', 'content': info});
|
||||
// _users.add(uid);
|
||||
});
|
||||
|
|
@ -330,6 +362,12 @@ class _PalRoomPageState extends State<PalRoomPage> {
|
|||
// 下麦再将身份改回为观众(下麦不代表离开频道)
|
||||
_engine.setClientRole(ClientRole.Audience);
|
||||
Navigator.pop(context);
|
||||
|
||||
// // 房间空无一人的时候返回首页
|
||||
if (newUserList.isEmpty) {
|
||||
Navigator.of(context).pushReplacementNamed('/');
|
||||
return;
|
||||
}
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
|
|
@ -383,7 +421,8 @@ class _PalRoomPageState extends State<PalRoomPage> {
|
|||
),
|
||||
),
|
||||
SizedBox(width: 5),
|
||||
Text('以冬', style: TextStyle(color: Colors.white, fontSize: 14)),
|
||||
Text(_list.length > 0 ? _list[0]['nickname'] : '加入中',
|
||||
style: TextStyle(color: Colors.white, fontSize: 14)),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
@ -578,27 +617,16 @@ class _PalRoomPageState extends State<PalRoomPage> {
|
|||
),
|
||||
child: TextField(
|
||||
textInputAction: TextInputAction.send, // 键盘右下角图标
|
||||
// onEditingComplete: () async {
|
||||
// late String speak = _controller.text.trim();
|
||||
// if (speak.isEmpty) {
|
||||
// showToast("请输入聊天内容~");
|
||||
// return;
|
||||
// }
|
||||
// String userName = await Storage.get('userName'); // 用户名
|
||||
|
||||
// _wsChannel.sink.add(speak);
|
||||
|
||||
// // _controller.text = '';
|
||||
// },
|
||||
onSubmitted: (value) async {
|
||||
late String speak = value.trim();
|
||||
onSubmitted: (value) {
|
||||
late String speak = _controller.text.trim();
|
||||
if (speak.isEmpty) {
|
||||
showToast("请输入聊天内容~");
|
||||
return;
|
||||
}
|
||||
String userName = await Storage.get('userName'); // 用户名
|
||||
|
||||
print(speak);
|
||||
_wsChannel.sink.add(speak);
|
||||
|
||||
_controller.clear();
|
||||
},
|
||||
controller: _controller,
|
||||
decoration: InputDecoration(
|
||||
|
|
@ -618,6 +646,17 @@ class _PalRoomPageState extends State<PalRoomPage> {
|
|||
),
|
||||
GestureDetector(
|
||||
// 加号图标
|
||||
onTap: () {
|
||||
late String speak = _controller.text.trim();
|
||||
if (speak.isEmpty) {
|
||||
showToast("请输入聊天内容~");
|
||||
return;
|
||||
}
|
||||
print(speak);
|
||||
_wsChannel.sink.add(speak);
|
||||
|
||||
_controller.clear();
|
||||
},
|
||||
child: Icon(Icons.add,
|
||||
color: Color.fromRGBO(201, 201, 201, 1), size: 25.0),
|
||||
),
|
||||
|
|
@ -670,7 +709,7 @@ class _PalRoomPageState extends State<PalRoomPage> {
|
|||
Row(
|
||||
children: [
|
||||
Text(
|
||||
'以冬',
|
||||
_list.length > 0 ? _list[0]['nickname'] : '加入中',
|
||||
style: TextStyle(color: Colors.white, fontSize: 12),
|
||||
),
|
||||
SizedBox(width: 5),
|
||||
|
|
|
|||
|
|
@ -389,7 +389,7 @@ class _ViewsWidgetState extends State<ViewsWidget> {
|
|||
),
|
||||
SizedBox(width: 5),
|
||||
Text(
|
||||
_data[index]['id'],
|
||||
'${_data[index]['userCount']}人',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
color: Color.fromRGBO(
|
||||
|
|
|
|||
Loading…
Reference in New Issue