-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from cryptomator/feature/tray-menu
Add Tray Menu API
- Loading branch information
Showing
7 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
src/main/java/org/cryptomator/integrations/tray/ActionItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { | ||
} |
4 changes: 4 additions & 0 deletions
4
src/main/java/org/cryptomator/integrations/tray/SeparatorItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package org.cryptomator.integrations.tray; | ||
|
||
public record SeparatorItem() implements TrayMenuItem { | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/java/org/cryptomator/integrations/tray/SubMenuItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/main/java/org/cryptomator/integrations/tray/TrayMenuController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
|
||
} |
4 changes: 4 additions & 0 deletions
4
src/main/java/org/cryptomator/integrations/tray/TrayMenuItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { | ||
} |