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 {
|
Intent(activity, MainService::class.java).also {
|
||||||
bindService(it, serviceConnection, Context.BIND_AUTO_CREATE)
|
bindService(it, serviceConnection, Context.BIND_AUTO_CREATE)
|
||||||
}
|
}
|
||||||
if(mainService?.isReady == true){
|
if (mainService?.isReady == true) {
|
||||||
result.success(false)
|
result.success(false)
|
||||||
return@setMethodCallHandler
|
return@setMethodCallHandler
|
||||||
}
|
}
|
||||||
@ -58,7 +58,7 @@ class MainActivity : FlutterActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
"stop_service" -> {
|
"stop_service" -> {
|
||||||
Log.d(logTag,"Stop service")
|
Log.d(logTag, "Stop service")
|
||||||
mainService?.let {
|
mainService?.let {
|
||||||
it.destroy()
|
it.destroy()
|
||||||
result.success(true)
|
result.success(true)
|
||||||
@ -67,14 +67,14 @@ class MainActivity : FlutterActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
"check_permission" -> {
|
"check_permission" -> {
|
||||||
if(call.arguments is String){
|
if (call.arguments is String) {
|
||||||
result.success(checkPermission(context, call.arguments as String))
|
result.success(checkPermission(context, call.arguments as String))
|
||||||
} else {
|
} else {
|
||||||
result.success(false)
|
result.success(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"request_permission" -> {
|
"request_permission" -> {
|
||||||
if(call.arguments is String){
|
if (call.arguments is String) {
|
||||||
requestPermission(context, call.arguments as String)
|
requestPermission(context, call.arguments as String)
|
||||||
result.success(true)
|
result.success(true)
|
||||||
} else {
|
} else {
|
||||||
@ -117,14 +117,13 @@ class MainActivity : FlutterActivity() {
|
|||||||
"cancel_notification" -> {
|
"cancel_notification" -> {
|
||||||
try {
|
try {
|
||||||
val id = call.arguments as Int
|
val id = call.arguments as Int
|
||||||
Log.d(logTag,"cancel_notification id:$id")
|
|
||||||
mainService?.cancelNotification(id)
|
mainService?.cancelNotification(id)
|
||||||
}finally {
|
} finally {
|
||||||
result.success(true)
|
result.success(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else -> {
|
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?) {
|
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||||
super.onActivityResult(requestCode, resultCode, data)
|
super.onActivityResult(requestCode, resultCode, data)
|
||||||
if (requestCode == MEDIA_REQUEST_CODE && resultCode == Activity.RESULT_OK && data != null) {
|
if (requestCode == MEDIA_REQUEST_CODE) {
|
||||||
Log.d(logTag, "got mediaProjectionResultIntent ok")
|
if (resultCode == Activity.RESULT_OK && data != null) {
|
||||||
mediaProjectionResultIntent = data
|
mediaProjectionResultIntent = data
|
||||||
initService()
|
initService()
|
||||||
|
} else {
|
||||||
|
flutterMethodChannel.invokeMethod("on_media_projection_canceled", null)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,8 +82,8 @@ class ServerPage extends StatelessWidget implements PageShape {
|
|||||||
void checkService() async {
|
void checkService() async {
|
||||||
FFI.invokeMethod("check_service"); // jvm
|
FFI.invokeMethod("check_service"); // jvm
|
||||||
// for Android 10/11,MANAGE_EXTERNAL_STORAGE permission from a system setting page
|
// for Android 10/11,MANAGE_EXTERNAL_STORAGE permission from a system setting page
|
||||||
if(PermissionManager.isWaitingFile() && !FFI.serverModel.fileOk){
|
if (PermissionManager.isWaitingFile() && !FFI.serverModel.fileOk) {
|
||||||
PermissionManager.complete("file",await PermissionManager.check("file"));
|
PermissionManager.complete("file", await PermissionManager.check("file"));
|
||||||
debugPrint("file permission finished");
|
debugPrint("file permission finished");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -280,15 +280,20 @@ class ConnectionManager extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
clientInfo(entry.value),
|
clientInfo(entry.value),
|
||||||
entry.value.isFileTransfer
|
entry.value.isFileTransfer
|
||||||
?SizedBox.shrink()
|
? SizedBox.shrink()
|
||||||
:IconButton(onPressed: (){
|
: IconButton(
|
||||||
FFI.chatModel.changeCurrentID(entry.value.id);
|
onPressed: () {
|
||||||
final bar = navigationBarKey.currentWidget;
|
FFI.chatModel.changeCurrentID(entry.value.id);
|
||||||
if(bar!=null){
|
final bar = navigationBarKey.currentWidget;
|
||||||
bar as BottomNavigationBar;
|
if (bar != null) {
|
||||||
bar.onTap!(1);
|
bar as BottomNavigationBar;
|
||||||
}
|
bar.onTap!(1);
|
||||||
}, icon: Icon(Icons.chat,color: MyTheme.accent80,))
|
}
|
||||||
|
},
|
||||||
|
icon: Icon(
|
||||||
|
Icons.chat,
|
||||||
|
color: MyTheme.accent80,
|
||||||
|
))
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
ElevatedButton.icon(
|
ElevatedButton.icon(
|
||||||
@ -360,24 +365,24 @@ Widget clientInfo(Client client) {
|
|||||||
return Padding(
|
return Padding(
|
||||||
padding: EdgeInsets.symmetric(vertical: 8),
|
padding: EdgeInsets.symmetric(vertical: 8),
|
||||||
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
CircleAvatar(
|
CircleAvatar(
|
||||||
child: Text(client.name[0]), backgroundColor: MyTheme.border),
|
child: Text(client.name[0]), backgroundColor: MyTheme.border),
|
||||||
SizedBox(width: 12),
|
SizedBox(width: 12),
|
||||||
Column(
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Text(client.name,
|
Text(client.name,
|
||||||
style: TextStyle(color: MyTheme.idColor, fontSize: 20)),
|
style: TextStyle(color: MyTheme.idColor, fontSize: 20)),
|
||||||
SizedBox(width: 8),
|
SizedBox(width: 8),
|
||||||
Text(client.peerId,
|
Text(client.peerId,
|
||||||
style: TextStyle(color: MyTheme.idColor, fontSize: 10))
|
style: TextStyle(color: MyTheme.idColor, fontSize: 10))
|
||||||
])
|
])
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
|
|
||||||
void toAndroidChannelInit() {
|
void toAndroidChannelInit() {
|
||||||
@ -406,6 +411,11 @@ void toAndroidChannelInit() {
|
|||||||
PermissionManager.complete(type, result);
|
PermissionManager.complete(type, result);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case "on_media_projection_canceled":
|
||||||
|
{
|
||||||
|
FFI.serverModel.stopService();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
debugPrint("MethodCallHandler err:$e");
|
debugPrint("MethodCallHandler err:$e");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user