android handle media projection canceled
This commit is contained in:
parent
1662dadfc2
commit
bc00375c44
@ -43,7 +43,7 @@ class MainActivity : FlutterActivity() {
|
||||
Intent(activity, MainService::class.java).also {
|
||||
bindService(it, serviceConnection, Context.BIND_AUTO_CREATE)
|
||||
}
|
||||
if(mainService?.isReady == true){
|
||||
if (mainService?.isReady == true) {
|
||||
result.success(false)
|
||||
return@setMethodCallHandler
|
||||
}
|
||||
@ -58,7 +58,7 @@ class MainActivity : FlutterActivity() {
|
||||
}
|
||||
}
|
||||
"stop_service" -> {
|
||||
Log.d(logTag,"Stop service")
|
||||
Log.d(logTag, "Stop service")
|
||||
mainService?.let {
|
||||
it.destroy()
|
||||
result.success(true)
|
||||
@ -67,14 +67,14 @@ class MainActivity : FlutterActivity() {
|
||||
}
|
||||
}
|
||||
"check_permission" -> {
|
||||
if(call.arguments is String){
|
||||
if (call.arguments is String) {
|
||||
result.success(checkPermission(context, call.arguments as String))
|
||||
} else {
|
||||
result.success(false)
|
||||
}
|
||||
}
|
||||
"request_permission" -> {
|
||||
if(call.arguments is String){
|
||||
if (call.arguments is String) {
|
||||
requestPermission(context, call.arguments as String)
|
||||
result.success(true)
|
||||
} else {
|
||||
@ -117,14 +117,13 @@ class MainActivity : FlutterActivity() {
|
||||
"cancel_notification" -> {
|
||||
try {
|
||||
val id = call.arguments as Int
|
||||
Log.d(logTag,"cancel_notification id:$id")
|
||||
mainService?.cancelNotification(id)
|
||||
}finally {
|
||||
} finally {
|
||||
result.success(true)
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
result.error("-1","No such method",null)
|
||||
result.error("-1", "No such method", null)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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")
|
||||
mediaProjectionResultIntent = data
|
||||
initService()
|
||||
if (requestCode == MEDIA_REQUEST_CODE) {
|
||||
if (resultCode == Activity.RESULT_OK && data != null) {
|
||||
mediaProjectionResultIntent = data
|
||||
initService()
|
||||
} else {
|
||||
flutterMethodChannel.invokeMethod("on_media_projection_canceled", null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,8 +82,8 @@ class ServerPage extends StatelessWidget implements PageShape {
|
||||
void checkService() async {
|
||||
FFI.invokeMethod("check_service"); // jvm
|
||||
// for Android 10/11,MANAGE_EXTERNAL_STORAGE permission from a system setting page
|
||||
if(PermissionManager.isWaitingFile() && !FFI.serverModel.fileOk){
|
||||
PermissionManager.complete("file",await PermissionManager.check("file"));
|
||||
if (PermissionManager.isWaitingFile() && !FFI.serverModel.fileOk) {
|
||||
PermissionManager.complete("file", await PermissionManager.check("file"));
|
||||
debugPrint("file permission finished");
|
||||
}
|
||||
}
|
||||
@ -280,15 +280,20 @@ class ConnectionManager extends StatelessWidget {
|
||||
children: [
|
||||
clientInfo(entry.value),
|
||||
entry.value.isFileTransfer
|
||||
?SizedBox.shrink()
|
||||
: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,))
|
||||
? SizedBox.shrink()
|
||||
: 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,
|
||||
))
|
||||
],
|
||||
),
|
||||
ElevatedButton.icon(
|
||||
@ -360,24 +365,24 @@ Widget clientInfo(Client client) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 8),
|
||||
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||
Row(
|
||||
children: [
|
||||
CircleAvatar(
|
||||
child: Text(client.name[0]), backgroundColor: MyTheme.border),
|
||||
SizedBox(width: 12),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(client.name,
|
||||
style: TextStyle(color: MyTheme.idColor, fontSize: 20)),
|
||||
SizedBox(width: 8),
|
||||
Text(client.peerId,
|
||||
style: TextStyle(color: MyTheme.idColor, fontSize: 10))
|
||||
])
|
||||
],
|
||||
),
|
||||
]));
|
||||
Row(
|
||||
children: [
|
||||
CircleAvatar(
|
||||
child: Text(client.name[0]), backgroundColor: MyTheme.border),
|
||||
SizedBox(width: 12),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(client.name,
|
||||
style: TextStyle(color: MyTheme.idColor, fontSize: 20)),
|
||||
SizedBox(width: 8),
|
||||
Text(client.peerId,
|
||||
style: TextStyle(color: MyTheme.idColor, fontSize: 10))
|
||||
])
|
||||
],
|
||||
),
|
||||
]));
|
||||
}
|
||||
|
||||
void toAndroidChannelInit() {
|
||||
@ -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");
|
||||
|
Loading…
x
Reference in New Issue
Block a user