Apply suggestions from code review

Co-authored-by: Sebastian Stenzel <overheadhunter@users.noreply.github.com>
This commit is contained in:
Armin Schrenk
2026-02-16 16:05:26 +01:00
committed by GitHub
parent 9e6bd913cb
commit f753ddc9be
2 changed files with 6 additions and 7 deletions

View File

@@ -45,12 +45,12 @@ public class FxApplicationStyle {
}
private void appThemeChanged(@SuppressWarnings("unused") ObservableValue<? extends UiTheme> 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();

View File

@@ -26,7 +26,6 @@ public class JfxUiAppearanceProvider implements UiAppearanceProvider {
private final ConcurrentHashMap<UiAppearanceListener, ChangeListener<ColorScheme>> 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()) {