diff --git a/main/commons/src/main/java/org/cryptomator/common/settings/Settings.java b/main/commons/src/main/java/org/cryptomator/common/settings/Settings.java index 863e359e2..16d16b01d 100644 --- a/main/commons/src/main/java/org/cryptomator/common/settings/Settings.java +++ b/main/commons/src/main/java/org/cryptomator/common/settings/Settings.java @@ -69,6 +69,7 @@ public class Settings { preferredVolumeImpl.addListener(this::somethingChanged); theme.addListener(this::somethingChanged); userInterfaceOrientation.addListener(this::somethingChanged); + licenseKey.addListener(this::somethingChanged); } void setSaveCmd(Consumer saveCmd) { diff --git a/main/commons/src/main/java/org/cryptomator/common/settings/SettingsJsonAdapter.java b/main/commons/src/main/java/org/cryptomator/common/settings/SettingsJsonAdapter.java index 874994cf8..33afb7306 100644 --- a/main/commons/src/main/java/org/cryptomator/common/settings/SettingsJsonAdapter.java +++ b/main/commons/src/main/java/org/cryptomator/common/settings/SettingsJsonAdapter.java @@ -38,6 +38,7 @@ public class SettingsJsonAdapter extends TypeAdapter { out.name("preferredVolumeImpl").value(value.preferredVolumeImpl().get().name()); out.name("theme").value(value.theme().get().name()); out.name("uiOrientation").value(value.userInterfaceOrientation().get().name()); + out.name("licenseKey").value(value.licenseKey().get()); out.endObject(); } @@ -90,6 +91,9 @@ public class SettingsJsonAdapter extends TypeAdapter { case "uiOrientation": settings.userInterfaceOrientation().set(parseUiOrientation(in.nextString())); break; + case "licenseKey": + settings.licenseKey().set(in.nextString()); + break; default: LOG.warn("Unsupported vault setting found in JSON: " + name); in.skipValue(); diff --git a/main/ui/src/main/java/org/cryptomator/ui/controls/FontAwesome5Icon.java b/main/ui/src/main/java/org/cryptomator/ui/controls/FontAwesome5Icon.java index 41f8b80e2..7a22d1ced 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/controls/FontAwesome5Icon.java +++ b/main/ui/src/main/java/org/cryptomator/ui/controls/FontAwesome5Icon.java @@ -15,9 +15,11 @@ public enum FontAwesome5Icon { EYE_SLASH("\uF070"), // FILE_IMPORT("\uF56F"), // FOLDER_OPEN("\uF07C"), // + HAND_HOLDING_HEART("\uF4BE"), // HEART("\uF004"), // HDD("\uF0A0"), // KEY("\uF084"), // + LINK("\uF0C1"), // LOCK_ALT("\uF30D"), // LOCK_OPEN_ALT("\uF3C2"), // PLUS("\uF067"), // @@ -26,7 +28,7 @@ public enum FontAwesome5Icon { SPINNER("\uF110"), // SYNC("\uF021"), // TIMES("\uF00D"), // - USER_CHECK("\uf4fc"), // + USER_CROWN("\uF6A4"), // WRENCH("\uF0AD"), // ; diff --git a/main/ui/src/main/java/org/cryptomator/ui/fxapp/FxApplicationModule.java b/main/ui/src/main/java/org/cryptomator/ui/fxapp/FxApplicationModule.java index 43fa9e749..a51470489 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/fxapp/FxApplicationModule.java +++ b/main/ui/src/main/java/org/cryptomator/ui/fxapp/FxApplicationModule.java @@ -5,8 +5,10 @@ *******************************************************************************/ package org.cryptomator.ui.fxapp; +import dagger.Binds; import dagger.Module; import dagger.Provides; +import javafx.application.Application; import javafx.beans.property.ObjectProperty; import javafx.beans.property.SimpleObjectProperty; import javafx.scene.image.Image; @@ -44,6 +46,9 @@ abstract class FxApplicationModule { return Optional.empty(); } } + + @Binds + abstract Application bindApplication(FxApplication application); @Provides static MainWindowComponent provideMainWindowComponent(MainWindowComponent.Builder builder) { diff --git a/main/ui/src/main/java/org/cryptomator/ui/preferences/RegistrationPreferencesController.java b/main/ui/src/main/java/org/cryptomator/ui/preferences/LicenseKeyPreferencesController.java similarity index 67% rename from main/ui/src/main/java/org/cryptomator/ui/preferences/RegistrationPreferencesController.java rename to main/ui/src/main/java/org/cryptomator/ui/preferences/LicenseKeyPreferencesController.java index 64de38d63..33c613ce4 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/preferences/RegistrationPreferencesController.java +++ b/main/ui/src/main/java/org/cryptomator/ui/preferences/LicenseKeyPreferencesController.java @@ -1,6 +1,7 @@ package org.cryptomator.ui.preferences; import com.auth0.jwt.interfaces.DecodedJWT; +import javafx.application.Application; import javafx.beans.binding.Bindings; import javafx.beans.binding.BooleanBinding; import javafx.beans.binding.StringBinding; @@ -17,22 +18,26 @@ import javax.inject.Inject; import java.util.Optional; @PreferencesScoped -public class RegistrationPreferencesController implements FxController { +public class LicenseKeyPreferencesController implements FxController { + + private static final String DONATION_URI = "https://cryptomator.org/#donate"; private final Settings settings; + private final Application application; private final LicenseChecker licenseChecker; private final ObjectProperty validJwtClaims; private final StringBinding licenseSubject; - private final BooleanBinding registeredProperty; - public TextArea registrationKeyField; + private final BooleanBinding validLicenseProperty; + public TextArea donationKeyField; @Inject - RegistrationPreferencesController(Settings settings, LicenseChecker licenseChecker) { + LicenseKeyPreferencesController(Settings settings, Application application, LicenseChecker licenseChecker) { this.settings = settings; + this.application = application; this.licenseChecker = licenseChecker; this.validJwtClaims = new SimpleObjectProperty<>(); this.licenseSubject = Bindings.createStringBinding(this::getLicenseSubject, validJwtClaims); - this.registeredProperty = validJwtClaims.isNotNull(); + this.validLicenseProperty = validJwtClaims.isNotNull(); Optional claims = licenseChecker.check(settings.licenseKey().get()); validJwtClaims.set(claims.orElse(null)); @@ -40,7 +45,8 @@ public class RegistrationPreferencesController implements FxController { @FXML public void initialize() { - registrationKeyField.textProperty().addListener(this::registrationKeyChanged); + donationKeyField.setText(settings.licenseKey().get()); + donationKeyField.textProperty().addListener(this::registrationKeyChanged); } private void registrationKeyChanged(@SuppressWarnings("unused") ObservableValue observable, @SuppressWarnings("unused") String oldValue, String newValue) { @@ -51,12 +57,17 @@ public class RegistrationPreferencesController implements FxController { } } + @FXML + public void getDonationKey() { + application.getHostServices().showDocument(DONATION_URI); + } + /* Observable Properties */ - + public StringBinding licenseSubjectProperty() { return licenseSubject; } - + public String getLicenseSubject() { DecodedJWT claims = validJwtClaims.get(); if (claims != null) { @@ -66,12 +77,11 @@ public class RegistrationPreferencesController implements FxController { } } - public BooleanBinding registeredProperty() { - return registeredProperty; + public BooleanBinding validLicenseProperty() { + return validLicenseProperty; } - public boolean isRegistered() { - return registeredProperty.get(); + public boolean isValidLicense() { + return validLicenseProperty.get(); } - } diff --git a/main/ui/src/main/java/org/cryptomator/ui/preferences/PreferencesModule.java b/main/ui/src/main/java/org/cryptomator/ui/preferences/PreferencesModule.java index 793617352..5f8852df9 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/preferences/PreferencesModule.java +++ b/main/ui/src/main/java/org/cryptomator/ui/preferences/PreferencesModule.java @@ -72,7 +72,7 @@ abstract class PreferencesModule { @Binds @IntoMap - @FxControllerKey(RegistrationPreferencesController.class) - abstract FxController bindRegistrationPreferencesController(RegistrationPreferencesController controller); + @FxControllerKey(LicenseKeyPreferencesController.class) + abstract FxController bindLicenseKeyPreferencesController(LicenseKeyPreferencesController controller); } diff --git a/main/ui/src/main/resources/fxml/preferences.fxml b/main/ui/src/main/resources/fxml/preferences.fxml index 4a5363883..15b844c60 100644 --- a/main/ui/src/main/resources/fxml/preferences.fxml +++ b/main/ui/src/main/resources/fxml/preferences.fxml @@ -7,7 +7,9 @@ xmlns:fx="http://javafx.com/fxml" fx:id="tabPane" fx:controller="org.cryptomator.ui.preferences.PreferencesController" - minWidth="400" + minWidth="-Infinity" + maxWidth="-Infinity" + prefWidth="500" tabClosingPolicy="UNAVAILABLE" tabDragPolicy="FIXED"> @@ -35,12 +37,12 @@ - + - + - + diff --git a/main/ui/src/main/resources/fxml/preferences_donationkey.fxml b/main/ui/src/main/resources/fxml/preferences_donationkey.fxml new file mode 100644 index 000000000..bbe073a70 --- /dev/null +++ b/main/ui/src/main/resources/fxml/preferences_donationkey.fxml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +