基于自定义规则的番剧采集APP,支持流媒体在线观看,支持弹幕,支持实时超分辨率。
feat: add Android WebView feature detection for DOCUMENT_START_SCRIPT (#1168)
KotaHve2c09e493dea
diff --git a/lib/main.dart b/lib/main.dartindex 56b59a68..54221f54 100644--- a/lib/main.dart+++ b/lib/main.dart@@ -27,6 +27,11 @@ void main() async {statusBarColor: Colors.transparent,));}++ if (Platform.isAndroid) {+ await Utils.checkWebViewFeatureSupport();+ }+try {await Hive.initFlutter('${(await getApplicationSupportDirectory()).path}/hive');diff --git a/lib/pages/webview/webview_controller.dart b/lib/pages/webview/webview_controller.dartindex 88de54c2..a48896f0 100644--- a/lib/pages/webview/webview_controller.dart+++ b/lib/pages/webview/webview_controller.dart@@ -6,6 +6,7 @@ import 'package:kazumi/pages/webview/webview_controller_impel/webview_controllerimport 'package:kazumi/pages/webview/webview_controller_impel/webview_windows_controller_impel.dart';import 'package:kazumi/pages/webview/webview_controller_impel/webview_linux_controller_impel.dart';import 'package:kazumi/pages/webview/webview_controller_impel/webview_apple_controller_impel.dart';+import 'package:kazumi/utils/utils.dart';abstract class WebviewItemController<T> {// Webview controller@@ -68,7 +69,7 @@ class WebviewItemControllerFactory {if (Platform.isMacOS || Platform.isIOS) {return WebviewAppleItemControllerImpel();}- if (Platform.isAndroid) {+ if (Platform.isAndroid && Utils.isDocumentStartScriptSupported) {return WebviewAndroidItemControllerImpel();}return WebviewItemControllerImpel();diff --git a/lib/pages/webview/webview_item.dart b/lib/pages/webview/webview_item.dartindex e368a5e1..2b3d8452 100644--- a/lib/pages/webview/webview_item.dart+++ b/lib/pages/webview/webview_item.dart@@ -5,6 +5,7 @@ import 'package:kazumi/pages/webview/webview_item_impel/webview_item_impel.dart'import 'package:kazumi/pages/webview/webview_item_impel/webview_windows_item_impel.dart';import 'package:kazumi/pages/webview/webview_item_impel/webview_linux_item_impel.dart';import 'package:kazumi/pages/webview/webview_item_impel/webview_apple_item_impel.dart';+import 'package:kazumi/utils/utils.dart';class WebviewItem extends StatefulWidget {const WebviewItem({super.key});@@ -30,7 +31,7 @@ Widget get webviewUniversal {if (Platform.isMacOS || Platform.isIOS) {return const WebviewAppleItemImpel();}- if (Platform.isAndroid) {+ if (Platform.isAndroid && Utils.isDocumentStartScriptSupported) {return const WebviewAndroidItemImpel();}return const WebviewItemImpel();diff --git a/lib/utils/utils.dart b/lib/utils/utils.dartindex 1cc29905..0a78cffa 100644--- a/lib/utils/utils.dart+++ b/lib/utils/utils.dart@@ -20,10 +20,24 @@ import 'package:path/path.dart' as path;import 'package:path_provider/path_provider.dart';import 'package:screen_pixel/screen_pixel.dart';import 'package:window_manager/window_manager.dart';+import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart';class Utils {static final Random random = Random();+ static bool? _isDocumentStartScriptSupported;++ /// 检查 Android WebView 是否支持 DOCUMENT_START_SCRIPT 特性+ static Future<void> checkWebViewFeatureSupport() async {+ if (Platform.isAndroid) {+ _isDocumentStartScriptSupported = await PlatformWebViewFeature.static()+ .isFeatureSupported(WebViewFeature.DOCUMENT_START_SCRIPT);+ }+ }++ static bool get isDocumentStartScriptSupported =>+ _isDocumentStartScriptSupported ?? false;+static Future<bool> isLowResolution() async {if (Platform.isMacOS) {return false;