mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-20 11:41:26 +00:00
Code improvements continued
Discussion: https://github.com/cryptomator/cryptomator/pull/2885
This commit is contained in:
@@ -35,7 +35,7 @@ open module org.cryptomator.desktop {
|
||||
requires org.apache.commons.lang3;
|
||||
|
||||
/* TODO: filename-based modules: */
|
||||
requires static javax.inject;
|
||||
requires static javax.inject; /* ugly dagger/guava crap */
|
||||
|
||||
provides TrayMenuController with AwtTrayMenuController;
|
||||
provides Configurator with LogbackConfiguratorFactory;
|
||||
|
||||
@@ -30,8 +30,8 @@ import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* Responsible to manage the tray icon on macOS and Windows using AWT.
|
||||
* For Linux, we use {@link AppindicatorTrayMenuController}
|
||||
* Fallback tray icon implementation using AWT. This will only be used if no better implementation is found.
|
||||
* @see <a href="https://github.com/cryptomator/integrations-linux/blob/33f9a4685b781b55fcce399b8618818bfc08cbdf/src/main/java/org/cryptomator/linux/tray/AppindicatorTrayMenuController.java">preferred AppIndicator-based implementation used on Linux</a>
|
||||
*/
|
||||
@CheckAvailability
|
||||
@Priority(Priority.FALLBACK)
|
||||
@@ -46,7 +46,7 @@ public class AwtTrayMenuController implements TrayMenuController {
|
||||
|
||||
@CheckAvailability
|
||||
public static boolean isAvailable() {
|
||||
return !SystemUtils.IS_OS_LINUX && SystemTray.isSupported();
|
||||
return SystemTray.isSupported();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -112,7 +112,7 @@ public class AwtTrayMenuController implements TrayMenuController {
|
||||
menuItem.setEnabled(a.enabled());
|
||||
menu.add(menuItem);
|
||||
}
|
||||
case SeparatorItem separatorItem -> menu.addSeparator();
|
||||
case SeparatorItem s -> menu.addSeparator(); // TODO: rename pattern variable with JEP 443
|
||||
case SubMenuItem s -> {
|
||||
var submenu = new Menu(s.title());
|
||||
addChildren(submenu, s.items());
|
||||
|
||||
@@ -69,7 +69,7 @@ public class TrayMenuBuilder {
|
||||
trayMenu.showTrayIcon(loader -> {
|
||||
switch (loader) {
|
||||
case TrayIconLoader.PngData l -> l.loadPng(getAppropriateTrayIconImage());
|
||||
case TrayIconLoader.FreedesktopIconName l -> l.lookupByName(getAppropriateTrayIconSVG());
|
||||
case TrayIconLoader.FreedesktopIconName l -> l.lookupByName(getAppropriateFreedesktopIconName());
|
||||
}
|
||||
}, this::showMainWindow, "Cryptomator");
|
||||
trayMenu.onBeforeOpenMenu(() -> {
|
||||
@@ -93,7 +93,7 @@ public class TrayMenuBuilder {
|
||||
trayMenu.updateTrayIcon(loader -> {
|
||||
switch (loader) {
|
||||
case TrayIconLoader.PngData l -> l.loadPng(getAppropriateTrayIconImage());
|
||||
case TrayIconLoader.FreedesktopIconName l -> l.lookupByName(getAppropriateTrayIconSVG());
|
||||
case TrayIconLoader.FreedesktopIconName l -> l.lookupByName(getAppropriateFreedesktopIconName());
|
||||
}
|
||||
});
|
||||
rebuildMenu();
|
||||
@@ -184,7 +184,7 @@ public class TrayMenuBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
private String getAppropriateTrayIconSVG() {
|
||||
private String getAppropriateFreedesktopIconName() {
|
||||
boolean isAnyVaultUnlocked = vaults.stream().anyMatch(Vault::isUnlocked);
|
||||
|
||||
return isAnyVaultUnlocked ? "org.cryptomator.Cryptomator-monochrome-unlocked" : "org.cryptomator.Cryptomator-monochrome";
|
||||
|
||||
Reference in New Issue
Block a user