Browse Source

implement requested changes from PR review

Jan-Peter Klein 1 year ago
parent
commit
f817bc5378

+ 8 - 9
src/main/java/org/cryptomator/ui/addvaultwizard/CreateNewVaultExpertSettingsController.java

@@ -26,6 +26,7 @@ public class CreateNewVaultExpertSettingsController implements FxController {
 	public static final int DEFAULT_SHORTENING_THRESHOLD = 220;
 	public static final int MIN_SHORTENING_THRESHOLD = 36;
 	private static final String DOCS_NAME_SHORTENING_URL = "https://docs.cryptomator.org/en/1.7/security/architecture/#name-shortening";
+
 	private final Stage window;
 	private final Lazy<Application> application;
 	private final Lazy<Scene> chooseLocationScene;
@@ -60,6 +61,8 @@ public class CreateNewVaultExpertSettingsController implements FxController {
 
 	@FXML
 	public void initialize() {
+		shorteningThresholdTextField.setPromptText(MIN_SHORTENING_THRESHOLD + "-" + DEFAULT_SHORTENING_THRESHOLD);
+		shorteningThresholdTextField.setText(Integer.toString(DEFAULT_SHORTENING_THRESHOLD));
 		shorteningThresholdTextField.textProperty().addListener((observable, oldValue, newValue) -> {
 			try {
 				int intValue = Integer.parseInt(newValue);
@@ -73,7 +76,7 @@ public class CreateNewVaultExpertSettingsController implements FxController {
 	@FXML
 	public void toggleUseExpertSettings() {
 		if (!expertSettingsCheckBox.isSelected()) {
-			shorteningThresholdTextField.setText(DEFAULT_SHORTENING_THRESHOLD + "");
+			shorteningThresholdTextField.setText(Integer.toString(DEFAULT_SHORTENING_THRESHOLD));
 		}
 	}
 
@@ -92,15 +95,11 @@ public class CreateNewVaultExpertSettingsController implements FxController {
 	}
 
 	public boolean isValidShorteningThreshold() {
-		try {
-			var value = shorteningThreshold.get();
-			if (value < MIN_SHORTENING_THRESHOLD || value > DEFAULT_SHORTENING_THRESHOLD) {
-				return false;
-			} else {
-				return true;
-			}
-		} catch (NumberFormatException e) {
+		var value = shorteningThreshold.get();
+		if (value < MIN_SHORTENING_THRESHOLD || value > DEFAULT_SHORTENING_THRESHOLD) {
 			return false;
+		} else {
+			return true;
 		}
 	}
 

+ 0 - 1
src/main/java/org/cryptomator/ui/addvaultwizard/CreateNewVaultLocationController.java

@@ -70,7 +70,6 @@ public class CreateNewVaultLocationController implements FxController {
 	@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_EXPERT_SETTINGS) Lazy<Scene> chooseExpertSettingsScene, //
 									 ObjectProperty<Path> vaultPath, //
 									 @Named("vaultName") StringProperty vaultName, //

+ 1 - 1
src/main/resources/fxml/addvault_new_expert_settings.fxml

@@ -49,7 +49,7 @@
 				</Hyperlink>
 			</HBox>
 			<HBox>
-				<NumericTextField fx:id="shorteningThresholdTextField" promptText="%addvaultwizard.new.shorteningThreshold.namePrompt" text="220"/>
+				<NumericTextField fx:id="shorteningThresholdTextField"/>
 				<Region prefWidth="4" HBox.hgrow="NEVER"/>
 				<StackPane>
 					<Label styleClass="label-muted" text="%addvaultwizard.new.shorteningThreshold.invalid" textAlignment="RIGHT" alignment="CENTER_RIGHT" visible="${!controller.validShorteningThreshold}" graphicTextGap="6">

+ 0 - 1
src/main/resources/i18n/strings.properties

@@ -66,7 +66,6 @@ addvaultwizard.new.validCharacters.dashes=Hyphen (%s) or underscore (%s)
 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 (default 220).
 addvaultwizard.new.shorteningThreshold.invalid=Invalid
 addvaultwizard.new.shorteningThreshold.valid=Valid