Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions lib/Database/database_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion lib/Screens/Lock/pin_verify_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class PinVerifyScreenState extends BaseWindowState<PinVerifyScreen>

@override
void initState() {
if (widget.jumpToMain) {
if (widget.isModal) {
trayManager.addListener(this);
Utils.initSimpleTray();
}
Expand Down
44 changes: 19 additions & 25 deletions lib/Screens/main_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ class MainScreenState extends BaseWindowState<MainScreen>
ProtocolListener,
AutomaticKeepAliveClientMixin {
Timer? _timer;
Orientation _oldOrientation = Orientation.portrait;
TextEditingController searchController = TextEditingController();

@override
Expand Down Expand Up @@ -120,6 +119,10 @@ class MainScreenState extends BaseWindowState<MainScreen>
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) {
Expand All @@ -131,30 +134,23 @@ class MainScreenState extends BaseWindowState<MainScreen>
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);
});
Expand Down Expand Up @@ -208,8 +204,6 @@ class MainScreenState extends BaseWindowState<MainScreen>
defaultValue: defaultEnableSafeMode));
super.build(context);
return OrientationBuilder(builder: (ctx, ori) {
if (ori != _oldOrientation) {}
_oldOrientation = ori;
return _buildBodyByPlatform();
});
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Utils/biometric_util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
250 changes: 133 additions & 117 deletions lib/Utils/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -136,140 +136,156 @@ class Utils {
}

static Future<void> 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<void> 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(
BuildContext context,
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) {
Expand Down
Loading