File tree Expand file tree Collapse file tree
src/main/java/org/cryptomator/integrations/tray Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package org .cryptomator .integrations .tray ;
2+
3+ import org .jetbrains .annotations .ApiStatus ;
4+
5+ /**
6+ * A callback used by the {@link TrayMenuController} to load tray icons in the format required by the implementation.
7+ */
8+ @ ApiStatus .Experimental
9+ sealed public interface TrayIconLoader permits TrayIconLoader .PngData , TrayIconLoader .FreedesktopIconName {
10+
11+ @ FunctionalInterface
12+ non-sealed interface PngData extends TrayIconLoader {
13+
14+ /**
15+ * Loads an icon from a byte array holding a loaded PNG file.
16+ *
17+ * @param data png data
18+ */
19+ void loadPng (byte [] data );
20+ }
21+
22+ @ FunctionalInterface
23+ non-sealed interface FreedesktopIconName extends TrayIconLoader {
24+
25+ /**
26+ * Loads an icon by looking it up {@code iconName} inside of {@code $XDG_DATA_DIRS/icons}.
27+ *
28+ * @param iconName the icon name
29+ */
30+ void lookupByName (String iconName );
31+ }
32+ }
Original file line number Diff line number Diff line change 33import org .cryptomator .integrations .common .IntegrationsLoader ;
44import org .jetbrains .annotations .ApiStatus ;
55
6- import java .net .URI ;
76import java .util .List ;
87import java .util .Optional ;
8+ import java .util .function .Consumer ;
99
1010/**
1111 * Displays a tray icon and menu
@@ -22,20 +22,20 @@ static Optional<TrayMenuController> get() {
2222 /**
2323 * Displays an icon on the system tray.
2424 *
25- * @param imageUri What image to show
25+ * @param iconLoader A callback responsible for retrieving the icon in the required format
2626 * @param defaultAction Action to perform when interacting with the icon directly instead of its menu
2727 * @param tooltip Text shown when hovering
2828 * @throws TrayMenuException thrown when adding the tray icon failed
2929 */
30- void showTrayIcon (URI imageUri , Runnable defaultAction , String tooltip ) throws TrayMenuException ;
30+ void showTrayIcon (Consumer < TrayIconLoader > iconLoader , Runnable defaultAction , String tooltip ) throws TrayMenuException ;
3131
3232 /**
3333 * Updates the icon on the system tray.
3434 *
35- * @param imageUri What image to show
35+ * @param iconLoader A callback responsible for retrieving the icon in the required format
3636 * @throws IllegalStateException thrown when called before an icon has been added
3737 */
38- void updateTrayIcon (URI imageUri );
38+ void updateTrayIcon (Consumer < TrayIconLoader > iconLoader );
3939
4040 /**
4141 * Show the given options in the tray menu.
You can’t perform that action at this time.
0 commit comments