Browse Source

Some controllers no longer singleton, preventing reuse of internal states. Fixes #537

Sebastian Stenzel 7 years ago
parent
commit
0a7d102981

+ 0 - 5
main/ui/src/main/java/org/cryptomator/ui/controllers/ChangePasswordController.java

@@ -15,7 +15,6 @@ import java.util.Objects;
 import java.util.Optional;
 
 import javax.inject.Inject;
-import javax.inject.Singleton;
 
 import org.cryptomator.cryptolib.api.InvalidPassphraseException;
 import org.cryptomator.cryptolib.api.UnsupportedVaultFormatException;
@@ -42,7 +41,6 @@ import javafx.scene.layout.GridPane;
 import javafx.scene.layout.Region;
 import javafx.scene.text.Text;
 
-@Singleton
 public class ChangePasswordController implements ViewController {
 
 	private static final Logger LOG = LoggerFactory.getLogger(ChangePasswordController.class);
@@ -123,9 +121,6 @@ public class ChangePasswordController implements ViewController {
 
 	void setVault(Vault vault) {
 		this.vault = Objects.requireNonNull(vault);
-		oldPasswordField.swipe();
-		newPasswordField.swipe();
-		retypePasswordField.swipe();
 		// trigger "default" change to refresh key bindings:
 		changePasswordButton.setDefaultButton(false);
 		changePasswordButton.setDefaultButton(true);

+ 3 - 7
main/ui/src/main/java/org/cryptomator/ui/controllers/InitializeController.java

@@ -16,7 +16,6 @@ import java.util.Objects;
 import java.util.Optional;
 
 import javax.inject.Inject;
-import javax.inject.Singleton;
 
 import org.cryptomator.ui.controls.SecPasswordField;
 import org.cryptomator.ui.l10n.Localization;
@@ -28,8 +27,8 @@ import org.slf4j.LoggerFactory;
 
 import javafx.application.Platform;
 import javafx.beans.binding.BooleanBinding;
-import javafx.beans.property.IntegerProperty;
 import javafx.beans.property.SimpleIntegerProperty;
+import javafx.beans.value.ObservableValue;
 import javafx.event.ActionEvent;
 import javafx.fxml.FXML;
 import javafx.scene.Parent;
@@ -38,14 +37,13 @@ import javafx.scene.control.Label;
 import javafx.scene.layout.GridPane;
 import javafx.scene.layout.Region;
 
-@Singleton
 public class InitializeController implements ViewController {
 
 	private static final Logger LOG = LoggerFactory.getLogger(InitializeController.class);
 
 	private final Localization localization;
 	private final PasswordStrengthUtil strengthRater;
-	private final IntegerProperty passwordStrength = new SimpleIntegerProperty(); // 0-4
+	private ObservableValue<Integer> passwordStrength; // 0-4
 	private Optional<InitializationListener> listener = Optional.empty();
 	private Vault vault;
 
@@ -93,7 +91,7 @@ public class InitializeController implements ViewController {
 		BooleanBinding passwordIsEmpty = passwordField.textProperty().isEmpty();
 		BooleanBinding passwordsDiffer = passwordField.textProperty().isNotEqualTo(retypePasswordField.textProperty());
 		okButton.disableProperty().bind(passwordIsEmpty.or(passwordsDiffer));
-		passwordStrength.bind(EasyBind.map(passwordField.textProperty(), strengthRater::computeRate));
+		passwordStrength = EasyBind.map(passwordField.textProperty(), strengthRater::computeRate);
 
 		passwordStrengthLevel0.backgroundProperty().bind(EasyBind.combine(passwordStrength, new SimpleIntegerProperty(0), strengthRater::getBackgroundWithStrengthColor));
 		passwordStrengthLevel1.backgroundProperty().bind(EasyBind.combine(passwordStrength, new SimpleIntegerProperty(1), strengthRater::getBackgroundWithStrengthColor));
@@ -110,8 +108,6 @@ public class InitializeController implements ViewController {
 
 	void setVault(Vault vault) {
 		this.vault = Objects.requireNonNull(vault);
-		passwordField.swipe();
-		retypePasswordField.swipe();
 		// trigger "default" change to refresh key bindings:
 		okButton.setDefaultButton(false);
 		okButton.setDefaultButton(true);

+ 0 - 1
main/ui/src/main/java/org/cryptomator/ui/controllers/UnlockController.java

@@ -167,7 +167,6 @@ public class UnlockController implements ViewController {
 		}
 		assert vault != null;
 		this.vault = vault;
-		passwordField.swipe();
 		advancedOptions.setVisible(false);
 		advancedOptionsButton.setText(localization.getString("unlock.button.advancedOptions.show"));
 		progressIndicator.setVisible(false);