From 3429044258a5893c0bbbd54525e2a592576f29e5 Mon Sep 17 00:00:00 2001 From: Armin Schrenk Date: Tue, 25 Nov 2025 23:52:39 +0100 Subject: [PATCH 1/2] first draft of notification api --- src/main/java/module-info.java | 3 ++ .../integrations/notify/NotifyService.java | 52 +++++++++++++++++++ .../notify/NotifyServiceException.java | 4 ++ 3 files changed, 59 insertions(+) create mode 100644 src/main/java/org/cryptomator/integrations/notify/NotifyService.java create mode 100644 src/main/java/org/cryptomator/integrations/notify/NotifyServiceException.java diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java index f6c292f..53f412e 100644 --- a/src/main/java/module-info.java +++ b/src/main/java/module-info.java @@ -1,3 +1,4 @@ +import org.cryptomator.integrations.notify.NotifyService; import org.cryptomator.integrations.quickaccess.QuickAccessService; import org.cryptomator.integrations.mount.MountService; import org.cryptomator.integrations.revealpath.RevealPathService; @@ -19,6 +20,7 @@ exports org.cryptomator.integrations.common; exports org.cryptomator.integrations.keychain; exports org.cryptomator.integrations.mount; + exports org.cryptomator.integrations.notify; exports org.cryptomator.integrations.revealpath; exports org.cryptomator.integrations.tray; exports org.cryptomator.integrations.uiappearance; @@ -28,6 +30,7 @@ uses AutoStartProvider; uses KeychainAccessProvider; uses MountService; + uses NotifyService; uses RevealPathService; uses TrayIntegrationProvider; uses TrayMenuController; diff --git a/src/main/java/org/cryptomator/integrations/notify/NotifyService.java b/src/main/java/org/cryptomator/integrations/notify/NotifyService.java new file mode 100644 index 0000000..fe0c835 --- /dev/null +++ b/src/main/java/org/cryptomator/integrations/notify/NotifyService.java @@ -0,0 +1,52 @@ +package org.cryptomator.integrations.notify; + +import org.cryptomator.integrations.common.IntegrationsLoader; +import org.cryptomator.integrations.common.NamedServiceProvider; + +import java.util.stream.Stream; + +/** + * Service for sending a notification to the user. + */ +@FunctionalInterface +public interface NotifyService extends NamedServiceProvider { + + /** + * Sends a notification to the user. + *

+ * A (toast) notification is a message displayed to the user, informing them about an event. + * In general, a notification has the following elements: + *

+ * + * @param header Header of the notification + * @param description Description of the notification + * @param actions Zero or more {@link Action}s the user can trigger/interact in the notification + * @throws NotifyServiceException if an error on displaying the notificaiton occurs + */ + void sendNotification(String header, String description, Action... actions) throws NotifyServiceException; + + /** + * Record representing possible actions for a notification. + *

+ * Performing the actions should invoke the callback. + * + * @param actionDescription short description what the action does + * @param actionCallback execution of the action + */ + record Action(String actionDescription, Runnable actionCallback) { + } + + + /** + * Loads all supported service providers. + * + * @return Stream of supported {@link NotifyService} implementations (may be empty) + */ + static Stream loadAll() { + return IntegrationsLoader.loadAll(NotifyService.class); + } +} diff --git a/src/main/java/org/cryptomator/integrations/notify/NotifyServiceException.java b/src/main/java/org/cryptomator/integrations/notify/NotifyServiceException.java new file mode 100644 index 0000000..cbe762b --- /dev/null +++ b/src/main/java/org/cryptomator/integrations/notify/NotifyServiceException.java @@ -0,0 +1,4 @@ +package org.cryptomator.integrations.notify; + +public class NotifyServiceException extends Exception { +} From 0b0990308caed8fe6325bb287b39c30a8ecc42fc Mon Sep 17 00:00:00 2001 From: Armin Schrenk Date: Fri, 28 Nov 2025 14:33:03 +0100 Subject: [PATCH 2/2] [skip ci] impl draft --- .../integrations/notify/NotifyService.java | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/cryptomator/integrations/notify/NotifyService.java b/src/main/java/org/cryptomator/integrations/notify/NotifyService.java index fe0c835..3be4bc5 100644 --- a/src/main/java/org/cryptomator/integrations/notify/NotifyService.java +++ b/src/main/java/org/cryptomator/integrations/notify/NotifyService.java @@ -1,15 +1,10 @@ package org.cryptomator.integrations.notify; import org.cryptomator.integrations.common.IntegrationsLoader; -import org.cryptomator.integrations.common.NamedServiceProvider; import java.util.stream.Stream; -/** - * Service for sending a notification to the user. - */ -@FunctionalInterface -public interface NotifyService extends NamedServiceProvider { +public interface NotifyService { /** * Sends a notification to the user. @@ -24,20 +19,20 @@ public interface NotifyService extends NamedServiceProvider { * * @param header Header of the notification * @param description Description of the notification - * @param actions Zero or more {@link Action}s the user can trigger/interact in the notification + * @param actions Zero or more {@link NotifyService.Action}s the user can trigger/interact in the notification * @throws NotifyServiceException if an error on displaying the notificaiton occurs */ - void sendNotification(String header, String description, Action... actions) throws NotifyServiceException; + void sendNotification(String header, String description, NotifyService.Action... actions) throws NotifyServiceException; /** * Record representing possible actions for a notification. *

* Performing the actions should invoke the callback. * - * @param actionDescription short description what the action does - * @param actionCallback execution of the action + * @param label _short_ description of the action + * @param returnMessage message sent on action execution */ - record Action(String actionDescription, Runnable actionCallback) { + record Action(String label, String returnMessage) { }