diff --git a/lib/Database/database_manager.dart b/lib/Database/database_manager.dart index 52beeecf..df00bfdb 100644 --- a/lib/Database/database_manager.dart +++ b/lib/Database/database_manager.dart @@ -263,11 +263,7 @@ class DatabaseManager { if (Platform.isLinux || Platform.isAndroid) { try { lib = DynamicLibrary.open('libsqlcipher.so'); - } catch (e, t) { - ILogger.error( - "Failed to load libsqlcipher.so, perhaps the library is not installed or not in the correct path.", - e, - t); + } catch (e) { if (Platform.isAndroid) { final appIdAsBytes = File('/proc/self/cmdline').readAsBytesSync(); final endOfAppId = max(appIdAsBytes.indexOf(0), 0); diff --git a/lib/Screens/Lock/pin_verify_screen.dart b/lib/Screens/Lock/pin_verify_screen.dart index 56779f68..71eefd03 100644 --- a/lib/Screens/Lock/pin_verify_screen.dart +++ b/lib/Screens/Lock/pin_verify_screen.dart @@ -73,7 +73,7 @@ class PinVerifyScreenState extends BaseWindowState @override void initState() { - if (widget.jumpToMain) { + if (widget.isModal) { trayManager.addListener(this); Utils.initSimpleTray(); } diff --git a/lib/Screens/main_screen.dart b/lib/Screens/main_screen.dart index 1f215eb9..d06344a8 100644 --- a/lib/Screens/main_screen.dart +++ b/lib/Screens/main_screen.dart @@ -69,7 +69,6 @@ class MainScreenState extends BaseWindowState ProtocolListener, AutomaticKeepAliveClientMixin { Timer? _timer; - Orientation _oldOrientation = Orientation.portrait; TextEditingController searchController = TextEditingController(); @override @@ -120,6 +119,10 @@ class MainScreenState extends BaseWindowState if (ResponsiveUtil.isDesktop() && !ResponsiveUtil.isLinux()) { protocolHandler.addListener(this); } + if (ResponsiveUtil.isDesktop()) { + Utils.initTray(); + } + trayManager.addListener(this); windowManager.addListener(this); WidgetsBinding.instance.addObserver(this); CloudOTPHiveUtil.showCloudEntry().then((value) { @@ -131,30 +134,23 @@ class MainScreenState extends BaseWindowState defaultValue: false)) { ShortcutsUtil.focusSearch(); } - if (ResponsiveUtil.isDesktop()) { - await Utils.initTray(); - trayManager.addListener(this); - // keyboardHandlerState?.focus(); - } - if (mounted) { - initGlobalConfig(); - _oldOrientation = MediaQuery.of(context).orientation; - EasyRefresh.defaultHeaderBuilder = () => LottieCupertinoHeader( - backgroundColor: ChewieTheme.canvasColor, - indicator: LottieFiles.load(LottieFiles.getLoadingPath(context), - scale: 1.5), - hapticFeedback: true, - triggerOffset: 40, - ); - EasyRefresh.defaultFooterBuilder = () => LottieCupertinoFooter( - indicator: LottieFiles.load(LottieFiles.getLoadingPath(context)), - ); - chewieProvider.loadingWidgetBuilder = (size, forceDark) => - LottieFiles.load( + EasyRefresh.defaultHeaderBuilder = () => LottieCupertinoHeader( + backgroundColor: ChewieTheme.canvasColor, + indicator: LottieFiles.load(LottieFiles.getLoadingPath(context), + scale: 1.5), + hapticFeedback: true, + triggerOffset: 40, + ); + EasyRefresh.defaultFooterBuilder = () => LottieCupertinoFooter( + indicator: LottieFiles.load(LottieFiles.getLoadingPath(context)), + ); + chewieProvider.loadingWidgetBuilder = + (size, forceDark) => LottieFiles.load( LottieFiles.getLoadingPath(chewieProvider.rootContext), - scale: 1.5); - } + scale: 1.5, + ); }); + initGlobalConfig(); searchController.addListener(() { homeScreenState?.performSearch(searchController.text); }); @@ -208,8 +204,6 @@ class MainScreenState extends BaseWindowState defaultValue: defaultEnableSafeMode)); super.build(context); return OrientationBuilder(builder: (ctx, ori) { - if (ori != _oldOrientation) {} - _oldOrientation = ori; return _buildBodyByPlatform(); }); } diff --git a/lib/Utils/biometric_util.dart b/lib/Utils/biometric_util.dart index faba2290..8abdad4d 100644 --- a/lib/Utils/biometric_util.dart +++ b/lib/Utils/biometric_util.dart @@ -71,7 +71,7 @@ class BiometricUtil { ILogger.info("No passcode set on this device"); break; default: - ILogger.info("Unknown error"); + ILogger.info("Biometric Unknown error"); break; } } diff --git a/lib/Utils/utils.dart b/lib/Utils/utils.dart index f585ace2..6010f396 100644 --- a/lib/Utils/utils.dart +++ b/lib/Utils/utils.dart @@ -136,133 +136,148 @@ class Utils { } static Future initTray() async { - if (!ResponsiveUtil.isDesktop()) return; - await trayManager.destroy(); - if (!ChewieHiveUtil.getBool(ChewieHiveUtil.showTrayKey)) { + try { + if (!ResponsiveUtil.isDesktop()) return; + ILogger.debug("Initializing tray..."); await trayManager.destroy(); - return; - } - - // Ensure tray icon display in linux sandboxed environments - if (Platform.environment.containsKey('FLATPAK_ID') || - Platform.environment.containsKey('SNAP')) { - await trayManager.setIcon('com.cloudchewie.cloudotp'); - } else if (ResponsiveUtil.isWindows()) { - await trayManager.setIcon('assets/logo-transparent.ico'); - } else { - await trayManager.setIcon('assets/logo-transparent.png'); - } + if (!ChewieHiveUtil.getBool(ChewieHiveUtil.showTrayKey)) { + ILogger.debug("Tray is disabled, not initializing."); + await trayManager.destroy(); + return; + } + // Ensure tray icon display in linux sandboxed environments + if (Platform.environment.containsKey('FLATPAK_ID') || + Platform.environment.containsKey('SNAP')) { + await trayManager.setIcon('com.cloudchewie.cloudotp'); + } else if (ResponsiveUtil.isWindows()) { + await trayManager.setIcon('assets/logo-transparent.ico'); + } else { + await trayManager.setIcon('assets/logo-transparent.png'); + } - bool lauchAtStartup = await LaunchAtStartup.instance.isEnabled(); - if (!ResponsiveUtil.isLinux()) { - await trayManager.setToolTip(ResponsiveUtil.appName); + bool lauchAtStartup = await LaunchAtStartup.instance.isEnabled(); + if (!ResponsiveUtil.isLinux()) { + ILogger.debug( + "Setting tray tooltip to app name ${ResponsiveUtil.appName}"); + await trayManager.setToolTip(ResponsiveUtil.appName); + } + Menu menu = Menu( + items: [ + MenuItem( + key: TrayKey.checkUpdates.key, + label: appProvider.latestVersion.isNotEmpty + ? appLocalizations.getNewVersion(appProvider.latestVersion) + : appLocalizations.checkUpdates, + ), + MenuItem( + key: TrayKey.shortcutHelp.key, + label: appLocalizations.shortcutHelp, + ), + MenuItem.separator(), + MenuItem( + key: TrayKey.displayApp.key, + label: appLocalizations.displayAppTray, + ), + MenuItem( + key: TrayKey.lockApp.key, + label: appLocalizations.lockAppTray, + ), + ...await getTrayTokenMenuItems(), + MenuItem.separator(), + MenuItem( + key: TrayKey.setting.key, + label: appLocalizations.setting, + ), + MenuItem( + key: TrayKey.officialWebsite.key, + label: appLocalizations.officialWebsiteTray, + ), + MenuItem( + key: TrayKey.about.key, + label: appLocalizations.about, + ), + MenuItem( + key: TrayKey.githubRepository.key, + label: appLocalizations.repoTray, + ), + MenuItem.separator(), + MenuItem.checkbox( + checked: lauchAtStartup, + key: TrayKey.launchAtStartup.key, + label: appLocalizations.launchAtStartup, + ), + MenuItem.separator(), + MenuItem( + key: TrayKey.exitApp.key, + label: appLocalizations.exitAppTray, + ), + ], + ); + await trayManager.setContextMenu(menu); + ILogger.debug("Tray initialized successfully."); + } catch (e, t) { + ILogger.error("Failed to initialize simple tray", e, t); } - Menu menu = Menu( - items: [ - MenuItem( - key: TrayKey.checkUpdates.key, - label: appProvider.latestVersion.isNotEmpty - ? appLocalizations.getNewVersion(appProvider.latestVersion) - : appLocalizations.checkUpdates, - ), - MenuItem( - key: TrayKey.shortcutHelp.key, - label: appLocalizations.shortcutHelp, - ), - MenuItem.separator(), - MenuItem( - key: TrayKey.displayApp.key, - label: appLocalizations.displayAppTray, - ), - MenuItem( - key: TrayKey.lockApp.key, - label: appLocalizations.lockAppTray, - ), - ...await getTrayTokenMenuItems(), - MenuItem.separator(), - MenuItem( - key: TrayKey.setting.key, - label: appLocalizations.setting, - ), - MenuItem( - key: TrayKey.officialWebsite.key, - label: appLocalizations.officialWebsiteTray, - ), - MenuItem( - key: TrayKey.about.key, - label: appLocalizations.about, - ), - MenuItem( - key: TrayKey.githubRepository.key, - label: appLocalizations.repoTray, - ), - MenuItem.separator(), - MenuItem.checkbox( - checked: lauchAtStartup, - key: TrayKey.launchAtStartup.key, - label: appLocalizations.launchAtStartup, - ), - MenuItem.separator(), - MenuItem( - key: TrayKey.exitApp.key, - label: appLocalizations.exitAppTray, - ), - ], - ); - await trayManager.setContextMenu(menu); } static Future initSimpleTray() async { - if (!ResponsiveUtil.isDesktop()) return; - await trayManager.destroy(); - if (!ChewieHiveUtil.getBool(ChewieHiveUtil.showTrayKey)) { + try { + if (!ResponsiveUtil.isDesktop()) return; + ILogger.debug("Initializing simple tray..."); await trayManager.destroy(); - return; - } + if (!ChewieHiveUtil.getBool(ChewieHiveUtil.showTrayKey)) { + ILogger.debug("Tray is disabled, not initializing."); + await trayManager.destroy(); + return; + } - // Ensure tray icon display in linux sandboxed environments - if (Platform.environment.containsKey('FLATPAK_ID') || - Platform.environment.containsKey('SNAP')) { - await trayManager.setIcon('com.cloudchewie.cloudotp'); - } else if (ResponsiveUtil.isWindows()) { - await trayManager.setIcon('assets/logo-transparent.ico'); - } else { - await trayManager.setIcon('assets/logo-transparent.png'); - } + // Ensure tray icon display in linux sandboxed environments + if (Platform.environment.containsKey('FLATPAK_ID') || + Platform.environment.containsKey('SNAP')) { + await trayManager.setIcon('com.cloudchewie.cloudotp'); + } else if (ResponsiveUtil.isWindows()) { + await trayManager.setIcon('assets/logo-transparent.ico'); + } else { + await trayManager.setIcon('assets/logo-transparent.png'); + } - bool lauchAtStartup = await LaunchAtStartup.instance.isEnabled(); - if (!ResponsiveUtil.isLinux()) { - await trayManager.setToolTip(ResponsiveUtil.appName); + bool lauchAtStartup = await LaunchAtStartup.instance.isEnabled(); + if (!ResponsiveUtil.isLinux()) { + await trayManager.setToolTip(ResponsiveUtil.appName); + } + Menu menu = Menu( + items: [ + MenuItem( + key: TrayKey.displayApp.key, + label: appLocalizations.displayAppTray, + ), + MenuItem.separator(), + MenuItem( + key: TrayKey.officialWebsite.key, + label: appLocalizations.officialWebsiteTray, + ), + MenuItem( + key: TrayKey.githubRepository.key, + label: appLocalizations.repoTray, + ), + MenuItem.separator(), + MenuItem.checkbox( + checked: lauchAtStartup, + key: TrayKey.launchAtStartup.key, + label: appLocalizations.launchAtStartup, + ), + MenuItem.separator(), + MenuItem( + key: TrayKey.exitApp.key, + label: appLocalizations.exitAppTray, + ), + ], + ); + await trayManager.setContextMenu(menu); + ILogger.debug("Simple tray initialized successfully."); + } catch (e, t) { + ILogger.error("Failed to initialize simple tray", e, t); } - Menu menu = Menu( - items: [ - MenuItem( - key: TrayKey.displayApp.key, - label: appLocalizations.displayAppTray, - ), - MenuItem.separator(), - MenuItem( - key: TrayKey.officialWebsite.key, - label: appLocalizations.officialWebsiteTray, - ), - MenuItem( - key: TrayKey.githubRepository.key, - label: appLocalizations.repoTray, - ), - MenuItem.separator(), - MenuItem.checkbox( - checked: lauchAtStartup, - key: TrayKey.launchAtStartup.key, - label: appLocalizations.launchAtStartup, - ), - MenuItem.separator(), - MenuItem( - key: TrayKey.exitApp.key, - label: appLocalizations.exitAppTray, - ), - ], - ); - await trayManager.setContextMenu(menu); } static processTrayMenuItemClick( @@ -270,6 +285,7 @@ class Utils { MenuItem menuItem, [ bool isSimple = false, ]) async { + ILogger.debug("Processing tray menu item click: ${menuItem.key}"); if (menuItem.key == TrayKey.displayApp.key) { ChewieUtils.displayApp(); } else if (menuItem.key == TrayKey.shortcutHelp.key) { diff --git a/lib/main.dart b/lib/main.dart index 30b67b1a..811c04d0 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -101,8 +101,11 @@ Future initApp(WidgetsBinding widgetsBinding) async { await BiometricUtil.initStorage(); await TokenImageUtil.loadBrandLogos(); CustomFont.downloadFont(showToast: false); - if (ResponsiveUtil.isAndroid()) initAndroid(); - if (ResponsiveUtil.isDesktop()) initDesktop(); + if (ResponsiveUtil.isAndroid()) await initAndroid(); + if (ResponsiveUtil.isDesktop()) await initDesktop(); + ILogger.debug( + "Running on ${ResponsiveUtil.platformName} with version ${ResponsiveUtil.version}"); + ILogger.debug(ResponsiveUtil.deviceDescription); } Future initHive() async { @@ -148,6 +151,8 @@ Future initDesktop() async { appName: ResponsiveUtil.appName, shortcutPolicy: ShortcutPolicy.requireCreate, ); + ILogger.debug( + "LaunchAtStartup: ${await LaunchAtStartup.instance.isEnabled()}"); ChewieHiveUtil.put(ChewieHiveUtil.launchAtStartupKey, await LaunchAtStartup.instance.isEnabled()); for (String scheme in kWindowsSchemes) { diff --git a/third-party/chewie/lib/src/Utils/General/responsive_util.dart b/third-party/chewie/lib/src/Utils/General/responsive_util.dart index 9ac2d7fb..29da7338 100644 --- a/third-party/chewie/lib/src/Utils/General/responsive_util.dart +++ b/third-party/chewie/lib/src/Utils/General/responsive_util.dart @@ -101,7 +101,11 @@ class ResponsiveUtil { } static bool isAppBundle() { - ILogger.debug("BUILD_TYPE is $buildType"); + if (buildType.isNotEmpty) { + ILogger.debug("BUILD_TYPE is $buildType"); + } else { + ILogger.debug("BUILD_TYPE is not set, defaulting to false"); + } if (Platform.isAndroid) { if (buildType == 'appbundle') { ILogger.debug("Building appbundle for google play store"); diff --git a/third-party/chewie/lib/src/Utils/System/file_util.dart b/third-party/chewie/lib/src/Utils/System/file_util.dart index 48d17f81..4456749d 100644 --- a/third-party/chewie/lib/src/Utils/System/file_util.dart +++ b/third-party/chewie/lib/src/Utils/System/file_util.dart @@ -806,7 +806,7 @@ class FileUtil { final currentPath = Platform.resolvedExecutable; final installPath = "${installPathPtr.cast().toDartString()}\\${ResponsiveUtil.appName}.exe"; - ILogger.info(ResponsiveUtil.appName, + ILogger.info( "Get install path: $installPath and current path: $currentPath"); tmp = installPath == currentPath ? WindowsVersion.installed diff --git a/third-party/chewie/lib/src/Utils/System/hive_util.dart b/third-party/chewie/lib/src/Utils/System/hive_util.dart index 370a27f5..43f79545 100644 --- a/third-party/chewie/lib/src/Utils/System/hive_util.dart +++ b/third-party/chewie/lib/src/Utils/System/hive_util.dart @@ -101,7 +101,6 @@ class ChewieHiveUtil { } static void setWindowPosition(Offset offset) { - ILogger.info("Set window position at ${offset.dx},${offset.dy}"); ChewieHiveUtil.put( ChewieHiveUtil.windowPositionKey, "${offset.dx},${offset.dy}"); } @@ -117,8 +116,6 @@ class ChewieHiveUtil { } try { List list = position.split(","); - ILogger.info( - "Get window position ${double.parse(list[0])},${double.parse(list[1])}"); return Offset(double.parse(list[0]), double.parse(list[1])); } catch (e, t) { ILogger.error("Failed to get window position", e, t); diff --git a/third-party/tool/awesome_cloud/lib/services/huaweicloud.dart b/third-party/tool/awesome_cloud/lib/services/huaweicloud.dart index 4eeb52d0..1cff7d69 100644 --- a/third-party/tool/awesome_cloud/lib/services/huaweicloud.dart +++ b/third-party/tool/awesome_cloud/lib/services/huaweicloud.dart @@ -292,8 +292,8 @@ class HuaweiCloud extends BaseCloudService { @override Future push( Uint8List bytes, - String fileName, - String remotePath, { + String remotePath, + String fileName, { Function(int, int)? onProgress, }) async { CloudLogger.info(