更新打包apk配置文件信息和代码修改

This commit is contained in:
apple 2022-08-11 18:30:23 +08:00
parent ba45554dfa
commit e7c60497ad
4 changed files with 118 additions and 60 deletions

View File

@ -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 {

View File

@ -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);
// });
// }
}

View File

@ -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),

View File

@ -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(