Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import org.cryptomator.integrations.tray.TrayMenuController;
import org.cryptomator.integrations.autostart.AutoStartProvider;
import org.cryptomator.integrations.keychain.KeychainAccessProvider;
import org.cryptomator.integrations.tray.TrayIntegrationProvider;
import org.cryptomator.integrations.uiappearance.UiAppearanceProvider;


module org.cryptomator.integrations.api {
exports org.cryptomator.integrations.autostart;
exports org.cryptomator.integrations.keychain;
Expand All @@ -12,5 +14,6 @@
uses AutoStartProvider;
uses KeychainAccessProvider;
uses TrayIntegrationProvider;
uses TrayMenuController;
uses UiAppearanceProvider;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package org.cryptomator.integrations.tray;

public record ActionItem(String title, Runnable action) implements TrayMenuItem {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package org.cryptomator.integrations.tray;

public record SeparatorItem() implements TrayMenuItem {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.cryptomator.integrations.tray;

import java.util.List;

public record SubMenuItem(String title, List<TrayMenuItem> items) implements TrayMenuItem {
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,17 @@

import java.util.Optional;

/**
* Allows to perform OS-specific tasks when the app gets minimized to or restored from a tray icon.
*/
public interface TrayIntegrationProvider {

/**
* Loads the best-suited TrayIntegrationProvider.
*
* @return preferred TrayIntegrationProvider (if any)
* @since 1.1.0
*/
static Optional<TrayIntegrationProvider> get() {
return IntegrationsLoader.load(TrayIntegrationProvider.class);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package org.cryptomator.integrations.tray;

import org.cryptomator.integrations.common.IntegrationsLoader;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Optional;

/**
* Displays a tray icon and menu
*
* @since 1.1.0
*/
public interface TrayMenuController {

static Optional<TrayMenuController> get() {
return IntegrationsLoader.load(TrayMenuController.class);
}

/**
* Displays an icon on the system tray.
*
* @param rawImageData 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 <code>rawImageData</code>
*/
void showTrayIcon(InputStream rawImageData, Runnable defaultAction, String tooltip) throws IOException;

/**
* Show the given options in the tray menu.
* <p>
* This method may be called multiple times, e.g. when the vault list changes.
*
* @param items Menu items
*/
void updateTrayMenu(List<TrayMenuItem> items);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package org.cryptomator.integrations.tray;

public sealed interface TrayMenuItem permits ActionItem, SubMenuItem, SeparatorItem {
}