mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-04-20 01:13:19 +03:00
refact: android audio input, voice call (#8037)
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
@@ -637,40 +637,94 @@ class ConnectionManager extends StatelessWidget {
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
).marginOnly(bottom: 5),
|
||||
client.authorized
|
||||
? Container(
|
||||
alignment: Alignment.centerRight,
|
||||
child: ElevatedButton.icon(
|
||||
style: ButtonStyle(
|
||||
backgroundColor:
|
||||
MaterialStatePropertyAll(Colors.red)),
|
||||
icon: const Icon(Icons.close),
|
||||
onPressed: () {
|
||||
bind.cmCloseConnection(connId: client.id);
|
||||
gFFI.invokeMethod(
|
||||
"cancel_notification", client.id);
|
||||
},
|
||||
label: Text(translate("Disconnect"))))
|
||||
: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
TextButton(
|
||||
child: Text(translate("Dismiss")),
|
||||
onPressed: () {
|
||||
serverModel.sendLoginResponse(
|
||||
client, false);
|
||||
}).marginOnly(right: 15),
|
||||
if (serverModel.approveMode != 'password')
|
||||
ElevatedButton.icon(
|
||||
icon: const Icon(Icons.check),
|
||||
label: Text(translate("Accept")),
|
||||
onPressed: () {
|
||||
serverModel.sendLoginResponse(
|
||||
client, true);
|
||||
}),
|
||||
]),
|
||||
? _buildDisconnectButton(client)
|
||||
: _buildNewConnectionHint(serverModel, client),
|
||||
if (client.incomingVoiceCall && !client.inVoiceCall)
|
||||
..._buildNewVoiceCallHint(context, serverModel, client),
|
||||
])))
|
||||
.toList());
|
||||
}
|
||||
|
||||
Widget _buildDisconnectButton(Client client) {
|
||||
final disconnectButton = ElevatedButton.icon(
|
||||
style: ButtonStyle(backgroundColor: MaterialStatePropertyAll(Colors.red)),
|
||||
icon: const Icon(Icons.close),
|
||||
onPressed: () {
|
||||
bind.cmCloseConnection(connId: client.id);
|
||||
gFFI.invokeMethod("cancel_notification", client.id);
|
||||
},
|
||||
label: Text(translate("Disconnect")),
|
||||
);
|
||||
final buttons = [disconnectButton];
|
||||
if (client.inVoiceCall) {
|
||||
buttons.insert(
|
||||
0,
|
||||
ElevatedButton.icon(
|
||||
style: ButtonStyle(
|
||||
backgroundColor: MaterialStatePropertyAll(Colors.red)),
|
||||
icon: const Icon(Icons.phone),
|
||||
label: Text(translate("Stop")),
|
||||
onPressed: () {
|
||||
bind.cmCloseVoiceCall(id: client.id);
|
||||
gFFI.invokeMethod("cancel_notification", client.id);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (buttons.length == 1) {
|
||||
return Container(
|
||||
alignment: Alignment.centerRight,
|
||||
child: disconnectButton,
|
||||
);
|
||||
} else {
|
||||
return Row(
|
||||
children: buttons,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildNewConnectionHint(ServerModel serverModel, Client client) {
|
||||
return Row(mainAxisAlignment: MainAxisAlignment.end, children: [
|
||||
TextButton(
|
||||
child: Text(translate("Dismiss")),
|
||||
onPressed: () {
|
||||
serverModel.sendLoginResponse(client, false);
|
||||
}).marginOnly(right: 15),
|
||||
if (serverModel.approveMode != 'password')
|
||||
ElevatedButton.icon(
|
||||
icon: const Icon(Icons.check),
|
||||
label: Text(translate("Accept")),
|
||||
onPressed: () {
|
||||
serverModel.sendLoginResponse(client, true);
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
List<Widget> _buildNewVoiceCallHint(
|
||||
BuildContext context, ServerModel serverModel, Client client) {
|
||||
return [
|
||||
Text(
|
||||
translate("android_new_voice_call_tip"),
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
).marginOnly(bottom: 5),
|
||||
Row(mainAxisAlignment: MainAxisAlignment.end, children: [
|
||||
TextButton(
|
||||
child: Text(translate("Dismiss")),
|
||||
onPressed: () {
|
||||
serverModel.handleVoiceCall(client, false);
|
||||
}).marginOnly(right: 15),
|
||||
if (serverModel.approveMode != 'password')
|
||||
ElevatedButton.icon(
|
||||
icon: const Icon(Icons.check),
|
||||
label: Text(translate("Accept")),
|
||||
onPressed: () {
|
||||
serverModel.handleVoiceCall(client, true);
|
||||
}),
|
||||
])
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
class PaddingCard extends StatelessWidget {
|
||||
@@ -787,6 +841,15 @@ void androidChannelInit() {
|
||||
gFFI.serverModel.stopService();
|
||||
break;
|
||||
}
|
||||
case "msgbox":
|
||||
{
|
||||
var type = arguments["type"] as String;
|
||||
var title = arguments["title"] as String;
|
||||
var text = arguments["text"] as String;
|
||||
var link = (arguments["link"] ?? '') as String;
|
||||
msgBox(gFFI.sessionId, type, title, text, link, gFFI.dialogManager);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
debugPrintStack(label: "MethodCallHandler err:$e");
|
||||
|
||||
Reference in New Issue
Block a user