From 4ec1101efa9fc4677aa0f7806fb3964df56fc523 Mon Sep 17 00:00:00 2001 From: Armin Schrenk Date: Fri, 17 Mar 2023 16:53:24 +0100 Subject: [PATCH 1/9] Remove experimental status of mount api --- .../org/cryptomator/integrations/mount/package-info.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main/java/org/cryptomator/integrations/mount/package-info.java b/src/main/java/org/cryptomator/integrations/mount/package-info.java index d6535b2..5f6690f 100644 --- a/src/main/java/org/cryptomator/integrations/mount/package-info.java +++ b/src/main/java/org/cryptomator/integrations/mount/package-info.java @@ -1,7 +1,4 @@ /** * Mount service package */ -@ApiStatus.Experimental -package org.cryptomator.integrations.mount; - -import org.jetbrains.annotations.ApiStatus; +package org.cryptomator.integrations.mount; \ No newline at end of file From 3e53d065ed3b58fc6967674e5753b37bf26da421 Mon Sep 17 00:00:00 2001 From: Ralph Plawetzki Date: Wed, 12 Apr 2023 15:09:20 +0200 Subject: [PATCH 2/9] Widen API to show svg icons --- .../integrations/tray/TrayMenuController.java | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/cryptomator/integrations/tray/TrayMenuController.java b/src/main/java/org/cryptomator/integrations/tray/TrayMenuController.java index 85f8c63..79182f2 100644 --- a/src/main/java/org/cryptomator/integrations/tray/TrayMenuController.java +++ b/src/main/java/org/cryptomator/integrations/tray/TrayMenuController.java @@ -28,15 +28,41 @@ static Optional get() { * @param tooltip Text shown when hovering * @throws TrayMenuException thrown when adding the tray icon failed */ - void showTrayIcon(byte[] imageData, Runnable defaultAction, String tooltip) throws TrayMenuException; + default void showTrayIcon(byte[] imageData, Runnable defaultAction, String tooltip) throws TrayMenuException { + showTrayIcon(imageData, null, defaultAction, tooltip); + }; + + /** + * Displays an icon on the system tray. + * + * @param imageData What image to show + * @param icon The icon name of the icon to show. Can be an icon name following + * the Freedesktop Icon Naming Specification or a path to an icon file + * @param defaultAction Action to perform when interacting with the icon directly instead of its menu + * @param tooltip Text shown when hovering + * @throws TrayMenuException thrown when adding the tray icon failed + */ + void showTrayIcon(byte[] imageData, String icon, Runnable defaultAction, String tooltip) throws TrayMenuException; + + /** + * Updates the icon on the system tray. + * + * @param imageData What image to show + * @throws IllegalStateException thrown when called before an icon has been added + */ + default void updateTrayIcon(byte[] imageData) { + updateTrayIcon(imageData, null); + }; /** * Updates the icon on the system tray. * * @param imageData What image to show + * @param icon The icon name of the icon to show. Can be an icon name following + * the Freedesktop Icon Naming Specification or a path to an icon file * @throws IllegalStateException thrown when called before an icon has been added */ - void updateTrayIcon(byte[] imageData); + void updateTrayIcon(byte[] imageData, String icon); /** * Show the given options in the tray menu. From 8f51ba85b5113e8e550b7d663a05d1f60f307931 Mon Sep 17 00:00:00 2001 From: Ralph Plawetzki Date: Sun, 23 Apr 2023 08:03:50 +0200 Subject: [PATCH 3/9] Revert "Widen API to show svg icons" This reverts commit 3e53d065ed3b58fc6967674e5753b37bf26da421. --- .../integrations/tray/TrayMenuController.java | 30 ++----------------- 1 file changed, 2 insertions(+), 28 deletions(-) diff --git a/src/main/java/org/cryptomator/integrations/tray/TrayMenuController.java b/src/main/java/org/cryptomator/integrations/tray/TrayMenuController.java index 79182f2..85f8c63 100644 --- a/src/main/java/org/cryptomator/integrations/tray/TrayMenuController.java +++ b/src/main/java/org/cryptomator/integrations/tray/TrayMenuController.java @@ -28,41 +28,15 @@ static Optional get() { * @param tooltip Text shown when hovering * @throws TrayMenuException thrown when adding the tray icon failed */ - default void showTrayIcon(byte[] imageData, Runnable defaultAction, String tooltip) throws TrayMenuException { - showTrayIcon(imageData, null, defaultAction, tooltip); - }; - - /** - * Displays an icon on the system tray. - * - * @param imageData What image to show - * @param icon The icon name of the icon to show. Can be an icon name following - * the Freedesktop Icon Naming Specification or a path to an icon file - * @param defaultAction Action to perform when interacting with the icon directly instead of its menu - * @param tooltip Text shown when hovering - * @throws TrayMenuException thrown when adding the tray icon failed - */ - void showTrayIcon(byte[] imageData, String icon, Runnable defaultAction, String tooltip) throws TrayMenuException; - - /** - * Updates the icon on the system tray. - * - * @param imageData What image to show - * @throws IllegalStateException thrown when called before an icon has been added - */ - default void updateTrayIcon(byte[] imageData) { - updateTrayIcon(imageData, null); - }; + void showTrayIcon(byte[] imageData, Runnable defaultAction, String tooltip) throws TrayMenuException; /** * Updates the icon on the system tray. * * @param imageData What image to show - * @param icon The icon name of the icon to show. Can be an icon name following - * the Freedesktop Icon Naming Specification or a path to an icon file * @throws IllegalStateException thrown when called before an icon has been added */ - void updateTrayIcon(byte[] imageData, String icon); + void updateTrayIcon(byte[] imageData); /** * Show the given options in the tray menu. From 17fbf493eace2e32cec3658fafab98d7d9311e37 Mon Sep 17 00:00:00 2001 From: Ralph Plawetzki Date: Sun, 23 Apr 2023 08:15:09 +0200 Subject: [PATCH 4/9] Change API to support svg icons --- .../integrations/tray/TrayMenuController.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/cryptomator/integrations/tray/TrayMenuController.java b/src/main/java/org/cryptomator/integrations/tray/TrayMenuController.java index 85f8c63..5cdd413 100644 --- a/src/main/java/org/cryptomator/integrations/tray/TrayMenuController.java +++ b/src/main/java/org/cryptomator/integrations/tray/TrayMenuController.java @@ -3,8 +3,7 @@ import org.cryptomator.integrations.common.IntegrationsLoader; import org.jetbrains.annotations.ApiStatus; -import java.io.IOException; -import java.io.InputStream; +import java.net.URI; import java.util.List; import java.util.Optional; @@ -23,20 +22,20 @@ static Optional get() { /** * Displays an icon on the system tray. * - * @param imageData What image to show + * @param imageUri 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 TrayMenuException thrown when adding the tray icon failed */ - void showTrayIcon(byte[] imageData, Runnable defaultAction, String tooltip) throws TrayMenuException; + void showTrayIcon(URI imageUri, Runnable defaultAction, String tooltip) throws TrayMenuException; /** * Updates the icon on the system tray. * - * @param imageData What image to show + * @param imageUri What image to show * @throws IllegalStateException thrown when called before an icon has been added */ - void updateTrayIcon(byte[] imageData); + void updateTrayIcon(URI imageUri); /** * Show the given options in the tray menu. From cdf313e4feb132714c9cb2ec895036f7ec97a3c0 Mon Sep 17 00:00:00 2001 From: Sebastian Stenzel Date: Tue, 2 May 2023 18:33:22 +0200 Subject: [PATCH 5/9] polymorphic tray icon loading --- .../integrations/tray/TrayIconLoader.java | 27 +++++++++++++++++++ .../integrations/tray/TrayMenuController.java | 10 +++---- 2 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 src/main/java/org/cryptomator/integrations/tray/TrayIconLoader.java diff --git a/src/main/java/org/cryptomator/integrations/tray/TrayIconLoader.java b/src/main/java/org/cryptomator/integrations/tray/TrayIconLoader.java new file mode 100644 index 0000000..bfa6365 --- /dev/null +++ b/src/main/java/org/cryptomator/integrations/tray/TrayIconLoader.java @@ -0,0 +1,27 @@ +package org.cryptomator.integrations.tray; + +/** + * A callback used by the {@link TrayMenuController} to load tray icons in the format required by the implementation. + */ +sealed public interface TrayIconLoader permits TrayIconLoader.PngData, TrayIconLoader.FreedesktopIconName { + + non-sealed interface PngData extends TrayIconLoader { + + /** + * Loads an icon from a byte array holding a loaded PNG file. + * + * @param data png data + */ + void loadPng(byte[] data); + } + + non-sealed interface FreedesktopIconName extends TrayIconLoader { + + /** + * Loads an icon by looking it up {@code iconName} inside of {@code $XDG_DATA_DIRS/icons}. + * + * @param iconName the icon name + */ + void lookupByName(String iconName); + } +} diff --git a/src/main/java/org/cryptomator/integrations/tray/TrayMenuController.java b/src/main/java/org/cryptomator/integrations/tray/TrayMenuController.java index 5cdd413..a1af384 100644 --- a/src/main/java/org/cryptomator/integrations/tray/TrayMenuController.java +++ b/src/main/java/org/cryptomator/integrations/tray/TrayMenuController.java @@ -3,9 +3,9 @@ import org.cryptomator.integrations.common.IntegrationsLoader; import org.jetbrains.annotations.ApiStatus; -import java.net.URI; import java.util.List; import java.util.Optional; +import java.util.function.Consumer; /** * Displays a tray icon and menu @@ -22,20 +22,20 @@ static Optional get() { /** * Displays an icon on the system tray. * - * @param imageUri What image to show + * @param iconLoader A callback responsible for retrieving the icon in the required format * @param defaultAction Action to perform when interacting with the icon directly instead of its menu * @param tooltip Text shown when hovering * @throws TrayMenuException thrown when adding the tray icon failed */ - void showTrayIcon(URI imageUri, Runnable defaultAction, String tooltip) throws TrayMenuException; + void showTrayIcon(Consumer iconLoader, Runnable defaultAction, String tooltip) throws TrayMenuException; /** * Updates the icon on the system tray. * - * @param imageUri What image to show + * @param iconLoader A callback responsible for retrieving the icon in the required format * @throws IllegalStateException thrown when called before an icon has been added */ - void updateTrayIcon(URI imageUri); + void updateTrayIcon(Consumer iconLoader); /** * Show the given options in the tray menu. From 9daf5f6b4f52860fc1c7ad1de0170564b89b2f1e Mon Sep 17 00:00:00 2001 From: Sebastian Stenzel Date: Sun, 7 May 2023 20:54:10 +0200 Subject: [PATCH 6/9] mark api as still being subject to change --- .../org/cryptomator/integrations/tray/TrayIconLoader.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/org/cryptomator/integrations/tray/TrayIconLoader.java b/src/main/java/org/cryptomator/integrations/tray/TrayIconLoader.java index bfa6365..8a48b47 100644 --- a/src/main/java/org/cryptomator/integrations/tray/TrayIconLoader.java +++ b/src/main/java/org/cryptomator/integrations/tray/TrayIconLoader.java @@ -1,10 +1,14 @@ package org.cryptomator.integrations.tray; +import org.jetbrains.annotations.ApiStatus; + /** * A callback used by the {@link TrayMenuController} to load tray icons in the format required by the implementation. */ +@ApiStatus.Experimental sealed public interface TrayIconLoader permits TrayIconLoader.PngData, TrayIconLoader.FreedesktopIconName { + @FunctionalInterface non-sealed interface PngData extends TrayIconLoader { /** @@ -15,6 +19,7 @@ non-sealed interface PngData extends TrayIconLoader { void loadPng(byte[] data); } + @FunctionalInterface non-sealed interface FreedesktopIconName extends TrayIconLoader { /** From 948faeab9828389b489974a8864ac893bdb53548 Mon Sep 17 00:00:00 2001 From: Sebastian Stenzel Date: Sun, 7 May 2023 20:57:34 +0200 Subject: [PATCH 7/9] updated .idea config for IDEA 2023.1+ [ci skip] --- .idea/misc.xml | 1 + .idea/modules.xml | 8 -------- 2 files changed, 1 insertion(+), 8 deletions(-) delete mode 100644 .idea/modules.xml diff --git a/.idea/misc.xml b/.idea/misc.xml index 482738c..a8fc129 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,5 +1,6 @@ +