Selaa lähdekoodia

removed MAC warning screen

Sebastian Stenzel 8 vuotta sitten
vanhempi
commit
4fb8a27a78

+ 0 - 165
main/ui/src/main/java/org/cryptomator/ui/controllers/MacWarningsController.java

@@ -1,165 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Sebastian Stenzel and others.
- * This file is licensed under the terms of the MIT license.
- * See the LICENSE.txt file for more info.
- *
- * Contributors:
- *     Sebastian Stenzel - initial API and implementation
- *******************************************************************************/
-package org.cryptomator.ui.controllers;
-
-import java.net.URL;
-import java.util.stream.Collectors;
-
-import javax.inject.Inject;
-
-import org.cryptomator.ui.model.Vault;
-import org.cryptomator.ui.settings.Localization;
-
-import javafx.application.Application;
-import javafx.beans.Observable;
-import javafx.beans.property.BooleanProperty;
-import javafx.beans.property.ObjectProperty;
-import javafx.beans.property.ReadOnlyStringWrapper;
-import javafx.beans.property.SimpleBooleanProperty;
-import javafx.beans.property.SimpleObjectProperty;
-import javafx.beans.value.ChangeListener;
-import javafx.beans.value.ObservableValue;
-import javafx.beans.value.WeakChangeListener;
-import javafx.collections.FXCollections;
-import javafx.collections.ListChangeListener;
-import javafx.collections.ListChangeListener.Change;
-import javafx.collections.ObservableList;
-import javafx.event.ActionEvent;
-import javafx.fxml.FXML;
-import javafx.scene.control.Button;
-import javafx.scene.control.ListView;
-import javafx.scene.control.cell.CheckBoxListCell;
-import javafx.stage.Stage;
-import javafx.util.StringConverter;
-
-public class MacWarningsController extends LocalizedFXMLViewController {
-
-	private final Application application;
-	private final ObservableList<Warning> warnings = FXCollections.observableArrayList();
-	private final ListChangeListener<String> unauthenticatedResourcesChangeListener = this::unauthenticatedResourcesDidChange;
-	private final ChangeListener<Boolean> stageVisibilityChangeListener = this::windowVisibilityDidChange;
-	final ObjectProperty<Vault> vault = new SimpleObjectProperty<>();
-	private Stage stage;
-
-	@Inject
-	public MacWarningsController(Application application, Localization localization) {
-		super(localization);
-		this.application = application;
-	}
-
-	@FXML
-	private ListView<Warning> warningsList;
-
-	@FXML
-	private Button whitelistButton;
-
-	@Override
-	public void initialize() {
-		warnings.addListener(this::warningsDidInvalidate);
-		warningsList.setItems(warnings);
-		warningsList.setCellFactory(CheckBoxListCell.forListView(Warning::selectedProperty, new StringConverter<Warning>() {
-
-			@Override
-			public String toString(Warning object) {
-				return object.getName();
-			}
-
-			@Override
-			public Warning fromString(String string) {
-				return null;
-			}
-
-		}));
-	}
-
-	@Override
-	protected URL getFxmlResourceUrl() {
-		return getClass().getResource("/fxml/mac_warnings.fxml");
-	}
-
-	@Override
-	public void initStage(Stage stage) {
-		super.initStage(stage);
-		this.stage = stage;
-		stage.showingProperty().addListener(new WeakChangeListener<>(stageVisibilityChangeListener));
-	}
-
-	@FXML
-	private void didClickWhitelistButton(ActionEvent event) {
-		warnings.filtered(w -> w.isSelected()).stream().forEach(w -> {
-			final String resourceToBeWhitelisted = w.getName();
-			vault.get().getWhitelistedResourcesWithInvalidMac().add(resourceToBeWhitelisted);
-			vault.get().getNamesOfResourcesWithInvalidMac().remove(resourceToBeWhitelisted);
-		});
-		warnings.removeIf(w -> w.isSelected());
-	}
-
-	@FXML
-	private void didClickMoreInformationButton(ActionEvent event) {
-		application.getHostServices().showDocument("https://cryptomator.freshdesk.com/support/solutions/articles/16000003666-what-does-mac-authentication-failed-mean-");
-	}
-
-	private void unauthenticatedResourcesDidChange(Change<? extends String> change) {
-		while (change.next()) {
-			if (change.wasAdded()) {
-				warnings.addAll(change.getAddedSubList().stream().map(Warning::new).collect(Collectors.toList()));
-			} else if (change.wasRemoved()) {
-				change.getRemoved().forEach(str -> {
-					warnings.removeIf(w -> str.equals(w.name.get()));
-				});
-			}
-		}
-	}
-
-	private void warningsDidInvalidate(Observable observable) {
-		disableWhitelistButtonIfNothingSelected();
-	}
-
-	private void windowVisibilityDidChange(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
-		if (Boolean.TRUE.equals(newValue)) {
-			stage.setTitle(String.format(localization.getString("macWarnings.windowTitle"), vault.get().name().getValue()));
-			warnings.addAll(vault.get().getNamesOfResourcesWithInvalidMac().stream().map(Warning::new).collect(Collectors.toList()));
-			vault.get().getNamesOfResourcesWithInvalidMac().addListener(this.unauthenticatedResourcesChangeListener);
-		} else {
-			vault.get().getNamesOfResourcesWithInvalidMac().clear();
-			vault.get().getNamesOfResourcesWithInvalidMac().removeListener(this.unauthenticatedResourcesChangeListener);
-		}
-	}
-
-	private void disableWhitelistButtonIfNothingSelected() {
-		whitelistButton.setDisable(warnings.filtered(w -> w.isSelected()).isEmpty());
-	}
-
-	private class Warning {
-
-		private final ReadOnlyStringWrapper name = new ReadOnlyStringWrapper();
-		private final BooleanProperty selected = new SimpleBooleanProperty(false);
-
-		public Warning(String name) {
-			this.name.set(name);
-			this.selectedProperty().addListener(change -> {
-				disableWhitelistButtonIfNothingSelected();
-			});
-		}
-
-		public String getName() {
-			return name.get();
-		}
-
-		public BooleanProperty selectedProperty() {
-			return selected;
-		}
-
-		public boolean isSelected() {
-			return selected.get();
-		}
-
-	}
-
-}

