Pārlūkot izejas kodu

rearranged view elements an renamed advancedSettings to expertSettings

Jan-Peter Klein 1 gadu atpakaļ
vecāks
revīzija
2c506fcc97

+ 6 - 14
src/main/java/org/cryptomator/ui/addvaultwizard/AddVaultModule.java

@@ -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);
 
 }

+ 36 - 6
src/main/java/org/cryptomator/ui/addvaultwizard/CreateNewVaultAdvancedSettingsController.java

@@ -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();
+	}
 }

+ 5 - 17
src/main/java/org/cryptomator/ui/addvaultwizard/CreateNewVaultLocationController.java

@@ -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());
 		}
 	}
 

+ 5 - 15
src/main/java/org/cryptomator/ui/addvaultwizard/CreateNewVaultPasswordController.java

@@ -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

+ 1 - 1
src/main/java/org/cryptomator/ui/common/FxmlFile.java

@@ -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"), //

+ 15 - 6
src/main/resources/fxml/addvault_new_advanced_settings.fxml

@@ -12,9 +12,11 @@
 <?import javafx.scene.layout.Region?>
 <?import javafx.scene.layout.StackPane?>
 <?import javafx.scene.layout.VBox?>
+<?import javafx.scene.control.CheckBox?>
+<?import javafx.scene.layout.Pane?>
 <VBox xmlns:fx="http://javafx.com/fxml"
 	  xmlns="http://javafx.com/javafx"
-	  fx:controller="org.cryptomator.ui.addvaultwizard.CreateNewVaultAdvancedSettingsController"
+	  fx:controller="org.cryptomator.ui.addvaultwizard.CreateNewVaultExpertSettingsController"
 	  prefWidth="450"
 	  prefHeight="450"
 	  spacing="12"
@@ -23,10 +25,17 @@
 		<Insets topRightBottomLeft="24"/>
 	</padding>
 	<children>
-
 		<Region prefHeight="12" VBox.vgrow="NEVER"/>
-
-		<VBox spacing="6">
+		<VBox>
+			<Label text="%addvaultwizard.new.namePrompt"/>
+			<Label text="${controller.vaultName}" wrapText="true" styleClass="label-muted"/>
+			<Region prefHeight="4" VBox.vgrow="NEVER"/>
+			<Label text="%addvaultwizard.new.locationLabel"/>
+			<Label text="${controller.vaultPath}" wrapText="true" styleClass="label-muted"/>
+		</VBox>
+		<Region prefHeight="12" VBox.vgrow="NEVER"/>
+		<CheckBox fx:id="expertSettingsCheckBox" text="%addvaultwizard.new.enableExpertSettings.checkbox" onAction="#toggleUseExpertSettings"/>
+		<VBox spacing="6" visible="${expertSettingsCheckBox.selected}">
 			<HBox spacing="2" HBox.hgrow="NEVER">
 				<Label text="%addvaultwizard.new.shorteningThreshold.title"/>
 				<Region prefWidth="2"/>
@@ -55,13 +64,13 @@
 					</Label>
 				</StackPane>
 			</HBox>
+			<Label text="%addvaultwizard.new.shorteningThreshold.message"/>
 		</VBox>
-		<Label text="%addvaultwizard.new.shorteningThreshold.message"/>
 		<Region VBox.vgrow="ALWAYS"/>
 
 		<ButtonBar buttonMinWidth="120" buttonOrder="B+X">
 			<buttons>
-				<Button text="%generic.button.back" ButtonBar.buttonData="BACK_PREVIOUS" onAction="#back" disable="${!controller.validShorteningThreshold}"/>
+				<Button text="%generic.button.back" ButtonBar.buttonData="BACK_PREVIOUS" onAction="#back"/>
 				<Button text="%generic.button.next" ButtonBar.buttonData="NEXT_FORWARD" onAction="#next" defaultButton="true" disable="${!controller.validShorteningThreshold}"/>
 			</buttons>
 		</ButtonBar>

+ 0 - 4
src/main/resources/fxml/addvault_new_location.fxml

@@ -51,10 +51,6 @@
 			<Label fx:id="locationStatusLabel" alignment="CENTER_RIGHT" wrapText="true" visible="${controller.anyRadioButtonSelected}" maxWidth="Infinity" graphicTextGap="6" />
 		</VBox>
 
-		<Region prefHeight="12" VBox.vgrow="NEVER"/>
-
-		<CheckBox fx:id="advancedSettingsCheckBox" text="%addvaultwizard.new.showAdvancedSettings.checkbox"/>
-
 		<Region VBox.vgrow="ALWAYS"/>
 
 		<ButtonBar buttonMinWidth="120" buttonOrder="B+X">

+ 2 - 2
src/main/resources/i18n/strings.properties

@@ -63,11 +63,11 @@ addvaultwizard.new.validCharacters.message=The vault name may contain the follow
 addvaultwizard.new.validCharacters.chars=Word characters (e.g. a, ж or 수)
 addvaultwizard.new.validCharacters.numbers=Numbers
 addvaultwizard.new.validCharacters.dashes=Hyphen (%s) or underscore (%s)
-addvaultwizard.new.showAdvancedSettings.checkbox=Show advanced settings in next step
+addvaultwizard.new.enableExpertSettings.checkbox=Enable expert settings
 addvaultwizard.new.shorteningThreshold.title=Limit the length of encrypted file names.
 addvaultwizard.new.shorteningThreshold.tooltip=Open the documentation to learn more.
 addvaultwizard.new.shorteningThreshold.namePrompt=36-220
-addvaultwizard.new.shorteningThreshold.message=Enter a value between 36 and 220.
+addvaultwizard.new.shorteningThreshold.message=Enter a value between 36 and 220 (default 220).
 addvaultwizard.new.shorteningThreshold.invalid=Invalid
 addvaultwizard.new.shorteningThreshold.valid=Valid
 ### Password