improved supporter cert ui with cert stemp, donate/sponsors link buttons and remove button with dialog

This commit is contained in:
Jan-Peter Klein
2024-09-04 13:23:36 +02:00
parent d65beb632d
commit 7cdb2025dc
9 changed files with 131 additions and 25 deletions

View File

@@ -17,6 +17,7 @@ public enum FontAwesome5Icon {
COGS("\uF085"), //
COPY("\uF0C5"), //
CROWN("\uF521"), //
DONATE("\uF4B9"), //
EDIT("\uF044"), //
EXCHANGE_ALT("\uF362"), //
EXCLAMATION("\uF12A"), //
@@ -49,6 +50,7 @@ public enum FontAwesome5Icon {
SEARCH("\uF002"), //
SHARE("\uF064"), //
SPINNER("\uF110"), //
SPONSORS("\uF2B5"), //
STETHOSCOPE("\uF0f1"), //
SYNC("\uF021"), //
TIMES("\uF00D"), //

View File

@@ -31,7 +31,7 @@ public interface PreferencesComponent {
Stage stage = window();
stage.setScene(scene().get());
stage.setMinWidth(420);
stage.setMinHeight(300);
stage.setMinHeight(400);
stage.show();
stage.requestFocus();
return stage;

View File

@@ -10,24 +10,36 @@ import javax.inject.Inject;
import javafx.application.Application;
import javafx.beans.value.ObservableValue;
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.TextFormatter;
import java.util.ResourceBundle;
@PreferencesScoped
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 final Application application;
private final LicenseHolder licenseHolder;
private final Settings settings;
public TextArea supporterCertificateField;
private final ResourceBundle resourceBundle;
@FXML
private TextArea supporterCertificateField;
@FXML
private Button trashButton;
@Inject
SupporterCertificateController(Application application, LicenseHolder licenseHolder, Settings settings) {
SupporterCertificateController(Application application, LicenseHolder licenseHolder, Settings settings, ResourceBundle resourceBundle) {
this.application = application;
this.licenseHolder = licenseHolder;
this.settings = settings;
this.resourceBundle = resourceBundle;
}
@FXML
@@ -35,6 +47,20 @@ public class SupporterCertificateController implements FxController {
supporterCertificateField.setText(licenseHolder.getLicenseKey().orElse(null));
supporterCertificateField.textProperty().addListener(this::registrationKeyChanged);
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) {
@@ -57,6 +83,16 @@ public class SupporterCertificateController implements FxController {
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() {
return licenseHolder;
}