基于自定义规则的番剧采集APP,支持流媒体在线观看,支持弹幕,支持实时超分辨率。
fix android multi window mode
Prediditaa62af000726
diff --git a/README.md b/README.mdindex fb8e964e..ab091fd5 100644--- a/README.md+++ b/README.md@@ -56,7 +56,7 @@对于 GNU/Linux 用户,可以从 Flathub 安装:-[](https://flathub.org/apps/io.github.Predidit.Kazumi)+[](https://flathub.org/apps/io.github.Predidit.Kazumi)## 贡献diff --git a/android/app/src/main/kotlin/com/example/kazumi/MainActivity.kt b/android/app/src/main/kotlin/com/example/kazumi/MainActivity.ktindex ce6bbe96..6b232063 100644--- a/android/app/src/main/kotlin/com/example/kazumi/MainActivity.kt+++ b/android/app/src/main/kotlin/com/example/kazumi/MainActivity.kt@@ -1,6 +1,7 @@package com.example.kazumiimport android.content.Intent+import android.os.Build;import android.net.Uriimport android.os.Bundleimport androidx.annotation.NonNull@@ -23,9 +24,12 @@ class MainActivity: FlutterActivity() {} else {result.error("INVALID_ARGUMENT", "URL and MIME type required", null)}- } else {- result.notImplemented()}+ if (call.method == "checkIfInMultiWindowMode") {+ val isInMultiWindow = checkIfInMultiWindowMode()+ result.success(isInMultiWindow)+ }+ result.notImplemented()}}@@ -35,4 +39,12 @@ class MainActivity: FlutterActivity() {intent.setDataAndType(Uri.parse(url), mimeType)startActivity(intent)}++ private fun checkIfInMultiWindowMode(): Boolean {+ return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {+ this.isInMultiWindowMode+ } else {+ false+ }+ }}diff --git a/lib/pages/video/video_controller.dart b/lib/pages/video/video_controller.dartindex 2cba6d61..e1d10347 100644--- a/lib/pages/video/video_controller.dart+++ b/lib/pages/video/video_controller.dart@@ -76,10 +76,16 @@ abstract class _VideoPageController with Store {await windowManager.setFullScreen(true);return;}- await landScape();await SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky,);+ if (Platform.isAndroid) {+ bool isInMultiWindowMode = await Utils.isInMultiWindowMode();+ if (isInMultiWindowMode) {+ return;+ }+ }+ await landScape();}//退出全屏显示@@ -87,12 +93,9 @@ abstract class _VideoPageController with Store {if (Platform.isWindows || Platform.isLinux || Platform.isMacOS) {await windowManager.setFullScreen(false);}- dynamic document;late SystemUiMode mode = SystemUiMode.edgeToEdge;try {- if (kIsWeb) {- document.exitFullscreen();- } else if (Platform.isAndroid || Platform.isIOS) {+ if (Platform.isAndroid || Platform.isIOS) {if (Platform.isAndroid &&(await DeviceInfoPlugin().androidInfo).version.sdkInt < 29) {mode = SystemUiMode.manual;@@ -102,6 +105,12 @@ abstract class _VideoPageController with Store {overlays: SystemUiOverlay.values,);if (Utils.isCompact()) {+ if (Platform.isAndroid) {+ bool isInMultiWindowMode = await Utils.isInMultiWindowMode();+ if (isInMultiWindowMode) {+ return;+ }+ }verticalScreen();}}@@ -118,21 +127,14 @@ abstract class _VideoPageController with Store {if (kIsWeb) {await document.documentElement?.requestFullscreen();} else if (Platform.isAndroid || Platform.isIOS) {- // await SystemChrome.setEnabledSystemUIMode(- // SystemUiMode.immersiveSticky,- // overlays: [],- // );await SystemChrome.setPreferredOrientations([DeviceOrientation.landscapeLeft,DeviceOrientation.landscapeRight,],);- // await AutoOrientation.landscapeAutoMode(forceSensor: true);}} catch (exception, stacktrace) {- // debugPrint(exception.toString());- // debugPrint(stacktrace.toString());KazumiLogger().log(Level.error, exception.toString(), stackTrace: stacktrace);}diff --git a/lib/utils/utils.dart b/lib/utils/utils.dartindex 94e3de07..79e43ebe 100644--- a/lib/utils/utils.dart+++ b/lib/utils/utils.dart@@ -32,7 +32,8 @@ class Utils {static String getRandomUA() {final random = Random();- String randomElement = userAgentsList[random.nextInt(userAgentsList.length)];+ String randomElement =+ userAgentsList[random.nextInt(userAgentsList.length)];return randomElement;}@@ -445,4 +446,19 @@ class Utils {static bool isCompact() {return !isDesktop() && !isWideScreen();}++ /// 判断是否分屏模式 (android only)+ static Future<bool> isInMultiWindowMode() async {+ if (Platform.isAndroid) {+ const platform = MethodChannel('com.predidit.kazumi/intent');+ try {+ final bool result = await platform.invokeMethod('checkIfInMultiWindowMode');+ return result;+ } on PlatformException catch (e) {+ print("Failed to check multi window mode: '${e.message}'.");+ return false;+ }+ }+ return false;+ }}