Bladeren bron

Simpler solution to 8aa3da1 and 1702c6a2

Sebastian Stenzel 5 jaren geleden
bovenliggende
commit
461ec3ca43

+ 5 - 4
main/ui/src/main/java/org/cryptomator/ui/unlock/UnlockController.java

@@ -73,7 +73,7 @@ public class UnlockController implements FxController {
 		if (keychainAccess.isPresent()) {
 			loadStoredPassword();
 		} else {
-			savePassword.setDisable(true);
+			savePassword.setSelected(false);
 		}
 		unlockButtonDisabled.bind(vault.stateProperty().isNotEqualTo(VaultState.LOCKED).or(passwordField.textProperty().isEmpty()));
 	}
@@ -91,10 +91,8 @@ public class UnlockController implements FxController {
 
 		Task<Vault> task = vaultService.createUnlockTask(vault, password);
 		passwordField.setDisable(true);
-		savePassword.setDisable(true);
 		task.setOnSucceeded(event -> {
 			passwordField.setDisable(false);
-			savePassword.setDisable(!keychainAccess.isPresent());
 			if (keychainAccess.isPresent() && savePassword.isSelected()) {
 				try {
 					keychainAccess.get().storePassphrase(vault.getId(), password);
@@ -108,7 +106,6 @@ public class UnlockController implements FxController {
 		});
 		task.setOnFailed(event -> {
 			passwordField.setDisable(false);
-			savePassword.setDisable(!keychainAccess.isPresent());
 			if (task.getException() instanceof InvalidPassphraseException) {
 				Animations.createShakeWindowAnimation(window).play();
 				passwordField.selectAll();
@@ -190,4 +187,8 @@ public class UnlockController implements FxController {
 	public boolean isUnlockButtonDisabled() {
 		return unlockButtonDisabled.get();
 	}
+
+	public boolean isKeychainAccessAvailable() {
+		return keychainAccess.isPresent();
+	}
 }

+ 1 - 1
main/ui/src/main/resources/fxml/unlock.fxml

@@ -22,7 +22,7 @@
 		<VBox spacing="6">
 			<FormattedLabel format="%unlock.passwordPrompt" arg1="${controller.vault.displayableName}" wrapText="true"/>
 			<NiceSecurePasswordField fx:id="passwordField"/>
-			<CheckBox fx:id="savePassword" text="%unlock.savePassword" onAction="#didClickSavePasswordCheckbox"/>
+			<CheckBox fx:id="savePassword" text="%unlock.savePassword" onAction="#didClickSavePasswordCheckbox" disable="${controller.vault.processing}" visible="${controller.keychainAccessAvailable}"/>
 		</VBox>
 
 		<VBox alignment="BOTTOM_CENTER" VBox.vgrow="ALWAYS">