diff --git a/src/main/java/org/cryptomator/integrations/tray/ActionItem.java b/src/main/java/org/cryptomator/integrations/tray/ActionItem.java index 383618b..b11a7c5 100644 --- a/src/main/java/org/cryptomator/integrations/tray/ActionItem.java +++ b/src/main/java/org/cryptomator/integrations/tray/ActionItem.java @@ -1,4 +1,8 @@ package org.cryptomator.integrations.tray; -public record ActionItem(String title, Runnable action) implements TrayMenuItem { +public record ActionItem(String title, Runnable action, boolean enabled) implements TrayMenuItem { + + public ActionItem(String title, Runnable action) { + this(title, action, true); + } } diff --git a/src/main/java/org/cryptomator/integrations/tray/TrayMenuController.java b/src/main/java/org/cryptomator/integrations/tray/TrayMenuController.java index fadb980..2d8b864 100644 --- a/src/main/java/org/cryptomator/integrations/tray/TrayMenuController.java +++ b/src/main/java/org/cryptomator/integrations/tray/TrayMenuController.java @@ -23,12 +23,12 @@ static Optional get() { /** * Displays an icon on the system tray. * - * @param rawImageData What image to show + * @param imageData What image to show * @param defaultAction Action to perform when interacting with the icon directly instead of its menu * @param tooltip Text shown when hovering - * @throws IOException thrown when interacting with the given rawImageData + * @throws TrayMenuException thrown when adding the tray icon failed */ - void showTrayIcon(InputStream rawImageData, Runnable defaultAction, String tooltip) throws IOException; + void showTrayIcon(byte[] imageData, Runnable defaultAction, String tooltip) throws TrayMenuException; /** * Show the given options in the tray menu. @@ -36,7 +36,8 @@ static Optional get() { * This method may be called multiple times, e.g. when the vault list changes. * * @param items Menu items + * @throws TrayMenuException thrown when updating the tray menu failed */ - void updateTrayMenu(List items); + void updateTrayMenu(List items) throws TrayMenuException; } diff --git a/src/main/java/org/cryptomator/integrations/tray/TrayMenuException.java b/src/main/java/org/cryptomator/integrations/tray/TrayMenuException.java new file mode 100644 index 0000000..e9b61da --- /dev/null +++ b/src/main/java/org/cryptomator/integrations/tray/TrayMenuException.java @@ -0,0 +1,13 @@ +package org.cryptomator.integrations.tray; + +public class TrayMenuException extends Exception { + + public TrayMenuException(String message) { + super(message); + } + + public TrayMenuException(String message, Throwable cause) { + super(message, cause); + } + +} \ No newline at end of file