+ 1 - 38
main/ui/src/main/java/org/cryptomator/ui/controllers/UnlockedController.java

@@ -12,21 +12,17 @@ import java.net.URL;
 import java.util.Optional;
 
 import javax.inject.Inject;
-import javax.inject.Provider;
 
 import org.cryptomator.ui.model.Vault;
 import org.cryptomator.ui.settings.Localization;
-import org.cryptomator.ui.util.ActiveWindowStyleSupport;
 import org.cryptomator.ui.util.AsyncTaskService;
 import org.fxmisc.easybind.EasyBind;
 
 import javafx.animation.Animation;
 import javafx.animation.KeyFrame;
 import javafx.animation.Timeline;
-import javafx.application.Platform;
 import javafx.beans.property.ObjectProperty;
 import javafx.beans.property.SimpleObjectProperty;
-import javafx.collections.ListChangeListener;
 import javafx.event.ActionEvent;
 import javafx.event.EventHandler;
 import javafx.fxml.FXML;
@@ -42,7 +38,6 @@ import javafx.scene.control.ToggleButton;
 import javafx.scene.input.Clipboard;
 import javafx.scene.input.ClipboardContent;
 import javafx.stage.PopupWindow.AnchorLocation;
-import javafx.stage.Stage;
 import javafx.util.Duration;
 
 public class UnlockedController extends LocalizedFXMLViewController {
@@ -50,8 +45,6 @@ public class UnlockedController extends LocalizedFXMLViewController {
 	private static final int IO_SAMPLING_STEPS = 100;
 	private static final double IO_SAMPLING_INTERVAL = 0.25;
 
-	private final Stage macWarningsWindow = new Stage();
-	private final MacWarningsController macWarningsController;
 	private final AsyncTaskService asyncTaskService;
 	private final ObjectProperty<Vault> vault = new SimpleObjectProperty<>();
 	private Optional<LockListener> listener = Optional.empty();
@@ -76,19 +69,13 @@ public class UnlockedController extends LocalizedFXMLViewController {
 	private MenuItem revealVaultMenuItem;
 
 	@Inject
-	public UnlockedController(Localization localization, Provider<MacWarningsController> macWarningsControllerProvider, AsyncTaskService asyncTaskService) {
+	public UnlockedController(Localization localization, AsyncTaskService asyncTaskService) {
 		super(localization);
-		this.macWarningsController = macWarningsControllerProvider.get();
 		this.asyncTaskService = asyncTaskService;
-
-		macWarningsController.vault.bind(this.vault);
 	}
 
 	@Override
 	public void initialize() {
-		macWarningsController.initStage(macWarningsWindow);
-		ActiveWindowStyleSupport.startObservingFocus(macWarningsWindow);
-
 		revealVaultMenuItem.disableProperty().bind(EasyBind.map(vault, vault -> vault != null && !vault.isMounted()));
 
 		EasyBind.subscribe(vault, this::vaultChanged);
@@ -105,18 +92,6 @@ public class UnlockedController extends LocalizedFXMLViewController {
 			return;
 		}
 
-		// listen to MAC warnings as long as this vault is unlocked:
-		// TODO overheadhunter: reimplement eventually
-		/*
-		 * final ListChangeListener<String> macWarningsListener = this::macWarningsDidChange;
-		 * newVault.getNamesOfResourcesWithInvalidMac().addListener(macWarningsListener);
-		 * newVault.unlockedProperty().addListener((observable, oldValue, newValue) -> {
-		 * if (Boolean.FALSE.equals(newValue)) {
-		 * newVault.getNamesOfResourcesWithInvalidMac().removeListener(macWarningsListener);
-		 * }
-		 * });
-		 */
-
 		if (!vault.get().isMounted()) {
 			// TODO Markus Kreusch #393: hyperlink auf FAQ oder sowas?
 			messageLabel.setText(localization.getString("unlocked.label.mountFailed"));
@@ -166,18 +141,6 @@ public class UnlockedController extends LocalizedFXMLViewController {
 		Clipboard.getSystemClipboard().setContent(clipboardContent);
 	}
 
-	// ****************************************
-	// MAC Auth Warnings
-	// ****************************************
-
-	private void macWarningsDidChange(ListChangeListener.Change<? extends String> change) {
-		if (change.getList().size() > 0) {
-			Platform.runLater(macWarningsWindow::show);
-		} else {
-			Platform.runLater(macWarningsWindow::hide);
-		}
-	}
-
 	// ****************************************
 	// IO Graph
 	// ****************************************

+ 0 - 6
main/ui/src/main/resources/localization/en.txt

@@ -95,12 +95,6 @@ unlocked.label.statsEncrypted=encrypted
 unlocked.label.statsDecrypted=decrypted
 unlocked.ioGraph.yAxis.label=Throughput (MiB/s)
 
-# mac_warnings.fxml
-macWarnings.windowTitle=Danger - Corrupted file in %s
-macWarnings.message=Cryptomator detected potentially malicious corruptions in the following files:
-macWarnings.moreInformationButton=Learn More
-macWarnings.whitelistButton=Decrypt Selected Anyway
-
 # settings.fxml
 settings.version.label=Version %s
 settings.checkForUpdates.label=Check for Updates