mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-17 10:11:27 +00:00
Implemented that a different system tray icon is shown to indicate when one or more vaults are unlocked. The unlocked icons are placeholders and will updated visually in following commits.
This commit is contained in:
@@ -53,6 +53,7 @@ public class ExitUtil {
|
||||
private final Localization localization;
|
||||
private final Settings settings;
|
||||
private final Optional<MacFunctions> macFunctions;
|
||||
private TrayIcon trayIcon;
|
||||
|
||||
@Inject
|
||||
public ExitUtil(@Named("mainWindow") Stage mainWindow, Localization localization, Settings settings, Optional<MacFunctions> macFunctions) {
|
||||
@@ -82,7 +83,7 @@ public class ExitUtil {
|
||||
}
|
||||
|
||||
private void initTrayIconExitHandler(Runnable exitCommand) {
|
||||
final TrayIcon trayIcon = createTrayIcon(exitCommand);
|
||||
trayIcon = createTrayIcon(exitCommand);
|
||||
try {
|
||||
// double clicking tray icon should open Cryptomator
|
||||
if (SystemUtils.IS_OS_WINDOWS) {
|
||||
@@ -118,14 +119,7 @@ public class ExitUtil {
|
||||
exitItem.addActionListener(e -> exitCommand.run());
|
||||
popup.add(exitItem);
|
||||
|
||||
final Image image;
|
||||
if (SystemUtils.IS_OS_MAC_OSX && isMacMenuBarDarkMode()) {
|
||||
image = Toolkit.getDefaultToolkit().getImage(getClass().getResource("/tray_icon_mac_white.png"));
|
||||
} else if (SystemUtils.IS_OS_MAC_OSX) {
|
||||
image = Toolkit.getDefaultToolkit().getImage(getClass().getResource("/tray_icon_mac_black.png"));
|
||||
} else {
|
||||
image = Toolkit.getDefaultToolkit().getImage(getClass().getResource("/tray_icon.png"));
|
||||
}
|
||||
final Image image = getAppropriateTrayIconImage(true);
|
||||
|
||||
return new TrayIcon(image, localization.getString("app.name"), popup);
|
||||
}
|
||||
@@ -202,4 +196,23 @@ public class ExitUtil {
|
||||
});
|
||||
}
|
||||
|
||||
public void updateTrayIcon(boolean areAllVaultsLocked) {
|
||||
if (trayIcon != null) {
|
||||
Image image = getAppropriateTrayIconImage(areAllVaultsLocked);
|
||||
trayIcon.setImage(image);
|
||||
}
|
||||
}
|
||||
|
||||
private Image getAppropriateTrayIconImage(boolean areAllVaultsLocked) {
|
||||
String resourceName;
|
||||
if (SystemUtils.IS_OS_MAC_OSX && isMacMenuBarDarkMode()) {
|
||||
resourceName = areAllVaultsLocked ? "/tray_icon_mac_white.png" : "/tray_icon_unlocked_mac_white.png";
|
||||
} else if (SystemUtils.IS_OS_MAC_OSX) {
|
||||
resourceName = areAllVaultsLocked ? "/tray_icon_mac_black.png" : "/tray_icon_unlocked_mac_black.png";
|
||||
} else {
|
||||
resourceName = areAllVaultsLocked ? "/tray_icon.png" : "/tray_icon_unlocked.png";
|
||||
}
|
||||
return Toolkit.getDefaultToolkit().getImage(getClass().getResource(resourceName));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -125,6 +125,7 @@ public class MainController implements ViewController {
|
||||
this.upgradeStrategyForSelectedVault = EasyBind.monadic(selectedVault).map(upgradeStrategies::getUpgradeStrategy);
|
||||
this.areAllVaultsLocked = Bindings.isEmpty(FXCollections.observableList(vaults, Vault::observables).filtered(Vault.NOT_LOCKED));
|
||||
|
||||
EasyBind.subscribe(areAllVaultsLocked, exitUtil::updateTrayIcon);
|
||||
EasyBind.subscribe(areAllVaultsLocked, Platform::setImplicitExit);
|
||||
autoUnlocker.unlockAllSilently();
|
||||
|
||||
|
||||
BIN
main/ui/src/main/resources/tray_icon_unlocked.png
Normal file
BIN
main/ui/src/main/resources/tray_icon_unlocked.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 588 B |
BIN
main/ui/src/main/resources/tray_icon_unlocked_mac_black.png
Normal file
BIN
main/ui/src/main/resources/tray_icon_unlocked_mac_black.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 350 B |
BIN
main/ui/src/main/resources/tray_icon_unlocked_mac_black@2x.png
Normal file
BIN
main/ui/src/main/resources/tray_icon_unlocked_mac_black@2x.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 692 B |
BIN
main/ui/src/main/resources/tray_icon_unlocked_mac_white.png
Normal file
BIN
main/ui/src/main/resources/tray_icon_unlocked_mac_white.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 359 B |
BIN
main/ui/src/main/resources/tray_icon_unlocked_mac_white@2x.png
Normal file
BIN
main/ui/src/main/resources/tray_icon_unlocked_mac_white@2x.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 707 B |
Reference in New Issue
Block a user