Skip to content

Commit c3aa6a2

Browse files
2 parents 6b90bdc + a2f2f9c commit c3aa6a2

File tree

10 files changed

+170
-158
lines changed

10 files changed

+170
-158
lines changed

lib/Database/database_manager.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -263,11 +263,7 @@ class DatabaseManager {
263263
if (Platform.isLinux || Platform.isAndroid) {
264264
try {
265265
lib = DynamicLibrary.open('libsqlcipher.so');
266-
} catch (e, t) {
267-
ILogger.error(
268-
"Failed to load libsqlcipher.so, perhaps the library is not installed or not in the correct path.",
269-
e,
270-
t);
266+
} catch (e) {
271267
if (Platform.isAndroid) {
272268
final appIdAsBytes = File('/proc/self/cmdline').readAsBytesSync();
273269
final endOfAppId = max(appIdAsBytes.indexOf(0), 0);

lib/Screens/Lock/pin_verify_screen.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class PinVerifyScreenState extends BaseWindowState<PinVerifyScreen>
7373

7474
@override
7575
void initState() {
76-
if (widget.jumpToMain) {
76+
if (widget.isModal) {
7777
trayManager.addListener(this);
7878
Utils.initSimpleTray();
7979
}

lib/Screens/main_screen.dart

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ class MainScreenState extends BaseWindowState<MainScreen>
6969
ProtocolListener,
7070
AutomaticKeepAliveClientMixin {
7171
Timer? _timer;
72-
Orientation _oldOrientation = Orientation.portrait;
7372
TextEditingController searchController = TextEditingController();
7473

7574
@override
@@ -120,6 +119,10 @@ class MainScreenState extends BaseWindowState<MainScreen>
120119
if (ResponsiveUtil.isDesktop() && !ResponsiveUtil.isLinux()) {
121120
protocolHandler.addListener(this);
122121
}
122+
if (ResponsiveUtil.isDesktop()) {
123+
Utils.initTray();
124+
}
125+
trayManager.addListener(this);
123126
windowManager.addListener(this);
124127
WidgetsBinding.instance.addObserver(this);
125128
CloudOTPHiveUtil.showCloudEntry().then((value) {
@@ -131,30 +134,23 @@ class MainScreenState extends BaseWindowState<MainScreen>
131134
defaultValue: false)) {
132135
ShortcutsUtil.focusSearch();
133136
}
134-
if (ResponsiveUtil.isDesktop()) {
135-
await Utils.initTray();
136-
trayManager.addListener(this);
137-
// keyboardHandlerState?.focus();
138-
}
139-
if (mounted) {
140-
initGlobalConfig();
141-
_oldOrientation = MediaQuery.of(context).orientation;
142-
EasyRefresh.defaultHeaderBuilder = () => LottieCupertinoHeader(
143-
backgroundColor: ChewieTheme.canvasColor,
144-
indicator: LottieFiles.load(LottieFiles.getLoadingPath(context),
145-
scale: 1.5),
146-
hapticFeedback: true,
147-
triggerOffset: 40,
148-
);
149-
EasyRefresh.defaultFooterBuilder = () => LottieCupertinoFooter(
150-
indicator: LottieFiles.load(LottieFiles.getLoadingPath(context)),
151-
);
152-
chewieProvider.loadingWidgetBuilder = (size, forceDark) =>
153-
LottieFiles.load(
137+
EasyRefresh.defaultHeaderBuilder = () => LottieCupertinoHeader(
138+
backgroundColor: ChewieTheme.canvasColor,
139+
indicator: LottieFiles.load(LottieFiles.getLoadingPath(context),
140+
scale: 1.5),
141+
hapticFeedback: true,
142+
triggerOffset: 40,
143+
);
144+
EasyRefresh.defaultFooterBuilder = () => LottieCupertinoFooter(
145+
indicator: LottieFiles.load(LottieFiles.getLoadingPath(context)),
146+
);
147+
chewieProvider.loadingWidgetBuilder =
148+
(size, forceDark) => LottieFiles.load(
154149
LottieFiles.getLoadingPath(chewieProvider.rootContext),
155-
scale: 1.5);
156-
}
150+
scale: 1.5,
151+
);
157152
});
153+
initGlobalConfig();
158154
searchController.addListener(() {
159155
homeScreenState?.performSearch(searchController.text);
160156
});
@@ -208,8 +204,6 @@ class MainScreenState extends BaseWindowState<MainScreen>
208204
defaultValue: defaultEnableSafeMode));
209205
super.build(context);
210206
return OrientationBuilder(builder: (ctx, ori) {
211-
if (ori != _oldOrientation) {}
212-
_oldOrientation = ori;
213207
return _buildBodyByPlatform();
214208
});
215209
}

lib/Utils/biometric_util.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class BiometricUtil {
7171
ILogger.info("No passcode set on this device");
7272
break;
7373
default:
74-
ILogger.info("Unknown error");
74+
ILogger.info("Biometric Unknown error");
7575
break;
7676
}
7777
}

lib/Utils/utils.dart

Lines changed: 133 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -136,140 +136,156 @@ class Utils {
136136
}
137137

138138
static Future<void> initTray() async {
139-
if (!ResponsiveUtil.isDesktop()) return;
140-
await trayManager.destroy();
141-
if (!ChewieHiveUtil.getBool(ChewieHiveUtil.showTrayKey)) {
139+
try {
140+
if (!ResponsiveUtil.isDesktop()) return;
141+
ILogger.debug("Initializing tray...");
142142
await trayManager.destroy();
143-
return;
144-
}
145-
146-
// Ensure tray icon display in linux sandboxed environments
147-
if (Platform.environment.containsKey('FLATPAK_ID') ||
148-
Platform.environment.containsKey('SNAP')) {
149-
await trayManager.setIcon('com.cloudchewie.cloudotp');
150-
} else if (ResponsiveUtil.isWindows()) {
151-
await trayManager.setIcon('assets/logo-transparent.ico');
152-
} else {
153-
await trayManager.setIcon('assets/logo-transparent.png');
154-
}
143+
if (!ChewieHiveUtil.getBool(ChewieHiveUtil.showTrayKey)) {
144+
ILogger.debug("Tray is disabled, not initializing.");
145+
await trayManager.destroy();
146+
return;
147+
}
148+
// Ensure tray icon display in linux sandboxed environments
149+
if (Platform.environment.containsKey('FLATPAK_ID') ||
150+
Platform.environment.containsKey('SNAP')) {
151+
await trayManager.setIcon('com.cloudchewie.cloudotp');
152+
} else if (ResponsiveUtil.isWindows()) {
153+
await trayManager.setIcon('assets/logo-transparent.ico');
154+
} else {
155+
await trayManager.setIcon('assets/logo-transparent.png');
156+
}
155157

156-
bool lauchAtStartup = await LaunchAtStartup.instance.isEnabled();
157-
if (!ResponsiveUtil.isLinux()) {
158-
await trayManager.setToolTip(ResponsiveUtil.appName);
158+
bool lauchAtStartup = await LaunchAtStartup.instance.isEnabled();
159+
if (!ResponsiveUtil.isLinux()) {
160+
ILogger.debug(
161+
"Setting tray tooltip to app name ${ResponsiveUtil.appName}");
162+
await trayManager.setToolTip(ResponsiveUtil.appName);
163+
}
164+
Menu menu = Menu(
165+
items: [
166+
MenuItem(
167+
key: TrayKey.checkUpdates.key,
168+
label: appProvider.latestVersion.isNotEmpty
169+
? appLocalizations.getNewVersion(appProvider.latestVersion)
170+
: appLocalizations.checkUpdates,
171+
),
172+
MenuItem(
173+
key: TrayKey.shortcutHelp.key,
174+
label: appLocalizations.shortcutHelp,
175+
),
176+
MenuItem.separator(),
177+
MenuItem(
178+
key: TrayKey.displayApp.key,
179+
label: appLocalizations.displayAppTray,
180+
),
181+
MenuItem(
182+
key: TrayKey.lockApp.key,
183+
label: appLocalizations.lockAppTray,
184+
),
185+
...await getTrayTokenMenuItems(),
186+
MenuItem.separator(),
187+
MenuItem(
188+
key: TrayKey.setting.key,
189+
label: appLocalizations.setting,
190+
),
191+
MenuItem(
192+
key: TrayKey.officialWebsite.key,
193+
label: appLocalizations.officialWebsiteTray,
194+
),
195+
MenuItem(
196+
key: TrayKey.about.key,
197+
label: appLocalizations.about,
198+
),
199+
MenuItem(
200+
key: TrayKey.githubRepository.key,
201+
label: appLocalizations.repoTray,
202+
),
203+
MenuItem.separator(),
204+
MenuItem.checkbox(
205+
checked: lauchAtStartup,
206+
key: TrayKey.launchAtStartup.key,
207+
label: appLocalizations.launchAtStartup,
208+
),
209+
MenuItem.separator(),
210+
MenuItem(
211+
key: TrayKey.exitApp.key,
212+
label: appLocalizations.exitAppTray,
213+
),
214+
],
215+
);
216+
await trayManager.setContextMenu(menu);
217+
ILogger.debug("Tray initialized successfully.");
218+
} catch (e, t) {
219+
ILogger.error("Failed to initialize simple tray", e, t);
159220
}
160-
Menu menu = Menu(
161-
items: [
162-
MenuItem(
163-
key: TrayKey.checkUpdates.key,
164-
label: appProvider.latestVersion.isNotEmpty
165-
? appLocalizations.getNewVersion(appProvider.latestVersion)
166-
: appLocalizations.checkUpdates,
167-
),
168-
MenuItem(
169-
key: TrayKey.shortcutHelp.key,
170-
label: appLocalizations.shortcutHelp,
171-
),
172-
MenuItem.separator(),
173-
MenuItem(
174-
key: TrayKey.displayApp.key,
175-
label: appLocalizations.displayAppTray,
176-
),
177-
MenuItem(
178-
key: TrayKey.lockApp.key,
179-
label: appLocalizations.lockAppTray,
180-
),
181-
...await getTrayTokenMenuItems(),
182-
MenuItem.separator(),
183-
MenuItem(
184-
key: TrayKey.setting.key,
185-
label: appLocalizations.setting,
186-
),
187-
MenuItem(
188-
key: TrayKey.officialWebsite.key,
189-
label: appLocalizations.officialWebsiteTray,
190-
),
191-
MenuItem(
192-
key: TrayKey.about.key,
193-
label: appLocalizations.about,
194-
),
195-
MenuItem(
196-
key: TrayKey.githubRepository.key,
197-
label: appLocalizations.repoTray,
198-
),
199-
MenuItem.separator(),
200-
MenuItem.checkbox(
201-
checked: lauchAtStartup,
202-
key: TrayKey.launchAtStartup.key,
203-
label: appLocalizations.launchAtStartup,
204-
),
205-
MenuItem.separator(),
206-
MenuItem(
207-
key: TrayKey.exitApp.key,
208-
label: appLocalizations.exitAppTray,
209-
),
210-
],
211-
);
212-
await trayManager.setContextMenu(menu);
213221
}
214222

215223
static Future<void> initSimpleTray() async {
216-
if (!ResponsiveUtil.isDesktop()) return;
217-
await trayManager.destroy();
218-
if (!ChewieHiveUtil.getBool(ChewieHiveUtil.showTrayKey)) {
224+
try {
225+
if (!ResponsiveUtil.isDesktop()) return;
226+
ILogger.debug("Initializing simple tray...");
219227
await trayManager.destroy();
220-
return;
221-
}
228+
if (!ChewieHiveUtil.getBool(ChewieHiveUtil.showTrayKey)) {
229+
ILogger.debug("Tray is disabled, not initializing.");
230+
await trayManager.destroy();
231+
return;
232+
}
222233

223-
// Ensure tray icon display in linux sandboxed environments
224-
if (Platform.environment.containsKey('FLATPAK_ID') ||
225-
Platform.environment.containsKey('SNAP')) {
226-
await trayManager.setIcon('com.cloudchewie.cloudotp');
227-
} else if (ResponsiveUtil.isWindows()) {
228-
await trayManager.setIcon('assets/logo-transparent.ico');
229-
} else {
230-
await trayManager.setIcon('assets/logo-transparent.png');
231-
}
234+
// Ensure tray icon display in linux sandboxed environments
235+
if (Platform.environment.containsKey('FLATPAK_ID') ||
236+
Platform.environment.containsKey('SNAP')) {
237+
await trayManager.setIcon('com.cloudchewie.cloudotp');
238+
} else if (ResponsiveUtil.isWindows()) {
239+
await trayManager.setIcon('assets/logo-transparent.ico');
240+
} else {
241+
await trayManager.setIcon('assets/logo-transparent.png');
242+
}
232243

233-
bool lauchAtStartup = await LaunchAtStartup.instance.isEnabled();
234-
if (!ResponsiveUtil.isLinux()) {
235-
await trayManager.setToolTip(ResponsiveUtil.appName);
244+
bool lauchAtStartup = await LaunchAtStartup.instance.isEnabled();
245+
if (!ResponsiveUtil.isLinux()) {
246+
await trayManager.setToolTip(ResponsiveUtil.appName);
247+
}
248+
Menu menu = Menu(
249+
items: [
250+
MenuItem(
251+
key: TrayKey.displayApp.key,
252+
label: appLocalizations.displayAppTray,
253+
),
254+
MenuItem.separator(),
255+
MenuItem(
256+
key: TrayKey.officialWebsite.key,
257+
label: appLocalizations.officialWebsiteTray,
258+
),
259+
MenuItem(
260+
key: TrayKey.githubRepository.key,
261+
label: appLocalizations.repoTray,
262+
),
263+
MenuItem.separator(),
264+
MenuItem.checkbox(
265+
checked: lauchAtStartup,
266+
key: TrayKey.launchAtStartup.key,
267+
label: appLocalizations.launchAtStartup,
268+
),
269+
MenuItem.separator(),
270+
MenuItem(
271+
key: TrayKey.exitApp.key,
272+
label: appLocalizations.exitAppTray,
273+
),
274+
],
275+
);
276+
await trayManager.setContextMenu(menu);
277+
ILogger.debug("Simple tray initialized successfully.");
278+
} catch (e, t) {
279+
ILogger.error("Failed to initialize simple tray", e, t);
236280
}
237-
Menu menu = Menu(
238-
items: [
239-
MenuItem(
240-
key: TrayKey.displayApp.key,
241-
label: appLocalizations.displayAppTray,
242-
),
243-
MenuItem.separator(),
244-
MenuItem(
245-
key: TrayKey.officialWebsite.key,
246-
label: appLocalizations.officialWebsiteTray,
247-
),
248-
MenuItem(
249-
key: TrayKey.githubRepository.key,
250-
label: appLocalizations.repoTray,
251-
),
252-
MenuItem.separator(),
253-
MenuItem.checkbox(
254-
checked: lauchAtStartup,
255-
key: TrayKey.launchAtStartup.key,
256-
label: appLocalizations.launchAtStartup,
257-
),
258-
MenuItem.separator(),
259-
MenuItem(
260-
key: TrayKey.exitApp.key,
261-
label: appLocalizations.exitAppTray,
262-
),
263-
],
264-
);
265-
await trayManager.setContextMenu(menu);
266281
}
267282

268283
static processTrayMenuItemClick(
269284
BuildContext context,
270285
MenuItem menuItem, [
271286
bool isSimple = false,
272287
]) async {
288+
ILogger.debug("Processing tray menu item click: ${menuItem.key}");
273289
if (menuItem.key == TrayKey.displayApp.key) {
274290
ChewieUtils.displayApp();
275291
} else if (menuItem.key == TrayKey.shortcutHelp.key) {

0 commit comments

Comments
 (0)