android handle media projection canceled

This commit is contained in:
csf 2022-04-12 20:54:29 +08:00
parent 1662dadfc2
commit bc00375c44
2 changed files with 52 additions and 40 deletions

View File

@ -117,7 +117,6 @@ class MainActivity : FlutterActivity() {
"cancel_notification" -> {
try {
val id = call.arguments as Int
Log.d(logTag,"cancel_notification id:$id")
mainService?.cancelNotification(id)
} finally {
result.success(true)
@ -181,10 +180,13 @@ class MainActivity : FlutterActivity() {
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == MEDIA_REQUEST_CODE && resultCode == Activity.RESULT_OK && data != null) {
Log.d(logTag, "got mediaProjectionResultIntent ok")
if (requestCode == MEDIA_REQUEST_CODE) {
if (resultCode == Activity.RESULT_OK && data != null) {
mediaProjectionResultIntent = data
initService()
} else {
flutterMethodChannel.invokeMethod("on_media_projection_canceled", null)
}
}
}

View File

@ -281,14 +281,19 @@ class ConnectionManager extends StatelessWidget {
clientInfo(entry.value),
entry.value.isFileTransfer
? SizedBox.shrink()
:IconButton(onPressed: (){
: IconButton(
onPressed: () {
FFI.chatModel.changeCurrentID(entry.value.id);
final bar = navigationBarKey.currentWidget;
if (bar != null) {
bar as BottomNavigationBar;
bar.onTap!(1);
}
}, icon: Icon(Icons.chat,color: MyTheme.accent80,))
},
icon: Icon(
Icons.chat,
color: MyTheme.accent80,
))
],
),
ElevatedButton.icon(
@ -406,6 +411,11 @@ void toAndroidChannelInit() {
PermissionManager.complete(type, result);
break;
}
case "on_media_projection_canceled":
{
FFI.serverModel.stopService();
break;
}
}
} catch (e) {
debugPrint("MethodCallHandler err:$e");