From 85e773abef48d135a07e896fb1e239299855b8fc Mon Sep 17 00:00:00 2001 From: Sebastian Stenzel Date: Thu, 9 Jan 2020 16:34:31 +0100 Subject: [PATCH] enable themes for donators --- .../java/org/cryptomator/ui/fxapp/FxApplication.java | 8 ++++++-- .../ui/preferences/GeneralPreferencesController.java | 9 ++++++++- main/ui/src/main/resources/fxml/preferences_general.fxml | 2 +- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/main/ui/src/main/java/org/cryptomator/ui/fxapp/FxApplication.java b/main/ui/src/main/java/org/cryptomator/ui/fxapp/FxApplication.java index bae199170..aca5650ea 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/fxapp/FxApplication.java +++ b/main/ui/src/main/java/org/cryptomator/ui/fxapp/FxApplication.java @@ -9,6 +9,7 @@ import javafx.beans.value.ObservableValue; import javafx.collections.FXCollections; import javafx.collections.ObservableSet; import javafx.stage.Stage; +import org.cryptomator.common.LicenseHolder; import org.cryptomator.common.settings.Settings; import org.cryptomator.common.settings.UiTheme; import org.cryptomator.common.vaults.Vault; @@ -41,11 +42,12 @@ public class FxApplication extends Application { private final QuitComponent.Builder quitWindowBuilder; private final Optional macFunctions; private final VaultService vaultService; + private final LicenseHolder licenseHolder; private final ObservableSet visibleStages = FXCollections.observableSet(); private final BooleanBinding hasVisibleStages = Bindings.isNotEmpty(visibleStages); @Inject - FxApplication(Settings settings, Lazy mainWindow, Lazy preferencesWindow, UnlockComponent.Builder unlockWindowBuilder, QuitComponent.Builder quitWindowBuilder, Optional macFunctions, VaultService vaultService) { + FxApplication(Settings settings, Lazy mainWindow, Lazy preferencesWindow, UnlockComponent.Builder unlockWindowBuilder, QuitComponent.Builder quitWindowBuilder, Optional macFunctions, VaultService vaultService, LicenseHolder licenseHolder) { this.settings = settings; this.mainWindow = mainWindow; this.preferencesWindow = preferencesWindow; @@ -53,6 +55,7 @@ public class FxApplication extends Application { this.quitWindowBuilder = quitWindowBuilder; this.macFunctions = macFunctions; this.vaultService = vaultService; + this.licenseHolder = licenseHolder; } public void start() { @@ -123,7 +126,8 @@ public class FxApplication extends Application { loadSelectedStyleSheet(newValue); } - private void loadSelectedStyleSheet(UiTheme theme) { + private void loadSelectedStyleSheet(UiTheme desiredTheme) { + UiTheme theme = licenseHolder.isValidLicense() ? desiredTheme : UiTheme.LIGHT; switch (theme) { // case CUSTOM: // // TODO diff --git a/main/ui/src/main/java/org/cryptomator/ui/preferences/GeneralPreferencesController.java b/main/ui/src/main/java/org/cryptomator/ui/preferences/GeneralPreferencesController.java index 61c37e4ab..ae18dbd3f 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/preferences/GeneralPreferencesController.java +++ b/main/ui/src/main/java/org/cryptomator/ui/preferences/GeneralPreferencesController.java @@ -11,6 +11,7 @@ import javafx.scene.control.RadioButton; import javafx.scene.control.Toggle; import javafx.scene.control.ToggleGroup; import javafx.util.StringConverter; +import org.cryptomator.common.LicenseHolder; import org.cryptomator.common.settings.Settings; import org.cryptomator.common.settings.UiTheme; import org.cryptomator.ui.common.FxController; @@ -30,6 +31,7 @@ public class GeneralPreferencesController implements FxController { private final Settings settings; private final boolean trayMenuSupported; private final Optional autoStartStrategy; + private final LicenseHolder licenseHolder; private final ExecutorService executor; public ChoiceBox themeChoiceBox; public CheckBox startHiddenCheckbox; @@ -40,10 +42,11 @@ public class GeneralPreferencesController implements FxController { public RadioButton nodeOrientationRtl; @Inject - GeneralPreferencesController(Settings settings, @Named("trayMenuSupported") boolean trayMenuSupported, Optional autoStartStrategy, ExecutorService executor) { + GeneralPreferencesController(Settings settings, @Named("trayMenuSupported") boolean trayMenuSupported, Optional autoStartStrategy, LicenseHolder licenseHolder, ExecutorService executor) { this.settings = settings; this.trayMenuSupported = trayMenuSupported; this.autoStartStrategy = autoStartStrategy; + this.licenseHolder = licenseHolder; this.executor = executor; } @@ -96,6 +99,10 @@ public class GeneralPreferencesController implements FxController { }); } + public LicenseHolder getLicenseHolder() { + return licenseHolder; + } + /* Helper classes */ private static class UiThemeConverter extends StringConverter { diff --git a/main/ui/src/main/resources/fxml/preferences_general.fxml b/main/ui/src/main/resources/fxml/preferences_general.fxml index 4688d7f6e..97d7e544c 100644 --- a/main/ui/src/main/resources/fxml/preferences_general.fxml +++ b/main/ui/src/main/resources/fxml/preferences_general.fxml @@ -21,7 +21,7 @@