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..3be4bc5 --- /dev/null +++ b/src/main/java/org/cryptomator/integrations/notify/NotifyService.java @@ -0,0 +1,47 @@ +package org.cryptomator.integrations.notify; + +import org.cryptomator.integrations.common.IntegrationsLoader; + +import java.util.stream.Stream; + +public interface NotifyService { + + /** + * 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 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, NotifyService.Action... actions) throws NotifyServiceException; + + /** + * Record representing possible actions for a notification. + *

+ * Performing the actions should invoke the callback. + * + * @param label _short_ description of the action + * @param returnMessage message sent on action execution + */ + record Action(String label, String returnMessage) { + } + + + /** + * 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 { +}