Skip to content

Commit d0176dd

Browse files
adjusted UI Appearance API
1 parent c5eac63 commit d0176dd

2 files changed

Lines changed: 39 additions & 3 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package org.cryptomator.integrations.uiappearance;
2+
3+
@FunctionalInterface
4+
public interface UiAppearanceListener {
5+
6+
void systemAppearanceChanged(Theme newTheme);
7+
8+
}

src/main/java/org/cryptomator/integrations/uiappearance/UiAppearanceProvider.java

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,37 @@
55
*/
66
public interface UiAppearanceProvider {
77

8-
Theme getCurrentTheme() throws UiAppearanceException;
8+
/**
9+
* Gets the best-matching theme for the OS's current L&F. This might be an approximation, as the OS might support more variations than we do.
10+
*
11+
* @implSpec Should default to {@link Theme#LIGHT} if the OS theme can't be determined, should not throw exceptions.
12+
* @return The current OS theme
13+
*/
14+
Theme getSystemTheme();
915

10-
void addListener() throws UiAppearanceException;
11-
void removeListener() throws UiAppearanceProvider;
16+
/**
17+
* Adjusts parts of the UI to the desired theme, that can not be directly controlled from within Java.
18+
* This might be required for window decorations or tray icons. Can be no-op.
19+
*
20+
* @implSpec A best-effort attempt should be made. If adjustments fail, do not throw an exception.
21+
* @param theme What theme to adjust to
22+
*/
23+
void adjustToTheme(Theme theme);
24+
25+
/**
26+
* Registers a listener that gets notified when the system theme changes.
27+
*
28+
* @param listener The listener
29+
* @throws UiAppearanceException If registering the listener failed.
30+
*/
31+
void addListener(UiAppearanceListener listener) throws UiAppearanceException;
32+
33+
/**
34+
* Removes a previously registered listener.
35+
*
36+
* @param listener The listener
37+
* @throws UiAppearanceException If removing the listener failed.
38+
*/
39+
void removeListener(UiAppearanceListener listener) throws UiAppearanceException;
1240

1341
}

0 commit comments

Comments
 (0)