From 1bef4e786d4708e17f1e16db22296dbb93604f10 Mon Sep 17 00:00:00 2001 From: Sebastian Stenzel Date: Sun, 4 Oct 2015 15:38:41 +0200 Subject: [PATCH] - Fixed "return" key in unlock view - Fixed password field focus - Don't show unlock error messages from one vault, when switching to another vault - Hide advanced mount options by default (preparation for things like #74) --- main/pom.xml | 4 +- .../ui/controllers/UnlockController.java | 49 +++++++++++++----- .../ui/controls/SecPasswordField.java | 14 +++--- .../ui/src/main/resources/css/linux_theme.css | 16 ++++++ main/ui/src/main/resources/css/mac_theme.css | 16 ++++++ main/ui/src/main/resources/css/win_theme.css | 16 ++++++ main/ui/src/main/resources/fxml/unlock.fxml | 50 +++++++++++++++---- main/ui/src/main/resources/fxml/unlocked.fxml | 2 +- .../main/resources/localization.properties | 3 ++ 9 files changed, 138 insertions(+), 32 deletions(-) diff --git a/main/pom.xml b/main/pom.xml index 43f6ebba3..c42e59907 100644 --- a/main/pom.xml +++ b/main/pom.xml @@ -129,12 +129,12 @@ com.google.dagger dagger - 2.0 + 2.0.1 com.google.dagger dagger-compiler - 2.0 + 2.0.1 provided diff --git a/main/ui/src/main/java/org/cryptomator/ui/controllers/UnlockController.java b/main/ui/src/main/java/org/cryptomator/ui/controllers/UnlockController.java index feda4a833..d44d0f4eb 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/controllers/UnlockController.java +++ b/main/ui/src/main/java/org/cryptomator/ui/controllers/UnlockController.java @@ -42,6 +42,7 @@ import javafx.scene.control.Hyperlink; import javafx.scene.control.ProgressIndicator; import javafx.scene.control.TextField; import javafx.scene.input.KeyEvent; +import javafx.scene.layout.GridPane; import javafx.scene.text.Text; public class UnlockController extends AbstractFXMLViewController { @@ -57,6 +58,9 @@ public class UnlockController extends AbstractFXMLViewController { @FXML private TextField mountName; + @FXML + private Button advancedOptionsButton; + @FXML private Button unlockButton; @@ -69,6 +73,9 @@ public class UnlockController extends AbstractFXMLViewController { @FXML private Hyperlink downloadsPageLink; + @FXML + private GridPane advancedOptions; + private final ExecutorService exec; private final Application app; @@ -93,6 +100,17 @@ public class UnlockController extends AbstractFXMLViewController { passwordField.textProperty().addListener(this::passwordFieldsDidChange); mountName.addEventFilter(KeyEvent.KEY_TYPED, this::filterAlphanumericKeyEvents); mountName.textProperty().addListener(this::mountNameDidChange); + advancedOptions.managedProperty().bind(advancedOptions.visibleProperty()); + } + + private void resetView() { + unlockButton.setDisable(true); + advancedOptions.setVisible(false); + advancedOptionsButton.setText(resourceBundle.getString("unlock.button.advancedOptions.show")); + progressIndicator.setVisible(false); + passwordField.clear(); + downloadsPageLink.setVisible(false); + messageText.setText(null); } // **************************************** @@ -113,6 +131,20 @@ public class UnlockController extends AbstractFXMLViewController { app.getHostServices().showDocument("https://cryptomator.org/downloads/"); } + // **************************************** + // Advanced options button + // **************************************** + + @FXML + private void didClickAdvancedOptionsButton(ActionEvent event) { + advancedOptions.setVisible(!advancedOptions.isVisible()); + if (advancedOptions.isVisible()) { + advancedOptionsButton.setText(resourceBundle.getString("unlock.button.advancedOptions.hide")); + } else { + advancedOptionsButton.setText(resourceBundle.getString("unlock.button.advancedOptions.show")); + } + } + // **************************************** // Unlock button // **************************************** @@ -138,23 +170,14 @@ public class UnlockController extends AbstractFXMLViewController { final Future futureMount = exec.submit(() -> (boolean) vault.mount()); FXThreads.runOnMainThreadWhenFinished(exec, futureMount, this::unlockAndMountFinished); } catch (IOException ex) { - setControlsDisabled(false); - progressIndicator.setVisible(false); messageText.setText(resourceBundle.getString("unlock.errorMessage.decryptionFailed")); LOG.error("Decryption failed for technical reasons.", ex); } catch (WrongPasswordException e) { - setControlsDisabled(false); - progressIndicator.setVisible(false); messageText.setText(resourceBundle.getString("unlock.errorMessage.wrongPassword")); - Platform.runLater(passwordField::requestFocus); } catch (UnsupportedKeyLengthException ex) { - setControlsDisabled(false); - progressIndicator.setVisible(false); messageText.setText(resourceBundle.getString("unlock.errorMessage.unsupportedKeyLengthInstallJCE")); LOG.warn("Unsupported Key-Length. Please install Oracle Java Cryptography Extension (JCE).", ex); } catch (UnsupportedVaultException e) { - setControlsDisabled(false); - progressIndicator.setVisible(false); downloadsPageLink.setVisible(true); if (e.isVaultOlderThanSoftware()) { messageText.setText(resourceBundle.getString("unlock.errorMessage.unsupportedVersion.vaultOlderThanSoftware") + " "); @@ -162,11 +185,12 @@ public class UnlockController extends AbstractFXMLViewController { messageText.setText(resourceBundle.getString("unlock.errorMessage.unsupportedVersion.softwareOlderThanVault") + " "); } } catch (DestroyFailedException e) { - setControlsDisabled(false); - progressIndicator.setVisible(false); LOG.error("Destruction of cryptor threw an exception.", e); } finally { + setControlsDisabled(false); + progressIndicator.setVisible(false); passwordField.swipe(); + Platform.runLater(passwordField::requestFocus); } } @@ -174,6 +198,7 @@ public class UnlockController extends AbstractFXMLViewController { passwordField.setDisable(disable); mountName.setDisable(disable); unlockButton.setDisable(disable); + advancedOptionsButton.setDisable(disable); } private void unlockAndMountFinished(boolean mountSuccess) { @@ -214,9 +239,9 @@ public class UnlockController extends AbstractFXMLViewController { } public void setVault(Vault vault) { + this.resetView(); this.vault = vault; this.mountName.setText(vault.getMountName()); - this.passwordField.clear(); } public UnlockListener getListener() { diff --git a/main/ui/src/main/java/org/cryptomator/ui/controls/SecPasswordField.java b/main/ui/src/main/java/org/cryptomator/ui/controls/SecPasswordField.java index 14f7f6391..4615c384f 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/controls/SecPasswordField.java +++ b/main/ui/src/main/java/org/cryptomator/ui/controls/SecPasswordField.java @@ -16,18 +16,18 @@ import javafx.scene.control.PasswordField; * Compromise in security. While the text can be swiped, any access to the {@link #getText()} method will create a copy of the String in the heap. */ public class SecPasswordField extends PasswordField { - + private static final char SWIPE_CHAR = ' '; - + /** * {@link #getContent()} uses a StringBuilder, which in turn is backed by a char[]. * The delete operation of AbstractStringBuilder closes the gap, that forms by deleting chars, by moving up the following chars. *
* Imagine the following example with pass being the password, x being the swipe char and ' being the offset of the char array: *
    - *
  1. Append filling chars to the end of the password: passxxxx'
  2. - *
  3. Delete first 4 chars. Internal implementation will then copy the following chars to the position, where the deletion occured: xxxx'xxxx
  4. - *
  5. Delete first 4 chars again, as we appended 4 chars in step 1: 'xxxxxx
  6. + *
  7. Append filling chars to the end of the password: passxxxx'
  8. + *
  9. Delete first 4 chars. Internal implementation will then copy the following chars to the position, where the deletion occured: xxxx'xxxx
  10. + *
  11. Delete first 4 chars again, as we appended 4 chars in step 1: 'xxxxxx
  12. *
