|
@@ -10,24 +10,36 @@ import javax.inject.Inject;
|
|
import javafx.application.Application;
|
|
import javafx.application.Application;
|
|
import javafx.beans.value.ObservableValue;
|
|
import javafx.beans.value.ObservableValue;
|
|
import javafx.fxml.FXML;
|
|
import javafx.fxml.FXML;
|
|
|
|
+import javafx.scene.control.Alert;
|
|
|
|
+import javafx.scene.control.Button;
|
|
|
|
+import javafx.scene.control.ButtonType;
|
|
import javafx.scene.control.TextArea;
|
|
import javafx.scene.control.TextArea;
|
|
import javafx.scene.control.TextFormatter;
|
|
import javafx.scene.control.TextFormatter;
|
|
|
|
+import java.util.ResourceBundle;
|
|
|
|
|
|
@PreferencesScoped
|
|
@PreferencesScoped
|
|
public class SupporterCertificateController implements FxController {
|
|
public class SupporterCertificateController implements FxController {
|
|
|
|
|
|
|
|
+ private static final String DONATE_URI = "https://cryptomator.org/donate";
|
|
|
|
+ private static final String SPONSORS_URI = "https://cryptomator.org/sponsors";
|
|
private static final String SUPPORTER_URI = "https://store.cryptomator.org/desktop";
|
|
private static final String SUPPORTER_URI = "https://store.cryptomator.org/desktop";
|
|
|
|
|
|
private final Application application;
|
|
private final Application application;
|
|
private final LicenseHolder licenseHolder;
|
|
private final LicenseHolder licenseHolder;
|
|
private final Settings settings;
|
|
private final Settings settings;
|
|
- public TextArea supporterCertificateField;
|
|
|
|
|
|
+ private final ResourceBundle resourceBundle;
|
|
|
|
+
|
|
|
|
+ @FXML
|
|
|
|
+ private TextArea supporterCertificateField;
|
|
|
|
+ @FXML
|
|
|
|
+ private Button trashButton;
|
|
|
|
|
|
@Inject
|
|
@Inject
|
|
- SupporterCertificateController(Application application, LicenseHolder licenseHolder, Settings settings) {
|
|
|
|
|
|
+ SupporterCertificateController(Application application, LicenseHolder licenseHolder, Settings settings, ResourceBundle resourceBundle) {
|
|
this.application = application;
|
|
this.application = application;
|
|
this.licenseHolder = licenseHolder;
|
|
this.licenseHolder = licenseHolder;
|
|
this.settings = settings;
|
|
this.settings = settings;
|
|
|
|
+ this.resourceBundle = resourceBundle;
|
|
}
|
|
}
|
|
|
|
|
|
@FXML
|
|
@FXML
|
|
@@ -35,6 +47,20 @@ public class SupporterCertificateController implements FxController {
|
|
supporterCertificateField.setText(licenseHolder.getLicenseKey().orElse(null));
|
|
supporterCertificateField.setText(licenseHolder.getLicenseKey().orElse(null));
|
|
supporterCertificateField.textProperty().addListener(this::registrationKeyChanged);
|
|
supporterCertificateField.textProperty().addListener(this::registrationKeyChanged);
|
|
supporterCertificateField.setTextFormatter(new TextFormatter<>(this::removeWhitespaces));
|
|
supporterCertificateField.setTextFormatter(new TextFormatter<>(this::removeWhitespaces));
|
|
|
|
+
|
|
|
|
+ trashButton.setOnAction(_ -> {
|
|
|
|
+ Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
|
|
|
|
+ alert.setTitle(resourceBundle.getString("removeLicenseKeyDialog.title"));
|
|
|
|
+ alert.setHeaderText(resourceBundle.getString("removeLicenseKeyDialog.header"));
|
|
|
|
+ alert.setContentText(resourceBundle.getString("removeLicenseKeyDialog.content"));
|
|
|
|
+
|
|
|
|
+ alert.showAndWait().ifPresent(response -> {
|
|
|
|
+ if (response == ButtonType.OK) {
|
|
|
|
+ supporterCertificateField.setText(null);
|
|
|
|
+ settings.licenseKey.set(null);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ });
|
|
}
|
|
}
|
|
|
|
|
|
private TextFormatter.Change removeWhitespaces(TextFormatter.Change change) {
|
|
private TextFormatter.Change removeWhitespaces(TextFormatter.Change change) {
|
|
@@ -57,6 +83,16 @@ public class SupporterCertificateController implements FxController {
|
|
application.getHostServices().showDocument(SUPPORTER_URI);
|
|
application.getHostServices().showDocument(SUPPORTER_URI);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @FXML
|
|
|
|
+ public void showDonate() {
|
|
|
|
+ application.getHostServices().showDocument(DONATE_URI);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @FXML
|
|
|
|
+ public void showSponsors() {
|
|
|
|
+ application.getHostServices().showDocument(SPONSORS_URI);
|
|
|
|
+ }
|
|
|
|
+
|
|
public LicenseHolder getLicenseHolder() {
|
|
public LicenseHolder getLicenseHolder() {
|
|
return licenseHolder;
|
|
return licenseHolder;
|
|
}
|
|
}
|