mirror of
https://github.com/cryptomator/cryptomator.git
synced 2024-11-23 03:59:51 +00:00
This commit is contained in:
parent
7cdb2025dc
commit
00e1e3654e
@ -45,6 +45,7 @@ public enum FxmlFile {
|
||||
RECOVERYKEY_RESET_PASSWORD("/fxml/recoverykey_reset_password.fxml"), //
|
||||
RECOVERYKEY_RESET_PASSWORD_SUCCESS("/fxml/recoverykey_reset_password_success.fxml"), //
|
||||
RECOVERYKEY_SUCCESS("/fxml/recoverykey_success.fxml"), //
|
||||
REMOVE_CERT("/fxml/remove_cert.fxml"), //
|
||||
REMOVE_VAULT("/fxml/remove_vault.fxml"), //
|
||||
SHARE_VAULT("/fxml/share_vault.fxml"), //
|
||||
UPDATE_REMINDER("/fxml/update_reminder.fxml"), //
|
||||
|
@ -14,6 +14,7 @@ import org.cryptomator.ui.lock.LockComponent;
|
||||
import org.cryptomator.ui.mainwindow.MainWindowComponent;
|
||||
import org.cryptomator.ui.preferences.PreferencesComponent;
|
||||
import org.cryptomator.ui.quit.QuitComponent;
|
||||
import org.cryptomator.ui.removecert.RemoveCertComponent;
|
||||
import org.cryptomator.ui.sharevault.ShareVaultComponent;
|
||||
import org.cryptomator.ui.traymenu.TrayMenuComponent;
|
||||
import org.cryptomator.ui.unlock.UnlockComponent;
|
||||
@ -35,6 +36,7 @@ import java.io.InputStream;
|
||||
HealthCheckComponent.class, //
|
||||
UpdateReminderComponent.class, //
|
||||
DokanySupportEndComponent.class, //
|
||||
RemoveCertComponent.class, //
|
||||
ShareVaultComponent.class})
|
||||
abstract class FxApplicationModule {
|
||||
|
||||
|
@ -5,17 +5,14 @@ import org.cryptomator.common.LicenseHolder;
|
||||
import org.cryptomator.common.settings.Settings;
|
||||
import org.cryptomator.common.settings.UiTheme;
|
||||
import org.cryptomator.ui.common.FxController;
|
||||
import org.cryptomator.ui.removecert.RemoveCertComponent;
|
||||
|
||||
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 {
|
||||
@ -27,19 +24,17 @@ public class SupporterCertificateController implements FxController {
|
||||
private final Application application;
|
||||
private final LicenseHolder licenseHolder;
|
||||
private final Settings settings;
|
||||
private final ResourceBundle resourceBundle;
|
||||
private final RemoveCertComponent.Builder removeCert;
|
||||
|
||||
@FXML
|
||||
private TextArea supporterCertificateField;
|
||||
@FXML
|
||||
private Button trashButton;
|
||||
|
||||
@Inject
|
||||
SupporterCertificateController(Application application, LicenseHolder licenseHolder, Settings settings, ResourceBundle resourceBundle) {
|
||||
SupporterCertificateController(Application application, LicenseHolder licenseHolder, Settings settings, RemoveCertComponent.Builder removeCert) {
|
||||
this.application = application;
|
||||
this.licenseHolder = licenseHolder;
|
||||
this.settings = settings;
|
||||
this.resourceBundle = resourceBundle;
|
||||
this.removeCert = removeCert;
|
||||
}
|
||||
|
||||
@FXML
|
||||
@ -47,20 +42,7 @@ 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);
|
||||
}
|
||||
});
|
||||
});
|
||||
settings.licenseKey.addListener(this::licenseKeySettingsChanged);
|
||||
}
|
||||
|
||||
private TextFormatter.Change removeWhitespaces(TextFormatter.Change change) {
|
||||
@ -71,6 +53,11 @@ public class SupporterCertificateController implements FxController {
|
||||
return change;
|
||||
}
|
||||
|
||||
private void licenseKeySettingsChanged(@SuppressWarnings("unused") ObservableValue<? extends String> observable, @SuppressWarnings("unused") String oldValue, String newValue){
|
||||
if(newValue == null)
|
||||
supporterCertificateField.setText(null);
|
||||
}
|
||||
|
||||
private void registrationKeyChanged(@SuppressWarnings("unused") ObservableValue<? extends String> observable, @SuppressWarnings("unused") String oldValue, String newValue) {
|
||||
licenseHolder.validateAndStoreLicense(newValue);
|
||||
if (!licenseHolder.isValidLicense()) {
|
||||
@ -93,6 +80,11 @@ public class SupporterCertificateController implements FxController {
|
||||
application.getHostServices().showDocument(SPONSORS_URI);
|
||||
}
|
||||
|
||||
@FXML
|
||||
void didClickRemoveCert() {
|
||||
removeCert.build().showRemoveCert();
|
||||
}
|
||||
|
||||
public LicenseHolder getLicenseHolder() {
|
||||
return licenseHolder;
|
||||
}
|
||||
|
@ -0,0 +1,33 @@
|
||||
package org.cryptomator.ui.removecert;
|
||||
|
||||
import dagger.Lazy;
|
||||
import dagger.Subcomponent;
|
||||
import org.cryptomator.ui.common.FxmlFile;
|
||||
import org.cryptomator.ui.common.FxmlScene;
|
||||
|
||||
import javafx.scene.Scene;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
@RemoveCertScoped
|
||||
@Subcomponent(modules = {RemoveCertModule.class})
|
||||
public interface RemoveCertComponent {
|
||||
|
||||
@RemoveCertWindow
|
||||
Stage window();
|
||||
|
||||
@FxmlScene(FxmlFile.REMOVE_CERT)
|
||||
Lazy<Scene> scene();
|
||||
|
||||
default void showRemoveCert() {
|
||||
Stage stage = window();
|
||||
stage.setScene(scene().get());
|
||||
stage.sizeToScene();
|
||||
stage.show();
|
||||
}
|
||||
|
||||
@Subcomponent.Builder
|
||||
interface Builder {
|
||||
RemoveCertComponent build();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package org.cryptomator.ui.removecert;
|
||||
|
||||
import org.cryptomator.common.settings.Settings;
|
||||
import org.cryptomator.ui.common.FxController;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
@RemoveCertScoped
|
||||
public class RemoveCertController implements FxController {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(org.cryptomator.ui.removecert.RemoveCertController.class);
|
||||
|
||||
private final Stage window;
|
||||
private final Settings settings;
|
||||
|
||||
@Inject
|
||||
public RemoveCertController(@RemoveCertWindow Stage window, Settings settings) {
|
||||
this.window = window;
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void close() {
|
||||
window.close();
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void remove() {
|
||||
settings.licenseKey.set(null);
|
||||
window.close();
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package org.cryptomator.ui.removecert;
|
||||
|
||||
import dagger.Binds;
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
import dagger.multibindings.IntoMap;
|
||||
import org.cryptomator.ui.common.DefaultSceneFactory;
|
||||
import org.cryptomator.ui.common.FxController;
|
||||
import org.cryptomator.ui.common.FxControllerKey;
|
||||
import org.cryptomator.ui.common.FxmlFile;
|
||||
import org.cryptomator.ui.common.FxmlLoaderFactory;
|
||||
import org.cryptomator.ui.common.FxmlScene;
|
||||
import org.cryptomator.ui.common.StageFactory;
|
||||
|
||||
import javax.inject.Provider;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.stage.Modality;
|
||||
import javafx.stage.Stage;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
@Module
|
||||
abstract class RemoveCertModule {
|
||||
|
||||
@Provides
|
||||
@RemoveCertWindow
|
||||
@RemoveCertScoped
|
||||
static FxmlLoaderFactory provideFxmlLoaderFactory(Map<Class<? extends FxController>, Provider<FxController>> factories, DefaultSceneFactory sceneFactory, ResourceBundle resourceBundle) {
|
||||
return new FxmlLoaderFactory(factories, sceneFactory, resourceBundle);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@RemoveCertWindow
|
||||
@RemoveCertScoped
|
||||
static Stage provideStage(StageFactory factory, ResourceBundle resourceBundle) {
|
||||
Stage stage = factory.create();
|
||||
stage.setTitle(resourceBundle.getString("removeCert.title"));
|
||||
stage.setResizable(false);
|
||||
stage.initModality(Modality.WINDOW_MODAL);
|
||||
return stage;
|
||||
}
|
||||
|
||||
@Provides
|
||||
@FxmlScene(FxmlFile.REMOVE_CERT)
|
||||
@RemoveCertScoped
|
||||
static Scene provideRemoveCertScene(@RemoveCertWindow FxmlLoaderFactory fxmlLoaders) {
|
||||
return fxmlLoaders.createScene(FxmlFile.REMOVE_CERT);
|
||||
}
|
||||
|
||||
// ------------------
|
||||
|
||||
@Binds
|
||||
@IntoMap
|
||||
@FxControllerKey(RemoveCertController.class)
|
||||
abstract FxController bindRemoveCertController(RemoveCertController controller);
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package org.cryptomator.ui.removecert;
|
||||
|
||||
import javax.inject.Scope;
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@Scope
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface RemoveCertScoped {
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package org.cryptomator.ui.removecert;
|
||||
|
||||
import javax.inject.Qualifier;
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Retention;
|
||||
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
@Qualifier
|
||||
@Documented
|
||||
@Retention(RUNTIME)
|
||||
@interface RemoveCertWindow {
|
||||
|
||||
}
|
@ -32,7 +32,7 @@
|
||||
<FormattedLabel format="%preferences.contribute.registeredFor" arg1="${controller.licenseHolder.licenseSubject}" wrapText="true"/>
|
||||
<Region minHeight="12"/>
|
||||
<HBox alignment="BOTTOM_CENTER" spacing="6">
|
||||
<Button fx:id="trashButton">
|
||||
<Button fx:id="trashButton" onAction="#didClickRemoveCert">
|
||||
<graphic>
|
||||
<FontAwesome5IconView glyph="TRASH"/>
|
||||
</graphic>
|
||||
|
51
src/main/resources/fxml/remove_cert.fxml
Normal file
51
src/main/resources/fxml/remove_cert.fxml
Normal file
@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import org.cryptomator.ui.controls.FontAwesome5IconView?>
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.control.ButtonBar?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<?import javafx.scene.layout.StackPane?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<?import javafx.scene.shape.Circle?>
|
||||
<?import javafx.scene.Group?>
|
||||
<?import javafx.scene.layout.Region?>
|
||||
<HBox xmlns:fx="http://javafx.com/fxml"
|
||||
xmlns="http://javafx.com/javafx"
|
||||
fx:controller="org.cryptomator.ui.removecert.RemoveCertController"
|
||||
minWidth="400"
|
||||
maxWidth="400"
|
||||
minHeight="145"
|
||||
spacing="12">
|
||||
<padding>
|
||||
<Insets topRightBottomLeft="12"/>
|
||||
</padding>
|
||||
<children>
|
||||
<Group>
|
||||
<StackPane>
|
||||
<padding>
|
||||
<Insets topRightBottomLeft="6"/>
|
||||
</padding>
|
||||
<Circle styleClass="glyph-icon-primary" radius="24"/>
|
||||
<FontAwesome5IconView styleClass="glyph-icon-white" glyph="QUESTION" glyphSize="24"/>
|
||||
</StackPane>
|
||||
</Group>
|
||||
<VBox HBox.hgrow="ALWAYS">
|
||||
<Label styleClass="label-large" text="%removeCert.message" wrapText="true" >
|
||||
<padding>
|
||||
<Insets bottom="6" top="6"/>
|
||||
</padding>
|
||||
</Label>
|
||||
<Label text="%removeCert.description" wrapText="true" />
|
||||
|
||||
<Region VBox.vgrow="ALWAYS" minHeight="18"/>
|
||||
<ButtonBar buttonMinWidth="120" buttonOrder="+CI">
|
||||
<buttons>
|
||||
<Button text="%generic.button.cancel" ButtonBar.buttonData="CANCEL_CLOSE" defaultButton="true" cancelButton="true" onAction="#close"/>
|
||||
<Button text="%removeCert.confirmBtn" ButtonBar.buttonData="FINISH" onAction="#remove"/>
|
||||
</buttons>
|
||||
</ButtonBar>
|
||||
</VBox>
|
||||
</children>
|
||||
</HBox>
|
@ -338,9 +338,10 @@ preferences.contribute.getCertificate=Don't have one already? Learn how you can
|
||||
preferences.contribute.promptText=Paste supporter certificate code here
|
||||
|
||||
### Remove License Key Dialog
|
||||
removeLicenseKeyDialog.title=Confirm Removal
|
||||
removeLicenseKeyDialog.header=Remove Certificate
|
||||
removeLicenseKeyDialog.content=Are you sure you want to remove the certificate?
|
||||
removeCert.title=Remove Cert
|
||||
removeCert.message=Remove supporter certificate?
|
||||
removeCert.description=Are you sure you want to remove the certificate?
|
||||
removeCert.confirmBtn=Remove Cert
|
||||
#<-- Add entries for donations and code/translation/documentation contribution -->
|
||||
|
||||
## About
|
||||
|
Loading…
Reference in New Issue
Block a user