From f753ddc9bee6adcd72d270a3cf741b3c830b3f34 Mon Sep 17 00:00:00 2001 From: Armin Schrenk Date: Mon, 16 Feb 2026 16:05:26 +0100 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Sebastian Stenzel --- .../org/cryptomator/ui/fxapp/FxApplicationStyle.java | 12 ++++++------ .../ui/fxapp/JfxUiAppearanceProvider.java | 1 - 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/cryptomator/ui/fxapp/FxApplicationStyle.java b/src/main/java/org/cryptomator/ui/fxapp/FxApplicationStyle.java index ccda4a3f8..bfdb22196 100644 --- a/src/main/java/org/cryptomator/ui/fxapp/FxApplicationStyle.java +++ b/src/main/java/org/cryptomator/ui/fxapp/FxApplicationStyle.java @@ -45,12 +45,12 @@ public class FxApplicationStyle { } private void appThemeChanged(@SuppressWarnings("unused") ObservableValue observable, UiTheme oldValue, UiTheme newValue) { - if (oldValue == UiTheme.AUTOMATIC && newValue != UiTheme.AUTOMATIC) { - removeOsThemeListener(); - } - - if (newValue == UiTheme.AUTOMATIC) { + if (oldValue == newValue) { + // no-op + } else if (newValue == UiTheme.AUTOMATIC) { registerOsThemeListener(); + } else if (oldValue == UiTheme.AUTOMATIC) { + removeOsThemeListener(); } applyTheme(newValue); @@ -86,7 +86,7 @@ public class FxApplicationStyle { } else { switch (uiTheme) { case AUTOMATIC -> { - var osTheme = appearanceProvider.isPresent() ? appearanceProvider.get().getSystemTheme() : Theme.LIGHT; + var osTheme = appearanceProvider.map(UiAppearanceProvider::getSystemTheme).orElse(Theme.LIGHT); systemInterfaceThemeChanged(osTheme); } case LIGHT -> loadAndApplyLightTheme(); diff --git a/src/main/java/org/cryptomator/ui/fxapp/JfxUiAppearanceProvider.java b/src/main/java/org/cryptomator/ui/fxapp/JfxUiAppearanceProvider.java index ffe7093a2..56562fc9c 100644 --- a/src/main/java/org/cryptomator/ui/fxapp/JfxUiAppearanceProvider.java +++ b/src/main/java/org/cryptomator/ui/fxapp/JfxUiAppearanceProvider.java @@ -26,7 +26,6 @@ public class JfxUiAppearanceProvider implements UiAppearanceProvider { private final ConcurrentHashMap> uiAppearanceListeners = new ConcurrentHashMap<>(); private final Platform.Preferences preferences = Platform.getPreferences(); //Note: this service impl MUST be loaded in the fx application thread - @Override public Theme getSystemTheme() { return switch (preferences.getColorScheme()) {