From 632ee8cfbdad92a594bd72ff63d20cce6d67d72f Mon Sep 17 00:00:00 2001 From: wanghongenpin Date: Wed, 13 Mar 2024 00:33:08 +0800 Subject: [PATCH] certificate & tab sliding optimization --- lib/l10n/app_en.arb | 6 +- lib/l10n/app_zh.arb | 6 +- lib/ui/configuration.dart | 6 +- lib/ui/content/panel.dart | 3 +- lib/ui/desktop/desktop.dart | 24 ++-- lib/ui/desktop/toolbar/ssl/ssl.dart | 134 +++++++++--------- lib/ui/mobile/menu.dart | 9 +- lib/ui/mobile/mobile.dart | 5 +- lib/ui/mobile/widgets/pip.dart | 11 +- macos/Flutter/GeneratedPluginRegistrant.swift | 2 - pubspec.lock | 57 -------- pubspec.yaml | 10 +- 12 files changed, 111 insertions(+), 162 deletions(-) diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index f0e60ed..b0228c2 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -169,10 +169,10 @@ "install": "Install", "installCaDescribe": "Install CA Setting > Profile Download > Install", "trustCaDescribe": "Trust CA Setting > General > About > Certificate Trust Setting", - "androidRoot": "ROOT User: Install to system certificate", - "androidRootMagisk": "For Android ROOT users, a Magisk module ProxyPinCA system certificate has been made, restart the phone after installation.", + "androidRoot": "System Certificate (ROOT Device)", + "androidRootMagisk": "Magisk module: \nAndroid ROOT devices can be used Magisk ProxyPinCA System Certificate Module, After installing and restarting the phone Check the system certificate to see if there is a ProxyPinCA certificate. If there is, it indicates that the certificate has been successfully installed。", "androidRootRename": "If the module does not take effect, you can install the system root certificate according to the online tutorial, and name the root certificate 243f0bfb.0", - "androidUserCA": "Non-ROOT User: Install to user certificate (many apps will not trust user certificates)", + "androidUserCA": "User certificate (many apps will not trust user certificates)", "androidUserCAInstall": "Open settings -> Security -> Encryption and credentials -> Install certificate -> CA certificate", "androidUserXposed": "It is recommended to use the Xposed module for packet capture (no need for ROOT), click to view wiki", "configWifiProxy": "Configure mobile Wi-Fi proxy", diff --git a/lib/l10n/app_zh.arb b/lib/l10n/app_zh.arb index 77a232f..801dc25 100644 --- a/lib/l10n/app_zh.arb +++ b/lib/l10n/app_zh.arb @@ -170,10 +170,10 @@ "install": "安装", "installCaDescribe": "安装证书 设置 > 已下载描述文件 > 安装", "trustCaDescribe": "信任证书 设置 > 通用 > 关于本机 > 证书信任设置", - "androidRoot": "ROOT用户: 安装到系统证书", - "androidRootMagisk": "针对安卓ROOT用户做了个Magisk模块ProxyPinCA系统证书,安装完重启手机即可。", + "androidRoot": "系统证书 (ROOT设备)", + "androidRootMagisk": "Magisk模块: \n安卓ROOT设备可以使用Magisk ProxyPinCA系统证书模块, 安装完重启手机后 在系统证书查看是否有ProxyPinCA证书,如果有说明证书安装成功。", "androidRootRename": "模块不生效可以根据网上教程安装系统根证书, 根证书命名成 243f0bfb.0", - "androidUserCA": "非ROOT用户: 安装到用户证书(很多软件不会信任用户证书)", + "androidUserCA": "用户证书 (很多软件不会信任用户证书)", "androidUserCAInstall": "打开设置 -> 安全 -> 加密和凭据 -> 安装证书 -> CA 证书", "androidUserXposed": "推荐使用Xposed模块抓包(无需ROOT), 点击查看wiki", "configWifiProxy": "配置手机Wi-Fi代理", diff --git a/lib/ui/configuration.dart b/lib/ui/configuration.dart index 525becd..a69f9a2 100644 --- a/lib/ui/configuration.dart +++ b/lib/ui/configuration.dart @@ -29,7 +29,7 @@ class AppConfiguration { bool upgradeNoticeV8 = true; /// 是否启用画中画 - bool pipEnabled = true; + ValueNotifier pipEnabled = ValueNotifier(true); /// bool headerExpanded = true; @@ -116,7 +116,7 @@ class AppConfiguration { _theme = ThemeModel(mode: mode, useMaterial3: config['useMaterial3'] ?? true); upgradeNoticeV8 = config['upgradeNoticeV8'] ?? true; _language = config['language'] == null ? null : Locale.fromSubtags(languageCode: config['language']); - pipEnabled = config['pipEnabled'] ?? true; + pipEnabled.value = config['pipEnabled'] ?? true; headerExpanded = config['headerExpanded'] ?? true; iosVpnBackgroundAudioEnable = config['iosVpnBackgroundAudioEnable']; } catch (e) { @@ -142,7 +142,7 @@ class AppConfiguration { 'useMaterial3': _theme.useMaterial3, 'upgradeNoticeV8': upgradeNoticeV8, "language": _language?.languageCode, - 'pipEnabled': pipEnabled, + 'pipEnabled': pipEnabled.value, "headerExpanded": headerExpanded, "iosVpnBackgroundAudioEnable": iosVpnBackgroundAudioEnable == false ? null : iosVpnBackgroundAudioEnable }; diff --git a/lib/ui/content/panel.dart b/lib/ui/content/panel.dart index d520c99..ad3ae04 100644 --- a/lib/ui/content/panel.dart +++ b/lib/ui/content/panel.dart @@ -225,6 +225,7 @@ class NetworkTabState extends State with SingleTickerProvi return ListView( controller: scrollController, + physics: const AlwaysScrollableScrollPhysics(), children: [rowWidget("URI", path), ...message(widget.request.get(), "Request", scrollController)]); } @@ -234,7 +235,7 @@ class NetworkTabState extends State with SingleTickerProvi } var scrollController = ScrollController(); - return ListView(controller: scrollController, children: [ + return ListView(controller: scrollController, physics: const AlwaysScrollableScrollPhysics(), children: [ rowWidget("StatusCode", widget.response.get()?.status.toString()), ...message(widget.response.get(), "Response", scrollController) ]); diff --git a/lib/ui/desktop/desktop.dart b/lib/ui/desktop/desktop.dart index ea4a4eb..886b266 100644 --- a/lib/ui/desktop/desktop.dart +++ b/lib/ui/desktop/desktop.dart @@ -200,24 +200,16 @@ class _DesktopHomePagePageState extends State implements EventL isCN ? '提示:默认不会开启HTTPS抓包,请安装证书后再开启HTTPS抓包。\n' '点击HTTPS抓包(加锁图标),选择安装根证书,按照提示操作即可。\n\n' - '1. 历史记录支持自动缓存时间设置;\n' - '2. 历史记录增加搜索;\n' - '3. 增加当前视图导出;\n' - '4. 增加屏蔽请求功能;\n' - '5. 支持高亮请求;\n' - '6. Android返回键进入小窗口;\n' - '7. Android白名单应用列表展示隐藏图标应用;\n' - '8. 修复暗黑主题样式;\n' + '1. 展示请求发起的应用图标;\n' + '2. 关键词匹配高亮;\n' + '3. 脚本批量操作和导入导出;\n' + '4. 脚本支持日志查看,通过console.log()输出;\n' : 'Tips:By default, HTTPS packet capture will not be enabled. Please install the certificate before enabling HTTPS packet capture。\n' 'Click HTTPS Capture packets(Lock icon),Choose to install the root certificate and follow the prompts to proceed。\n\n' - '1. History support auto cache time setting;\n' - '2. History Add Search;\n' - '3. Add current view export;\n' - '4. Support blocking request;\n' - '5. Support highlighting requests;\n' - '6. Android Return key to enter the small window;\n' - '7. Android Whitelist application list display hidden icon applications;\n' - '8. Fix dark theme style;\n', + '1. Display the application icon initiated by the request;\n' + '2. Keyword matching highlights;\n' + '3. Script batch operations and import/export;\n' + '4. The script supports log viewing, output through console.log();\n', style: const TextStyle(fontSize: 14))); }); } diff --git a/lib/ui/desktop/toolbar/ssl/ssl.dart b/lib/ui/desktop/toolbar/ssl/ssl.dart index f5b5acc..20212fb 100644 --- a/lib/ui/desktop/toolbar/ssl/ssl.dart +++ b/lib/ui/desktop/toolbar/ssl/ssl.dart @@ -196,76 +196,82 @@ class _SslState extends State { builder: (BuildContext context) { return AlertDialog( shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10.0)), - contentPadding: const EdgeInsets.all(16), + contentPadding: const EdgeInsets.all(5), title: Row(children: [ Text("Android ${localizations.caInstallGuide}", style: const TextStyle(fontSize: 16)), const Expanded(child: Align(alignment: Alignment.topRight, child: CloseButton())) ]), - alignment: Alignment.center, content: SizedBox( width: 600, - child: ListView(children: [ - ExpansionTile( - title: Text(localizations.androidRoot, - style: const TextStyle(fontWeight: FontWeight.w500, fontSize: 14)), - tilePadding: const EdgeInsets.only(left: 0), - expandedCrossAxisAlignment: CrossAxisAlignment.start, - expandedAlignment: Alignment.topLeft, - childrenPadding: const EdgeInsets.only(left: 20), - initiallyExpanded: true, - shape: const Border(), - children: [ - Text(localizations.androidRootMagisk), - TextButton( - child: Text( - "https://${isCN ? 'gitee' : 'github'}.com/wanghongenpin/Magisk-ProxyPinCA/releases"), - onPressed: () { - launchUrl(Uri.parse( - "https://${isCN ? 'gitee' : 'github'}.com/wanghongenpin/Magisk-ProxyPinCA/releases")); - }), - SelectableText(localizations.androidRootRename), - ]), - const SizedBox(height: 10), - ExpansionTile( - title: Text(localizations.androidUserCA, - style: const TextStyle(fontWeight: FontWeight.w500, fontSize: 14)), - tilePadding: const EdgeInsets.only(left: 0), - expandedCrossAxisAlignment: CrossAxisAlignment.start, - childrenPadding: const EdgeInsets.only(left: 20), - initiallyExpanded: true, - shape: const Border(), - children: [ - SelectableText.rich(TextSpan( - text: "1. ${localizations.configWifiProxy} Host:$host Port:${widget.proxyServer.port}")), - const SizedBox(height: 10), - Row( - children: [ - Text("2. ${localizations.caIosBrowser}\t"), - const SelectableText.rich(TextSpan( - text: "http://proxy.pin/ssl", style: TextStyle(decoration: TextDecoration.underline))) - ], - ), - const SizedBox(height: 10), - Text("3. ${localizations.androidUserCAInstall}"), - const SizedBox(height: 10), - TextButton( - onPressed: () { - launchUrl(Uri.parse(isCN - ? "https://gitee.com/wanghongenpin/network-proxy-flutter/wikis/%E5%AE%89%E5%8D%93%E6%97%A0ROOT%E4%BD%BF%E7%94%A8Xposed%E6%A8%A1%E5%9D%97%E6%8A%93%E5%8C%85" - : "https://github.com/wanghongenpin/network_proxy_flutter/wiki/Android-without-ROOT-uses-Xposed-module-to-capture-packets")); - }, - child: Text(" ${localizations.androidUserXposed}")), - ClipRRect( - child: Align( - alignment: Alignment.topCenter, - heightFactor: .7, - child: Image.network( - "https://foruda.gitee.com/images/1689352695624941051/74e3bed6_1073801.png", - height: 550, - ))) - ], - ), - ]))); + child: DefaultTabController( + length: 2, + child: Scaffold( + appBar: TabBar( + tabs: [ + Tab(text: localizations.androidRoot), + Tab(text: localizations.androidUserCA), + ] as List), + body: Padding( + padding: const EdgeInsets.all(10), + child: TabBarView(children: [ + ListView(children: [ + Text(localizations.androidRootMagisk), + TextButton( + child: Text( + "https://${isCN ? 'gitee' : 'github'}.com/wanghongenpin/Magisk-ProxyPinCA/releases"), + onPressed: () { + launchUrl(Uri.parse( + "https://${isCN ? 'gitee' : 'github'}.com/wanghongenpin/Magisk-ProxyPinCA/releases")); + }), + const SizedBox(height: 10), + SelectableText(localizations.androidRootRename), + const SizedBox(height: 10), + ClipRRect( + child: Align( + alignment: Alignment.topCenter, + child: Image.network( + scale: 0.5, + "https://foruda.gitee.com/images/1710181660282752846/cb520c0b_1073801.png", + height: 460, + ))) + ]), + ListView( + children: [ + SelectableText.rich(TextSpan( + text: + "1. ${localizations.configWifiProxy} Host:$host Port:${widget.proxyServer.port}")), + const SizedBox(height: 10), + Row( + children: [ + Text("2. ${localizations.caAndroidBrowser}\t"), + const SelectableText.rich(TextSpan( + text: "http://proxy.pin/ssl", + style: TextStyle(decoration: TextDecoration.underline))) + ], + ), + const SizedBox(height: 10), + Text("3. ${localizations.androidUserCAInstall}"), + const SizedBox(height: 10), + TextButton( + onPressed: () { + launchUrl(Uri.parse(isCN + ? "https://gitee.com/wanghongenpin/network-proxy-flutter/wikis/%E5%AE%89%E5%8D%93%E6%97%A0ROOT%E4%BD%BF%E7%94%A8Xposed%E6%A8%A1%E5%9D%97%E6%8A%93%E5%8C%85" + : "https://github.com/wanghongenpin/network_proxy_flutter/wiki/Android-without-ROOT-uses-Xposed-module-to-capture-packets")); + }, + child: Text(" ${localizations.androidUserXposed}")), + const SizedBox(height: 10), + ClipRRect( + child: Align( + alignment: Alignment.topCenter, + heightFactor: .7, + child: Image.network( + "https://foruda.gitee.com/images/1689352695624941051/74e3bed6_1073801.png", + height: 530, + ))) + ], + ), + ])), + )))); }); } diff --git a/lib/ui/mobile/menu.dart b/lib/ui/mobile/menu.dart index 51e82a6..28bb262 100644 --- a/lib/ui/mobile/menu.dart +++ b/lib/ui/mobile/menu.dart @@ -69,7 +69,7 @@ class DrawerWidget extends StatelessWidget { onTap: () => navigator( context, MobileHistory(proxyServer: proxyServer, container: container, historyTask: historyTask)), ), - const Divider(thickness: 0.3), + const Divider(thickness: 0.3, height: 0), ListTile( leading: const Icon(Icons.construction), title: Text(localizations.toolbox), @@ -84,7 +84,7 @@ class DrawerWidget extends StatelessWidget { title: Text(localizations.httpsProxy), leading: const Icon(Icons.https), onTap: () => navigator(context, MobileSslWidget(proxyServer: proxyServer))), - const Divider(thickness: 0.3), + const Divider(thickness: 0.3, height: 0), ListTile( title: Text(localizations.filter), leading: const Icon(Icons.filter_alt_outlined), @@ -122,6 +122,7 @@ class DrawerWidget extends StatelessWidget { title: Text(localizations.about), leading: const Icon(Icons.info_outline), onTap: () => navigator(context, const About())), + const SizedBox(height: 20) ], )); } @@ -166,9 +167,9 @@ class SettingMenu extends StatelessWidget { title: Text(localizations.windowMode), subtitle: Text(localizations.windowModeSubTitle, style: const TextStyle(fontSize: 12)), trailing: SwitchWidget( - value: appConfiguration.pipEnabled, + value: appConfiguration.pipEnabled.value, onChanged: (value) { - appConfiguration.pipEnabled = value; + appConfiguration.pipEnabled.value = value; appConfiguration.flushConfig(); })), ListTile( diff --git a/lib/ui/mobile/mobile.dart b/lib/ui/mobile/mobile.dart index 9533bf2..bb23480 100644 --- a/lib/ui/mobile/mobile.dart +++ b/lib/ui/mobile/mobile.dart @@ -59,7 +59,7 @@ class MobileHomeState extends State implements EventListener, Li Future enterPictureInPicture() async { if (Vpn.isVpnStarted && !pictureInPictureNotifier.value) { - if (desktop.value.connect || !Platform.isAndroid || !(await (AppConfiguration.instance)).pipEnabled) { + if (desktop.value.connect || !Platform.isAndroid || !(await (AppConfiguration.instance)).pipEnabled.value) { return false; } @@ -170,8 +170,7 @@ class MobileHomeState extends State implements EventListener, Li } return Scaffold( - floatingActionButton: - widget.appConfiguration.pipEnabled ? PictureInPictureWindow(proxyServer) : const SizedBox(), + floatingActionButton: PictureInPictureWindow(proxyServer), body: Scaffold( appBar: appBar(), drawer: DrawerWidget(proxyServer: proxyServer, container: container), diff --git a/lib/ui/mobile/widgets/pip.dart b/lib/ui/mobile/widgets/pip.dart index 7f94049..887246a 100644 --- a/lib/ui/mobile/widgets/pip.dart +++ b/lib/ui/mobile/widgets/pip.dart @@ -4,6 +4,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:network_proxy/native/pip.dart'; import 'package:network_proxy/network/bin/server.dart'; +import 'package:network_proxy/ui/configuration.dart'; import 'package:network_proxy/utils/ip.dart'; class PictureInPictureWindow extends StatefulWidget { @@ -25,9 +26,17 @@ class _PictureInPictureState extends State { AppLocalizations get localizations => AppLocalizations.of(context)!; + @override + void initState() { + super.initState(); + AppConfiguration.current?.pipEnabled.addListener(() { + setState(() {}); + }); + } + @override Widget build(BuildContext context) { - if (Platform.isAndroid) return const SizedBox(); + if (Platform.isAndroid || AppConfiguration.current?.pipEnabled.value == false) return const SizedBox(); size ??= MediaQuery.sizeOf(context); if (size == null || size!.isEmpty) { diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index 725f8d2..4d1e4a5 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -14,7 +14,6 @@ import proxy_manager import screen_retriever import share_plus import url_launcher_macos -import video_player_avfoundation import window_manager func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { @@ -27,6 +26,5 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { ScreenRetrieverPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverPlugin")) SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin")) UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) - FVPVideoPlayerPlugin.register(with: registry.registrar(forPlugin: "FVPVideoPlayerPlugin")) WindowManagerPlugin.register(with: registry.registrar(forPlugin: "WindowManagerPlugin")) } diff --git a/pubspec.lock b/pubspec.lock index f740430..ae303df 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -97,14 +97,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "3.0.3" - csslib: - dependency: transitive - description: - name: csslib - sha256: "706b5707578e0c1b4b7550f64078f0a0f19dec3f50a178ffae7006b0a9ca58fb" - url: "https://pub.flutter-io.cn" - source: hosted - version: "1.0.0" cupertino_icons: dependency: "direct main" description: @@ -350,14 +342,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "2.2.3" - html: - dependency: transitive - description: - name: html - sha256: "3a7812d5bcd2894edf53dfaf8cd640876cf6cef50a8f238745c8b8120ea74d3a" - url: "https://pub.flutter-io.cn" - source: hosted - version: "0.15.4" http: dependency: transitive description: @@ -803,47 +787,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "2.1.4" - video_player: - dependency: "direct main" - description: - path: "packages/video_player/video_player" - ref: "feature/ios-pip" - resolved-ref: b829adec12641d97bef672d8ddbbf0531dd3efe7 - url: "https://github.com/icapps/plugins.git" - source: git - version: "2.6.0" - video_player_android: - dependency: transitive - description: - name: video_player_android - sha256: "4dd9b8b86d70d65eecf3dcabfcdfbb9c9115d244d022654aba49a00336d540c2" - url: "https://pub.flutter-io.cn" - source: hosted - version: "2.4.12" - video_player_avfoundation: - dependency: transitive - description: - name: video_player_avfoundation - sha256: "309e3962795e761be010869bae65c0b0e45b5230c5cee1bec72197ca7db040ed" - url: "https://pub.flutter-io.cn" - source: hosted - version: "2.5.6" - video_player_platform_interface: - dependency: transitive - description: - name: video_player_platform_interface - sha256: "236454725fafcacf98f0f39af0d7c7ab2ce84762e3b63f2cbb3ef9a7e0550bc6" - url: "https://pub.flutter-io.cn" - source: hosted - version: "6.2.2" - video_player_web: - dependency: transitive - description: - name: video_player_web - sha256: "34beb3a07d4331a24f7e7b2f75b8e2b103289038e07e65529699a671b6a6e2cb" - url: "https://pub.flutter-io.cn" - source: hosted - version: "2.1.3" vm_service: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index fd443b5..92f561c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -38,11 +38,11 @@ dependencies: flutter_code_editor: file_picker: ^6.1.1 flutter_desktop_context_menu: ^0.2.0 - video_player: - git: - url: https://github.com/icapps/plugins.git - ref: feature/ios-pip - path: packages/video_player/video_player +# video_player: +# git: +# url: https://github.com/icapps/plugins.git +# ref: feature/ios-pip +# path: packages/video_player/video_player #dependency_overrides: