Ver código fonte

improved code quality

Jan-Peter Klein 1 ano atrás
pai
commit
e7e88f13e3

+ 0 - 13
src/main/java/org/cryptomator/common/CommonsModule.java

@@ -7,12 +7,10 @@ package org.cryptomator.common;
 
 import dagger.Module;
 import dagger.Provides;
-import org.apache.commons.lang3.SystemUtils;
 import org.cryptomator.common.keychain.KeychainModule;
 import org.cryptomator.common.mount.MountModule;
 import org.cryptomator.common.settings.Settings;
 import org.cryptomator.common.settings.SettingsProvider;
-import org.cryptomator.common.settings.VaultSettings;
 import org.cryptomator.common.vaults.VaultComponent;
 import org.cryptomator.common.vaults.VaultListModule;
 import org.cryptomator.cryptolib.common.MasterkeyFileAccess;
@@ -23,8 +21,6 @@ import org.slf4j.LoggerFactory;
 
 import javax.inject.Named;
 import javax.inject.Singleton;
-import javafx.beans.value.ObservableValue;
-import java.net.InetSocketAddress;
 import java.security.NoSuchAlgorithmException;
 import java.security.SecureRandom;
 import java.util.Comparator;
@@ -138,15 +134,6 @@ public abstract class CommonsModule {
 		LOG.error("Uncaught exception in " + thread.getName(), throwable);
 	}
 
-	@Provides
-	@Singleton
-	static ObservableValue<InetSocketAddress> provideServerSocketAddressBinding(VaultSettings vaultSettings) {
-		return vaultSettings.port.map(port -> {
-			String host = SystemUtils.IS_OS_WINDOWS ? "127.0.0.1" : "localhost";
-			return InetSocketAddress.createUnresolved(host, vaultSettings.port.intValue());
-		});
-	}
-
 	@Provides
 	@Singleton
 	@Named("FUPFMS")

+ 0 - 2
src/main/java/org/cryptomator/common/vaults/VaultListManager.java

@@ -73,8 +73,6 @@ public class VaultListManager {
 	private VaultSettings newVaultSettings(Path path) {
 		VaultSettings vaultSettings = VaultSettings.withRandomId();
 		vaultSettings.path.set(path);
-		vaultSettings.mountService.set(vaultSettings.mountService.getValue());
-		vaultSettings.port.set(vaultSettings.port.getValue());
 		if (path.getFileName() != null) {
 			vaultSettings.displayName.set(path.getFileName().toString());
 		} else {

+ 1 - 5
src/main/java/org/cryptomator/ui/preferences/VolumePreferencesController.java

@@ -3,13 +3,11 @@ package org.cryptomator.ui.preferences;
 import dagger.Lazy;
 import org.cryptomator.common.ObservableUtil;
 import org.cryptomator.common.settings.Settings;
-import org.cryptomator.common.vaults.VaultModule;
 import org.cryptomator.integrations.mount.MountCapability;
 import org.cryptomator.integrations.mount.MountService;
 import org.cryptomator.ui.common.FxController;
 
 import javax.inject.Inject;
-import javax.inject.Named;
 import javafx.application.Application;
 import javafx.beans.value.ObservableValue;
 import javafx.scene.control.ChoiceBox;
@@ -17,7 +15,6 @@ import javafx.util.StringConverter;
 import java.util.List;
 import java.util.Optional;
 import java.util.ResourceBundle;
-import java.util.concurrent.atomic.AtomicReference;
 
 @PreferencesScoped
 public class VolumePreferencesController implements FxController {
@@ -39,7 +36,6 @@ public class VolumePreferencesController implements FxController {
 	VolumePreferencesController(Settings settings,
 								Lazy<Application> application,
 								List<MountService> mountProviders,
-								@Named("FUPFMS") AtomicReference<MountService> firstUsedProblematicFuseMountService,
 								ResourceBundle resourceBundle) {
 		this.settings = settings;
 		this.application = application;
@@ -101,7 +97,7 @@ public class VolumePreferencesController implements FxController {
 
 	/* Helpers */
 
-	public class MountServiceConverter extends StringConverter<MountService> {
+	private class MountServiceConverter extends StringConverter<MountService> {
 
 		@Override
 		public String toString(MountService provider) {

+ 9 - 0
src/main/java/org/cryptomator/ui/unlock/UnlockFuseRestartRequiredController.java

@@ -8,22 +8,31 @@ import org.cryptomator.ui.vaultoptions.SelectedVaultOptionsTab;
 import javax.inject.Inject;
 import javafx.fxml.FXML;
 import javafx.stage.Stage;
+import java.util.ResourceBundle;
 
 @UnlockScoped
 public class UnlockFuseRestartRequiredController implements FxController {
 
 	private final Stage window;
+	private final ResourceBundle resourceBundle;
 	private final FxApplicationWindows appWindows;
 	private final Vault vault;
+
 	@Inject
 	UnlockFuseRestartRequiredController(@UnlockWindow Stage window,
+			ResourceBundle resourceBundle,
 			FxApplicationWindows appWindows,
 			@UnlockWindow Vault vault) {
 		this.window = window;
+		this.resourceBundle = resourceBundle;
 		this.appWindows = appWindows;
 		this.vault = vault;
 	}
 
+	public void initialize() {
+		window.setTitle(String.format(resourceBundle.getString("unlock.error.fuseRestartRequired.title"), vault.getDisplayName()));
+	}
+
 	@FXML
 	public void close() {
 		window.close();

+ 0 - 5
src/main/java/org/cryptomator/ui/unlock/UnlockWorkflow.java

@@ -23,7 +23,6 @@ import javafx.concurrent.Task;
 import javafx.scene.Scene;
 import javafx.stage.Stage;
 import java.io.IOException;
-import java.util.ResourceBundle;
 
 /**
  * A multi-step task that consists of background activities as well as user interaction.
@@ -36,7 +35,6 @@ public class UnlockWorkflow extends Task<Boolean> {
 	private static final Logger LOG = LoggerFactory.getLogger(UnlockWorkflow.class);
 
 	private final Stage window;
-	private final ResourceBundle resourceBundle;
 	private final Vault vault;
 	private final VaultService vaultService;
 	private final Lazy<Scene> successScene;
@@ -48,7 +46,6 @@ public class UnlockWorkflow extends Task<Boolean> {
 
 	@Inject
 	UnlockWorkflow(@UnlockWindow Stage window, //
-				   ResourceBundle resourceBundle,
 				   @UnlockWindow Vault vault, //
 				   VaultService vaultService, //
 				   @FxmlScene(FxmlFile.UNLOCK_SUCCESS) Lazy<Scene> successScene, //
@@ -58,7 +55,6 @@ public class UnlockWorkflow extends Task<Boolean> {
 				   @UnlockWindow KeyLoadingStrategy keyLoadingStrategy, //
 				   @UnlockWindow ObjectProperty<IllegalMountPointException> illegalMountPointException) {
 		this.window = window;
-		this.resourceBundle = resourceBundle;
 		this.vault = vault;
 		this.vaultService = vaultService;
 		this.successScene = successScene;
@@ -103,7 +99,6 @@ public class UnlockWorkflow extends Task<Boolean> {
 	private void handleFuseRestartRequiredError(FuseRestartRequiredException fRRE) {
 		Platform.runLater(() -> {
 			window.setScene(fuseRestartRequiredScene.get());
-			window.setTitle(String.format(resourceBundle.getString("unlock.error.fuseRestartRequired.title"), vault.getDisplayName()));
 			window.show();
 		});
 	}

+ 6 - 2
src/test/java/org/cryptomator/common/settings/SettingsTest.java

@@ -24,12 +24,16 @@ public class SettingsTest {
 		Mockito.verify(changeListener, Mockito.times(0)).accept(settings);
 
 		// first change (to property):
-		settings.directories.add(vaultSettings);
+		settings.windowXPosition.set(100);
 		Mockito.verify(changeListener, Mockito.times(1)).accept(settings);
 
 		// second change (to list):
-		vaultSettings.displayName.set("asd");
+		settings.directories.add(vaultSettings);
 		Mockito.verify(changeListener, Mockito.times(2)).accept(settings);
+
+		// third change (to property of list item):
+		vaultSettings.displayName.set("asd");
+		Mockito.verify(changeListener, Mockito.times(3)).accept(settings);
 	}
 
 }