mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-08-18 13:16:02 +00:00
configurable mount + reveal during unlock, preparation for #452 and #143 (still needs a little refactoring, though)
This commit is contained in:
@@ -85,9 +85,15 @@ public class UnlockController extends LocalizedFXMLViewController {
|
||||
@FXML
|
||||
private CheckBox savePassword;
|
||||
|
||||
@FXML
|
||||
private CheckBox mountAfterUnlock;
|
||||
|
||||
@FXML
|
||||
private TextField mountName;
|
||||
|
||||
@FXML
|
||||
private CheckBox revealAfterMount;
|
||||
|
||||
@FXML
|
||||
private Label winDriveLetterLabel;
|
||||
|
||||
@@ -110,6 +116,8 @@ public class UnlockController extends LocalizedFXMLViewController {
|
||||
public void initialize() {
|
||||
advancedOptions.managedProperty().bind(advancedOptions.visibleProperty());
|
||||
unlockButton.disableProperty().bind(passwordField.textProperty().isEmpty());
|
||||
mountName.disableProperty().bind(mountAfterUnlock.selectedProperty().not());
|
||||
revealAfterMount.disableProperty().bind(mountAfterUnlock.selectedProperty().not());
|
||||
mountName.addEventFilter(KeyEvent.KEY_TYPED, this::filterAlphanumericKeyEvents);
|
||||
mountName.textProperty().addListener(this::mountNameDidChange);
|
||||
savePassword.setDisable(!keychainAccess.isPresent());
|
||||
@@ -129,6 +137,11 @@ public class UnlockController extends LocalizedFXMLViewController {
|
||||
}
|
||||
|
||||
void setVault(Vault vault) {
|
||||
// TODO overheadhunter refactor
|
||||
if (this.vault != null) {
|
||||
this.vault.getVaultSettings().mountAfterUnlock().unbind();
|
||||
this.vault.getVaultSettings().revealAfterMount().unbind();
|
||||
}
|
||||
// trigger "default" change to refresh key bindings:
|
||||
unlockButton.setDefaultButton(false);
|
||||
unlockButton.setDefaultButton(true);
|
||||
@@ -165,6 +178,10 @@ public class UnlockController extends LocalizedFXMLViewController {
|
||||
Arrays.fill(storedPw, ' ');
|
||||
}
|
||||
}
|
||||
mountAfterUnlock.setSelected(this.vault.getVaultSettings().mountAfterUnlock().get());
|
||||
revealAfterMount.setSelected(this.vault.getVaultSettings().revealAfterMount().get());
|
||||
this.vault.getVaultSettings().mountAfterUnlock().bind(mountAfterUnlock.selectedProperty());
|
||||
this.vault.getVaultSettings().revealAfterMount().bind(revealAfterMount.selectedProperty());
|
||||
}
|
||||
|
||||
// ****************************************
|
||||
@@ -318,8 +335,12 @@ public class UnlockController extends LocalizedFXMLViewController {
|
||||
private void unlock(CharSequence password) {
|
||||
try {
|
||||
vault.unlock(password);
|
||||
vault.mount();
|
||||
vault.reveal();
|
||||
if (mountAfterUnlock.isSelected()) {
|
||||
vault.mount();
|
||||
if (revealAfterMount.isSelected()) {
|
||||
vault.reveal();
|
||||
}
|
||||
}
|
||||
Platform.runLater(() -> {
|
||||
messageText.setText(null);
|
||||
listener.ifPresent(lstnr -> lstnr.didUnlock(vault));
|
||||
|
||||
@@ -50,12 +50,12 @@ public class ConfigurableFileAppender extends AbstractOutputStreamAppender<FileM
|
||||
public static AbstractAppender createAppender(@PluginAttribute("name") final String name, @PluginAttribute("pathPropertyName") final String pathPropertyName, @PluginAttribute("append") final String append,
|
||||
@PluginElement("Layout") Layout<? extends Serializable> layout) {
|
||||
if (name == null) {
|
||||
LOGGER.error("No name provided for HomeDirectoryAwareFileAppender");
|
||||
LOGGER.error("No name provided for ConfigurableFileAppender");
|
||||
return null;
|
||||
}
|
||||
|
||||
if (pathPropertyName == null) {
|
||||
LOGGER.error("No pathPropertyName provided for HomeDirectoryAwareFileAppender with name " + name);
|
||||
LOGGER.error("No pathPropertyName provided for ConfigurableFileAppender with name " + name);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,9 @@ import java.util.UUID;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.fxmisc.easybind.EasyBind;
|
||||
|
||||
import javafx.beans.property.BooleanProperty;
|
||||
import javafx.beans.property.ObjectProperty;
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
import javafx.beans.property.SimpleObjectProperty;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.property.StringProperty;
|
||||
@@ -28,6 +30,8 @@ public class VaultSettings {
|
||||
private final ObjectProperty<Path> path = new SimpleObjectProperty<>();
|
||||
private final StringProperty mountName = new SimpleStringProperty();
|
||||
private final StringProperty winDriveLetter = new SimpleStringProperty();
|
||||
private final BooleanProperty mountAfterUnlock = new SimpleBooleanProperty();
|
||||
private final BooleanProperty revealAfterMount = new SimpleBooleanProperty();
|
||||
|
||||
public VaultSettings(Settings settings, String id) {
|
||||
this.settings = settings;
|
||||
@@ -37,6 +41,7 @@ public class VaultSettings {
|
||||
path.addListener(this::somethingChanged);
|
||||
mountName.addListener(this::somethingChanged);
|
||||
winDriveLetter.addListener(this::somethingChanged);
|
||||
mountAfterUnlock.addListener(this::somethingChanged);
|
||||
}
|
||||
|
||||
private void somethingChanged(ObservableValue<?> observable, Object oldValue, Object newValue) {
|
||||
@@ -107,6 +112,14 @@ public class VaultSettings {
|
||||
return winDriveLetter;
|
||||
}
|
||||
|
||||
public BooleanProperty mountAfterUnlock() {
|
||||
return mountAfterUnlock;
|
||||
}
|
||||
|
||||
public BooleanProperty revealAfterMount() {
|
||||
return revealAfterMount;
|
||||
}
|
||||
|
||||
/* Hashcode/Equals */
|
||||
|
||||
@Override
|
||||
|
||||
@@ -24,6 +24,8 @@ class VaultSettingsJsonAdapter {
|
||||
out.name("path").value(value.path().get().toString());
|
||||
out.name("mountName").value(value.mountName().get());
|
||||
out.name("winDriveLetter").value(value.winDriveLetter().get());
|
||||
out.name("mountAfterUnlock").value(value.mountAfterUnlock().get());
|
||||
out.name("revealAfterMount").value(value.revealAfterMount().get());
|
||||
out.endObject();
|
||||
}
|
||||
|
||||
@@ -32,6 +34,8 @@ class VaultSettingsJsonAdapter {
|
||||
String path = null;
|
||||
String mountName = null;
|
||||
String winDriveLetter = null;
|
||||
boolean mountAfterUnlock = true;
|
||||
boolean revealAfterMount = true;
|
||||
|
||||
in.beginObject();
|
||||
while (in.hasNext()) {
|
||||
@@ -49,6 +53,12 @@ class VaultSettingsJsonAdapter {
|
||||
case "winDriveLetter":
|
||||
winDriveLetter = in.nextString();
|
||||
break;
|
||||
case "mountAfterUnlock":
|
||||
mountAfterUnlock = in.nextBoolean();
|
||||
break;
|
||||
case "revealAfterMount":
|
||||
revealAfterMount = in.nextBoolean();
|
||||
break;
|
||||
default:
|
||||
LOG.warn("Unsupported vault setting found in JSON: " + name);
|
||||
in.skipValue();
|
||||
@@ -60,6 +70,8 @@ class VaultSettingsJsonAdapter {
|
||||
vaultSettings.mountName().set(mountName);
|
||||
vaultSettings.path().set(Paths.get(path));
|
||||
vaultSettings.winDriveLetter().set(winDriveLetter);
|
||||
vaultSettings.mountAfterUnlock().set(mountAfterUnlock);
|
||||
vaultSettings.revealAfterMount().set(revealAfterMount);
|
||||
return vaultSettings;
|
||||
}
|
||||
|
||||
|
||||
@@ -72,12 +72,20 @@
|
||||
<CheckBox GridPane.rowIndex="1" GridPane.columnIndex="1" fx:id="savePassword" onAction="#didClickSavePasswordCheckbox" cacheShape="true" cache="true" />
|
||||
|
||||
<!-- Row 3.2 -->
|
||||
<Label GridPane.rowIndex="2" GridPane.columnIndex="0" text="%unlock.label.mountName" cacheShape="true" cache="true" />
|
||||
<TextField GridPane.rowIndex="2" GridPane.columnIndex="1" fx:id="mountName" GridPane.hgrow="ALWAYS" maxWidth="Infinity" cacheShape="true" cache="true" />
|
||||
<Label GridPane.rowIndex="2" GridPane.columnIndex="0" text="%unlock.label.mountAfterUnlock" cacheShape="true" cache="true" />
|
||||
<CheckBox GridPane.rowIndex="2" GridPane.columnIndex="1" fx:id="mountAfterUnlock" cacheShape="true" cache="true" />
|
||||
|
||||
<!-- Row 3.3 -->
|
||||
<Label GridPane.rowIndex="3" GridPane.columnIndex="0" fx:id="winDriveLetterLabel" text="%unlock.label.winDriveLetter" cacheShape="true" cache="true" />
|
||||
<ChoiceBox GridPane.rowIndex="3" GridPane.columnIndex="1" fx:id="winDriveLetter" GridPane.hgrow="ALWAYS" maxWidth="Infinity" cacheShape="true" cache="true" />
|
||||
<Label GridPane.rowIndex="3" GridPane.columnIndex="0" text="%unlock.label.mountName" cacheShape="true" cache="true" />
|
||||
<TextField GridPane.rowIndex="3" GridPane.columnIndex="1" fx:id="mountName" GridPane.hgrow="ALWAYS" maxWidth="Infinity" cacheShape="true" cache="true" />
|
||||
|
||||
<!-- Row 3.4 -->
|
||||
<Label GridPane.rowIndex="4" GridPane.columnIndex="0" text="%unlock.label.revealAfterMount" cacheShape="true" cache="true" />
|
||||
<CheckBox GridPane.rowIndex="4" GridPane.columnIndex="1" fx:id="revealAfterMount" cacheShape="true" cache="true" />
|
||||
|
||||
<!-- Row 3.5 -->
|
||||
<Label GridPane.rowIndex="5" GridPane.columnIndex="0" fx:id="winDriveLetterLabel" text="%unlock.label.winDriveLetter" cacheShape="true" cache="true" />
|
||||
<ChoiceBox GridPane.rowIndex="5" GridPane.columnIndex="1" fx:id="winDriveLetter" GridPane.hgrow="ALWAYS" maxWidth="Infinity" cacheShape="true" cache="true" />
|
||||
</GridPane>
|
||||
|
||||
<!-- Row 4 -->
|
||||
|
||||
@@ -57,7 +57,9 @@ upgrade.version4to5.err.io=Migration failed due to an I/O Exception. See log fil
|
||||
# unlock.fxml
|
||||
unlock.label.password=Password
|
||||
unlock.label.savePassword=Save Password
|
||||
unlock.label.mountAfterUnlock=Mount Drive
|
||||
unlock.label.mountName=Drive Name
|
||||
unlock.label.revealAfterMount=Reveal Drive
|
||||
unlock.label.winDriveLetter=Drive Letter
|
||||
unlock.label.downloadsPageLink=All Cryptomator versions
|
||||
unlock.label.advancedHeading=Advanced Options
|
||||
|
||||
Reference in New Issue
Block a user