*/ public void swipe() { @@ -37,8 +37,8 @@ public class SecPasswordField extends PasswordField { this.getContent().insert(pwLength, new String(fillingChars), false); this.getContent().delete(0, pwLength, true); this.getContent().delete(0, pwLength, true); + // previous text has now been overwritten. still we need to update the text to trigger some property bindings: + this.setText(""); } - - } diff --git a/main/ui/src/main/resources/css/linux_theme.css b/main/ui/src/main/resources/css/linux_theme.css index c465f6548..eb749aaa4 100644 --- a/main/ui/src/main/resources/css/linux_theme.css +++ b/main/ui/src/main/resources/css/linux_theme.css @@ -225,6 +225,22 @@ -fx-font-size: 0.8em; } +/**************************************************************************** + * * + * Separator * + * * + ****************************************************************************/ + +.separator .line { + -fx-border-style: solid; + -fx-border-width: 1px; + -fx-background-color: null; +} + +.separator:horizontal .line { + -fx-border-color: COLOR_BORDER transparent transparent transparent; +} + /**************************************************************************** * * * CheckBox * diff --git a/main/ui/src/main/resources/css/mac_theme.css b/main/ui/src/main/resources/css/mac_theme.css index 7f74cc715..4e77e2453 100644 --- a/main/ui/src/main/resources/css/mac_theme.css +++ b/main/ui/src/main/resources/css/mac_theme.css @@ -291,6 +291,22 @@ -fx-font-size: 0.8em; } +/**************************************************************************** + * * + * Separator * + * * + ****************************************************************************/ + +.separator .line { + -fx-border-style: solid; + -fx-border-width: 1px; + -fx-background-color: null; +} + +.separator:horizontal .line { + -fx-border-color: COLOR_BORDER transparent transparent transparent; +} + /******************************************************************************* * * * CheckBox * diff --git a/main/ui/src/main/resources/css/win_theme.css b/main/ui/src/main/resources/css/win_theme.css index cd27cc895..f0bbcf280 100644 --- a/main/ui/src/main/resources/css/win_theme.css +++ b/main/ui/src/main/resources/css/win_theme.css @@ -281,6 +281,22 @@ -fx-font-size: 0.9em; } +/**************************************************************************** + * * + * Separator * + * * + ****************************************************************************/ + +.separator .line { + -fx-border-style: solid; + -fx-border-width: 1px; + -fx-background-color: null; +} + +.separator:horizontal .line { + -fx-border-color: COLOR_BORDER transparent transparent transparent; +} + /******************************************************************************* * * * CheckBox * diff --git a/main/ui/src/main/resources/fxml/unlock.fxml b/main/ui/src/main/resources/fxml/unlock.fxml index 8944d2518..05d2cc15c 100644 --- a/main/ui/src/main/resources/fxml/unlock.fxml +++ b/main/ui/src/main/resources/fxml/unlock.fxml @@ -21,6 +21,8 @@ + + @@ -36,24 +38,52 @@