diff --git a/star_lock/lib/app_settings/app_settings.dart b/star_lock/lib/app_settings/app_settings.dart index e63f061c..d825ef73 100644 --- a/star_lock/lib/app_settings/app_settings.dart +++ b/star_lock/lib/app_settings/app_settings.dart @@ -1,6 +1,8 @@ import 'package:flutter/foundation.dart'; import 'dart:io'; +import 'package:star_lock/debug/debug_console.dart'; + class AppLog { static bool _printLog = false; static bool _onlyError = false; @@ -17,6 +19,7 @@ class AppLog { if(error){ msg = '----->>> $msg'; } + DebugConsole.info(msg); print(msg); } } diff --git a/star_lock/lib/debug/debug_console.dart b/star_lock/lib/debug/debug_console.dart index 044cd085..77dfd920 100644 --- a/star_lock/lib/debug/debug_console.dart +++ b/star_lock/lib/debug/debug_console.dart @@ -201,10 +201,6 @@ class DebugConsole extends StatefulWidget { controller ??= DebugConsole.instance; runZoned(body, zoneSpecification: ZoneSpecification( - print: (Zone self, ZoneDelegate parent, Zone zone, String line) { - controller!.log(line); - parent.print(zone, line); - }, handleUncaughtError: (Zone self, ZoneDelegate parent, Zone zone, Object error, StackTrace stackTrace) { controller!.log(error, diff --git a/star_lock/lib/debug/debug_tool.dart b/star_lock/lib/debug/debug_tool.dart index 95e575ae..2a8e74d9 100644 --- a/star_lock/lib/debug/debug_tool.dart +++ b/star_lock/lib/debug/debug_tool.dart @@ -11,10 +11,11 @@ class DeBug { static bool open = false; static bool openInfo = false; + static late OverlayEntry overlayEntry; static void showFloatWidget() { Rx offset = Offset(20, 100).obs; // 初始位置 - OverlayEntry overlayEntry = OverlayEntry(builder: (context) { + overlayEntry = OverlayEntry(builder: (context) { return Obx(() => Positioned( left: offset.value.dx, top: offset.value.dy, @@ -54,5 +55,9 @@ class DeBug { Get.key.currentState?.overlay?.insert(overlayEntry); } + static void closeFloatWidget() { + overlayEntry.remove(); + } + DeBug(); } diff --git a/star_lock/lib/flavors.dart b/star_lock/lib/flavors.dart index 19d54133..0bbaedcf 100644 --- a/star_lock/lib/flavors.dart +++ b/star_lock/lib/flavors.dart @@ -57,7 +57,7 @@ class F { case Flavor.sky: return false; case Flavor.xhj: - return false; + return true; default: return false; } diff --git a/star_lock/lib/main.dart b/star_lock/lib/main.dart index 9fb0b04e..62a3b3a9 100644 --- a/star_lock/lib/main.dart +++ b/star_lock/lib/main.dart @@ -18,13 +18,9 @@ FutureOr main() async { // 设置国际化信息 await _initTranslation(); - if(F.debug){ - DebugConsole.listen(() { - runApp(const MyApp()); - }); - }else{ + DebugConsole.listen(() { runApp(const MyApp()); - } + }); if (AppPlatform.isAndroid) { SystemUiOverlayStyle systemUiOverlayStyle = diff --git a/star_lock/lib/mine/about/about_console.dart b/star_lock/lib/mine/about/about_console.dart new file mode 100644 index 00000000..1ba49b66 --- /dev/null +++ b/star_lock/lib/mine/about/about_console.dart @@ -0,0 +1,39 @@ +import 'dart:async'; + +import 'package:get/get.dart'; +import 'package:star_lock/debug/debug_tool.dart'; +import 'package:star_lock/tools/storage.dart'; + +class AboutConsole extends GetxController { + int _clickCount = 0; + Timer? _timer; + + void handleTap() async { + _clickCount++; + + if (_clickCount == 1) { + // 开始一个新的计时器 + _timer = Timer(const Duration(seconds: 3), () { + // 3秒内没有点击到15次,则重置 + _resetCounter(); + }); + } + + if (_clickCount >= 15) { + _timer?.cancel(); + _resetCounter(); + bool? openDeBug = await Storage.getBool(isOpenDeBug); + if (openDeBug == true) { + DeBug.closeFloatWidget(); + await Storage.setBool(isOpenDeBug, false); + } else { + DeBug.showFloatWidget(); + await Storage.setBool(isOpenDeBug, true); + } + } + } + + void _resetCounter() { + _clickCount = 0; + } +} diff --git a/star_lock/lib/mine/about/about_page.dart b/star_lock/lib/mine/about/about_page.dart index a9ebc7c1..17ae37cd 100644 --- a/star_lock/lib/mine/about/about_page.dart +++ b/star_lock/lib/mine/about/about_page.dart @@ -4,6 +4,7 @@ import 'package:get/get.dart'; import 'package:star_lock/appRouters.dart'; import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart'; import 'package:package_info_plus/package_info_plus.dart'; +import 'package:star_lock/mine/about/about_console.dart'; import '../../app_settings/app_colors.dart'; import '../../flavors.dart'; @@ -43,143 +44,160 @@ class _AboutPageState extends State { @override Widget build(BuildContext context) { - return Scaffold( - backgroundColor: AppColors.mainBackgroundColor, - appBar: TitleAppBar( - barTitle: TranslationLoader.lanKeys!.about!.tr, - haveBack: true, - backgroundColor: AppColors.mainColor), - body: Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - SizedBox(height: 150.h), - Row(mainAxisAlignment: MainAxisAlignment.center, children: [ - Image.asset( - F.sw( - defaultCall: () => "images/icon_main_1024.png", - xhjCall: () => "images/icon_main_xhj_1024.png"), - width: 160.w, - height: 160.w), - ]), - SizedBox(height: 20.h), - Text( - "${F.title} $version+$buildNumber", - style: TextStyle(fontSize: 24.sp, color: AppColors.blackColor), - ), - SizedBox(height: 20.h), - Text( - F.apiPrefix, - style: TextStyle(fontSize: 24.sp, color: AppColors.blackColor), - ), - SizedBox( - height: 60.h, - ), - CommonItem( - leftTitel: TranslationLoader.lanKeys!.introduce!.tr, - rightTitle: "", - isHaveLine: false, - isHaveDirection: true, - action: () { - Navigator.pushNamed(context, Routers.webviewShowPage, - arguments: { - "url": XSConstantMacro.introduceURL, - "title": '介绍'.tr - }); - }), - Divider( - height: 1, - color: AppColors.greyLineColor, - indent: 20.w, - endIndent: 20.w, - ), - CommonItem( - leftTitel: TranslationLoader.lanKeys!.userAgreement!.tr, - rightTitle: "", - isHaveLine: false, - isHaveDirection: true, - action: () { - Get.toNamed(Routers.webviewShowPage, arguments: { - "url": XSConstantMacro.userAgreementURL, - "title": '用户协议'.tr - }); - }), - Divider( - height: 1, - color: AppColors.greyLineColor, - indent: 20.w, - endIndent: 20.w, - ), - CommonItem( - leftTitel: TranslationLoader.lanKeys!.privacyPolicy!.tr, - rightTitle: "", - isHaveLine: false, - isHaveDirection: true, - action: () { - Navigator.pushNamed(context, Routers.webviewShowPage, - arguments: { - "url": XSConstantMacro.privacyPolicyURL, - "title": '隐私政策'.tr - }); - }), - Divider( - height: 1, - color: AppColors.greyLineColor, - indent: 20.w, - endIndent: 20.w, - ), - CommonItem( - leftTitel: TranslationLoader - .lanKeys!.personalInformationCollectionList!.tr, - rightTitle: "", - isHaveLine: false, - isHaveDirection: true, - action: () { - Navigator.pushNamed(context, Routers.webviewShowPage, - arguments: { - "url": XSConstantMacro.collectionListURL, - "title": '个人信息收集清单'.tr - }); - }), - Divider( - height: 1, - color: AppColors.greyLineColor, - indent: 20.w, - endIndent: 20.w, - ), - CommonItem( - leftTitel: TranslationLoader - .lanKeys!.applicationPermissionDescription!.tr, - rightTitle: "", - isHaveLine: false, - isHaveDirection: true, - action: () { - Navigator.pushNamed(context, Routers.webviewShowPage, - arguments: { - "url": XSConstantMacro.appPermissionDescURL, - "title": '应用权限说明'.tr - }); - }), - Divider( - height: 1, - color: AppColors.greyLineColor, - indent: 20.w, - endIndent: 20.w, - ), - CommonItem( - leftTitel: TranslationLoader - .lanKeys!.thirdPartyInformationSharingList!.tr, - rightTitle: "", - isHaveLine: false, - isHaveDirection: true, - action: () { - Navigator.pushNamed(context, Routers.webviewShowPage, - arguments: { - "url": XSConstantMacro.thirdPartyInfShareListURL, - "title": '第三方信息共享清单'.tr - }); - }), - ], - ), - ); + return GetBuilder( + init: AboutConsole(), + builder: (AboutConsole logic) { + return Scaffold( + backgroundColor: AppColors.mainBackgroundColor, + appBar: TitleAppBar( + barTitle: TranslationLoader.lanKeys!.about!.tr, + haveBack: true, + backgroundColor: AppColors.mainColor), + body: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Align( + alignment: Alignment.topRight, + child: GestureDetector( + onTap: logic.handleTap, + child: Container( + color: Colors.transparent, + width: 80.w, + height: 80.h, + ), + ), + ), + SizedBox(height: 70.h), + Row(mainAxisAlignment: MainAxisAlignment.center, children: [ + Image.asset( + F.sw( + defaultCall: () => "images/icon_main_1024.png", + xhjCall: () => "images/icon_main_xhj_1024.png"), + width: 160.w, + height: 160.w), + ]), + SizedBox(height: 20.h), + Text( + "${F.title} $version+$buildNumber", + style: + TextStyle(fontSize: 24.sp, color: AppColors.blackColor), + ), + SizedBox(height: 20.h), + Text( + F.apiPrefix, + style: + TextStyle(fontSize: 24.sp, color: AppColors.blackColor), + ), + SizedBox( + height: 60.h, + ), + CommonItem( + leftTitel: TranslationLoader.lanKeys!.introduce!.tr, + rightTitle: "", + isHaveLine: false, + isHaveDirection: true, + action: () { + Navigator.pushNamed(context, Routers.webviewShowPage, + arguments: { + "url": XSConstantMacro.introduceURL, + "title": '介绍'.tr + }); + }), + Divider( + height: 1, + color: AppColors.greyLineColor, + indent: 20.w, + endIndent: 20.w, + ), + CommonItem( + leftTitel: TranslationLoader.lanKeys!.userAgreement!.tr, + rightTitle: "", + isHaveLine: false, + isHaveDirection: true, + action: () { + Get.toNamed(Routers.webviewShowPage, arguments: { + "url": XSConstantMacro.userAgreementURL, + "title": '用户协议'.tr + }); + }), + Divider( + height: 1, + color: AppColors.greyLineColor, + indent: 20.w, + endIndent: 20.w, + ), + CommonItem( + leftTitel: TranslationLoader.lanKeys!.privacyPolicy!.tr, + rightTitle: "", + isHaveLine: false, + isHaveDirection: true, + action: () { + Navigator.pushNamed(context, Routers.webviewShowPage, + arguments: { + "url": XSConstantMacro.privacyPolicyURL, + "title": '隐私政策'.tr + }); + }), + Divider( + height: 1, + color: AppColors.greyLineColor, + indent: 20.w, + endIndent: 20.w, + ), + CommonItem( + leftTitel: TranslationLoader + .lanKeys!.personalInformationCollectionList!.tr, + rightTitle: "", + isHaveLine: false, + isHaveDirection: true, + action: () { + Navigator.pushNamed(context, Routers.webviewShowPage, + arguments: { + "url": XSConstantMacro.collectionListURL, + "title": '个人信息收集清单'.tr + }); + }), + Divider( + height: 1, + color: AppColors.greyLineColor, + indent: 20.w, + endIndent: 20.w, + ), + CommonItem( + leftTitel: TranslationLoader + .lanKeys!.applicationPermissionDescription!.tr, + rightTitle: "", + isHaveLine: false, + isHaveDirection: true, + action: () { + Navigator.pushNamed(context, Routers.webviewShowPage, + arguments: { + "url": XSConstantMacro.appPermissionDescURL, + "title": '应用权限说明'.tr + }); + }), + Divider( + height: 1, + color: AppColors.greyLineColor, + indent: 20.w, + endIndent: 20.w, + ), + CommonItem( + leftTitel: TranslationLoader + .lanKeys!.thirdPartyInformationSharingList!.tr, + rightTitle: "", + isHaveLine: false, + isHaveDirection: true, + action: () { + Navigator.pushNamed(context, Routers.webviewShowPage, + arguments: { + "url": XSConstantMacro.thirdPartyInfShareListURL, + "title": '第三方信息共享清单'.tr + }); + }), + ], + ), + ); + }); } } diff --git a/star_lock/lib/starLockApplication/starLockApplication.dart b/star_lock/lib/starLockApplication/starLockApplication.dart index 1d3a0f35..d4a7d389 100644 --- a/star_lock/lib/starLockApplication/starLockApplication.dart +++ b/star_lock/lib/starLockApplication/starLockApplication.dart @@ -21,8 +21,9 @@ class _StarLockApplicationState extends State { @override void initState() { super.initState(); - WidgetsBinding.instance.addPostFrameCallback((_) { - if (F.debug) { + WidgetsBinding.instance.addPostFrameCallback((_) async { + bool? openDeBug = await Storage.getBool(isOpenDeBug); + if (openDeBug == true) { DeBug.showFloatWidget(); } }); diff --git a/star_lock/lib/tools/storage.dart b/star_lock/lib/tools/storage.dart index f5465f51..82e44149 100644 --- a/star_lock/lib/tools/storage.dart +++ b/star_lock/lib/tools/storage.dart @@ -26,6 +26,7 @@ const saveIsVip = "saveIsVip"; //是否是VIP const saveUserLoginData = "userLoginData"; const saveLockMainListData = "lockMainListData"; +const isOpenDeBug = "isOpenDeBug";//是否打开 debug class Storage { Storage._internal();