rearranged view elements an renamed advancedSettings to expertSettings

This commit is contained in:
Jan-Peter Klein
2023-07-05 13:17:10 +02:00
parent dd71df8382
commit 2c506fcc97
8 changed files with 70 additions and 65 deletions

View File

@@ -19,10 +19,8 @@ import org.cryptomator.ui.recoverykey.RecoveryKeyDisplayController;
import javax.inject.Named;
import javax.inject.Provider;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
@@ -73,13 +71,7 @@ public abstract class AddVaultModule {
@Named("shorteningThreshold")
@AddVaultWizardScoped
static IntegerProperty provideShorteningThreshold() {
return new SimpleIntegerProperty(CreateNewVaultAdvancedSettingsController.DEFAULT_SHORTENING_THRESHOLD);
}
@Provides
@AddVaultWizardScoped
static BooleanProperty provideAdvancedSettingsEnabled() {
return new SimpleBooleanProperty();
return new SimpleIntegerProperty(CreateNewVaultExpertSettingsController.DEFAULT_SHORTENING_THRESHOLD);
}
@Provides
@@ -148,10 +140,10 @@ public abstract class AddVaultModule {
}
@Provides
@FxmlScene(FxmlFile.ADDVAULT_NEW_ADVANCED_SETTINGS)
@FxmlScene(FxmlFile.ADDVAULT_NEW_EXPERT_SETTINGS)
@AddVaultWizardScoped
static Scene provideCreateNewVaultAdvancedSettingsScene(@AddVaultWizardWindow FxmlLoaderFactory fxmlLoaders) {
return fxmlLoaders.createScene(FxmlFile.ADDVAULT_NEW_ADVANCED_SETTINGS);
static Scene provideCreateNewVaultExpertSettingsScene(@AddVaultWizardWindow FxmlLoaderFactory fxmlLoaders) {
return fxmlLoaders.createScene(FxmlFile.ADDVAULT_NEW_EXPERT_SETTINGS);
}
// ------------------
@@ -207,7 +199,7 @@ public abstract class AddVaultModule {
@Binds
@IntoMap
@FxControllerKey(CreateNewVaultAdvancedSettingsController.class)
abstract FxController bindCreateNewVaultAdvancedSettingsController(CreateNewVaultAdvancedSettingsController controller);
@FxControllerKey(CreateNewVaultExpertSettingsController.class)
abstract FxController bindCreateNewVaultExpertSettingsController(CreateNewVaultExpertSettingsController controller);
}

View File

@@ -12,12 +12,17 @@ import javafx.application.Application;
import javafx.beans.binding.Bindings;
import javafx.beans.binding.BooleanBinding;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.StringProperty;
import javafx.fxml.FXML;
import javafx.scene.Scene;
import javafx.scene.control.CheckBox;
import javafx.scene.control.Label;
import javafx.stage.Stage;
import java.nio.file.Path;
@AddVaultWizardScoped
public class CreateNewVaultAdvancedSettingsController implements FxController {
public class CreateNewVaultExpertSettingsController implements FxController {
public static final int DEFAULT_SHORTENING_THRESHOLD = 220;
public static final int MIN_SHORTENING_THRESHOLD = 36;
@@ -29,17 +34,28 @@ public class CreateNewVaultAdvancedSettingsController implements FxController {
public NumericTextField shorteningThresholdTextField;
private final BooleanBinding validShorteningThreshold;
private final Lazy<Application> application;
private final StringProperty vaultNameProperty;
private final ObjectProperty<Path> vaultPathProperty;
public CheckBox expertSettingsCheckBox;
public Label vaultNameLabel;
public Label vaultLocationLabel;
@Inject
CreateNewVaultAdvancedSettingsController(@AddVaultWizardWindow Stage window, //
Lazy<Application> application, //
@FxmlScene(FxmlFile.ADDVAULT_NEW_LOCATION) Lazy<Scene> chooseLocationScene, //
@FxmlScene(FxmlFile.ADDVAULT_NEW_PASSWORD) Lazy<Scene> choosePasswordScene, //
@Named("shorteningThreshold") IntegerProperty shorteningThreshold) {
CreateNewVaultExpertSettingsController(@AddVaultWizardWindow Stage window, //
Lazy<Application> application, //
@FxmlScene(FxmlFile.ADDVAULT_NEW_LOCATION) Lazy<Scene> chooseLocationScene, //
@FxmlScene(FxmlFile.ADDVAULT_NEW_PASSWORD) Lazy<Scene> choosePasswordScene, //
@Named("vaultName") StringProperty vaultName, //
ObjectProperty<Path> vaultPath, //
@Named("shorteningThreshold") IntegerProperty shorteningThreshold) {
this.window = window;
this.application = application;
this.chooseLocationScene = chooseLocationScene;
this.choosePasswordScene = choosePasswordScene;
this.vaultNameProperty = vaultName;
this.vaultPathProperty = vaultPath;
this.shorteningThreshold = shorteningThreshold;
this.validShorteningThreshold = Bindings.createBooleanBinding(this::isValidShorteningThreshold, shorteningThreshold);
}
@@ -56,6 +72,13 @@ public class CreateNewVaultAdvancedSettingsController implements FxController {
});
}
@FXML
public void toggleUseExpertSettings() {
if (!expertSettingsCheckBox.isSelected()) {
shorteningThresholdTextField.setText(DEFAULT_SHORTENING_THRESHOLD+"");
}
}
@FXML
public void back() {
window.setScene(chooseLocationScene.get());
@@ -84,4 +107,11 @@ public class CreateNewVaultAdvancedSettingsController implements FxController {
public void openDocs() {
application.get().getHostServices().showDocument(DOCS_MOUNTING_URL);
}
public Path getVaultPath() {
return vaultPathProperty.get();
}
public String getVaultName() {
return vaultNameProperty.get();
}
}

View File

@@ -21,7 +21,6 @@ import javafx.beans.property.StringProperty;
import javafx.beans.value.ObservableValue;
import javafx.fxml.FXML;
import javafx.scene.Scene;
import javafx.scene.control.CheckBox;
import javafx.scene.control.Label;
import javafx.scene.control.RadioButton;
import javafx.scene.control.Toggle;
@@ -49,8 +48,7 @@ public class CreateNewVaultLocationController implements FxController {
private final Stage window;
private final Lazy<Scene> chooseNameScene;
private final Lazy<Scene> choosePasswordScene;
private final Lazy<Scene> chooseAdvancedSettingsScene;
private final Lazy<Scene> chooseExpertSettingsScene;
private final List<RadioButton> locationPresetBtns;
private final ObjectProperty<Path> vaultPath;
private final StringProperty vaultName;
@@ -68,26 +66,21 @@ public class CreateNewVaultLocationController implements FxController {
public Label locationStatusLabel;
public FontAwesome5IconView goodLocation;
public FontAwesome5IconView badLocation;
public CheckBox advancedSettingsCheckBox;
private final BooleanProperty advancedSettingsEnabled;
@Inject
CreateNewVaultLocationController(@AddVaultWizardWindow Stage window, //
@FxmlScene(FxmlFile.ADDVAULT_NEW_NAME) Lazy<Scene> chooseNameScene, //
@FxmlScene(FxmlFile.ADDVAULT_NEW_PASSWORD) Lazy<Scene> choosePasswordScene, //
@FxmlScene(FxmlFile.ADDVAULT_NEW_ADVANCED_SETTINGS) Lazy<Scene> chooseAdvancedSettingsScene, //
@FxmlScene(FxmlFile.ADDVAULT_NEW_EXPERT_SETTINGS) Lazy<Scene> chooseExpertSettingsScene, //
ObjectProperty<Path> vaultPath, //
@Named("vaultName") StringProperty vaultName, //
ResourceBundle resourceBundle, //
BooleanProperty advancedSettingsEnabled) {
ResourceBundle resourceBundle) {
this.window = window;
this.chooseNameScene = chooseNameScene;
this.choosePasswordScene = choosePasswordScene;
this.chooseAdvancedSettingsScene = chooseAdvancedSettingsScene;
this.chooseExpertSettingsScene = chooseExpertSettingsScene;
this.vaultPath = vaultPath;
this.vaultName = vaultName;
this.resourceBundle = resourceBundle;
this.advancedSettingsEnabled = advancedSettingsEnabled;
this.vaultPathStatus = ObservableUtil.mapWithDefault(vaultPath, this::validatePath, new VaultPathStatus(false, "error.message"));
this.validVaultPath = ObservableUtil.mapWithDefault(vaultPathStatus, VaultPathStatus::valid, false);
this.vaultPathStatus.addListener(this::updateStatusLabel);
@@ -149,7 +142,6 @@ public class CreateNewVaultLocationController implements FxController {
locationPresetsToggler.getToggles().addAll(locationPresetBtns);
locationPresetsToggler.selectedToggleProperty().addListener(this::togglePredefinedLocation);
usePresetPath.bind(locationPresetsToggler.selectedToggleProperty().isNotEqualTo(customRadioButton));
advancedSettingsEnabled.bind(advancedSettingsCheckBox.selectedProperty());
}
private void togglePredefinedLocation(@SuppressWarnings("unused") ObservableValue<? extends Toggle> observable, @SuppressWarnings("unused") Toggle oldValue, Toggle newValue) {
@@ -165,11 +157,7 @@ public class CreateNewVaultLocationController implements FxController {
@FXML
public void next() {
if (validVaultPath.getValue()) {
if (advancedSettingsEnabled.get()) {
window.setScene(chooseAdvancedSettingsScene.get());
} else {
window.setScene(choosePasswordScene.get());
}
window.setScene(chooseExpertSettingsScene.get());
}
}

View File

@@ -56,8 +56,7 @@ public class CreateNewVaultPasswordController implements FxController {
private static final Logger LOG = LoggerFactory.getLogger(CreateNewVaultPasswordController.class);
private final Stage window;
private final Lazy<Scene> chooseLocationScene;
private final Lazy<Scene> chooseAdvancedSettingsScene;
private final Lazy<Scene> chooseExpertSettingsScene;
private final Lazy<Scene> recoveryKeyScene;
private final Lazy<Scene> successScene;
private final FxApplicationWindows appWindows;
@@ -76,7 +75,6 @@ public class CreateNewVaultPasswordController implements FxController {
private final BooleanProperty readyToCreateVault;
private final ObjectBinding<ContentDisplay> createVaultButtonState;
private final IntegerProperty shorteningThreshold;
private final BooleanProperty advancedSettingsEnabled;
/* FXML */
public ToggleGroup recoveryKeyChoice;
@@ -86,8 +84,7 @@ public class CreateNewVaultPasswordController implements FxController {
@Inject
CreateNewVaultPasswordController(@AddVaultWizardWindow Stage window, //
@FxmlScene(FxmlFile.ADDVAULT_NEW_LOCATION) Lazy<Scene> chooseLocationScene, //
@FxmlScene(FxmlFile.ADDVAULT_NEW_ADVANCED_SETTINGS) Lazy<Scene> chooseAdvancedSettingsScene, //
@FxmlScene(FxmlFile.ADDVAULT_NEW_EXPERT_SETTINGS) Lazy<Scene> chooseExpertSettingsScene, //
@FxmlScene(FxmlFile.ADDVAULT_NEW_RECOVERYKEY) Lazy<Scene> recoveryKeyScene, //
@FxmlScene(FxmlFile.ADDVAULT_SUCCESS) Lazy<Scene> successScene, //
FxApplicationWindows appWindows, //
@@ -102,11 +99,9 @@ public class CreateNewVaultPasswordController implements FxController {
@Named("shorteningThreshold") IntegerProperty shorteningThreshold, //
ReadmeGenerator readmeGenerator, //
SecureRandom csprng, //
MasterkeyFileAccess masterkeyFileAccess, //
BooleanProperty advancedSettingsEnabled) {
MasterkeyFileAccess masterkeyFileAccess) {
this.window = window;
this.chooseLocationScene = chooseLocationScene;
this.chooseAdvancedSettingsScene = chooseAdvancedSettingsScene;
this.chooseExpertSettingsScene = chooseExpertSettingsScene;
this.recoveryKeyScene = recoveryKeyScene;
this.successScene = successScene;
this.appWindows = appWindows;
@@ -125,7 +120,6 @@ public class CreateNewVaultPasswordController implements FxController {
this.readyToCreateVault = new SimpleBooleanProperty();
this.createVaultButtonState = Bindings.when(processing).then(ContentDisplay.LEFT).otherwise(ContentDisplay.TEXT_ONLY);
this.shorteningThreshold = shorteningThreshold;
this.advancedSettingsEnabled = advancedSettingsEnabled;
}
@FXML
@@ -139,11 +133,7 @@ public class CreateNewVaultPasswordController implements FxController {
@FXML
public void back() {
if (advancedSettingsEnabled.getValue()) {
window.setScene(chooseAdvancedSettingsScene.get());
} else {
window.setScene(chooseLocationScene.get());
}
window.setScene(chooseExpertSettingsScene.get());
}
@FXML

View File

@@ -4,7 +4,7 @@ public enum FxmlFile {
ADDVAULT_EXISTING("/fxml/addvault_existing.fxml"), //
ADDVAULT_NEW_NAME("/fxml/addvault_new_name.fxml"), //
ADDVAULT_NEW_LOCATION("/fxml/addvault_new_location.fxml"), //
ADDVAULT_NEW_ADVANCED_SETTINGS("/fxml/addvault_new_advanced_settings.fxml"), //
ADDVAULT_NEW_EXPERT_SETTINGS("/fxml/addvault_new_expert_settings.fxml"), //
ADDVAULT_NEW_PASSWORD("/fxml/addvault_new_password.fxml"), //
ADDVAULT_NEW_RECOVERYKEY("/fxml/addvault_new_recoverykey.fxml"), //
ADDVAULT_SUCCESS("/fxml/addvault_success.fxml"), //