From 06910ad1f448a5f2a031a183fa4e8cf7066ab127 Mon Sep 17 00:00:00 2001 From: Sebastian Stenzel Date: Mon, 23 May 2016 12:11:45 +0200 Subject: [PATCH] fixes #229 --- .../ui/controllers/ChangePasswordController.java | 15 +++++---------- .../ui/controllers/InitializeController.java | 15 +++++---------- .../cryptomator/ui/util/PasswordStrengthUtil.java | 6 +++++- .../src/main/resources/fxml/change_password.fxml | 13 ++++++++----- main/ui/src/main/resources/fxml/initialize.fxml | 11 +++++++---- main/ui/src/main/resources/localization/en.txt | 5 +---- 6 files changed, 31 insertions(+), 34 deletions(-) diff --git a/main/ui/src/main/java/org/cryptomator/ui/controllers/ChangePasswordController.java b/main/ui/src/main/java/org/cryptomator/ui/controllers/ChangePasswordController.java index 5944cf999..a8e5f31b8 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/controllers/ChangePasswordController.java +++ b/main/ui/src/main/java/org/cryptomator/ui/controllers/ChangePasswordController.java @@ -104,16 +104,11 @@ public class ChangePasswordController extends LocalizedFXMLViewController { changePasswordButton.disableProperty().bind(oldPasswordIsEmpty.or(newPasswordIsEmpty.or(passwordsDiffer))); passwordStrength.bind(EasyBind.map(newPasswordField.textProperty(), strengthRater::computeRate)); - passwordStrengthLevel0.visibleProperty().bind(passwordStrength.greaterThanOrEqualTo(0)); - passwordStrengthLevel1.visibleProperty().bind(passwordStrength.greaterThanOrEqualTo(1)); - passwordStrengthLevel2.visibleProperty().bind(passwordStrength.greaterThanOrEqualTo(2)); - passwordStrengthLevel3.visibleProperty().bind(passwordStrength.greaterThanOrEqualTo(3)); - passwordStrengthLevel4.visibleProperty().bind(passwordStrength.greaterThanOrEqualTo(4)); - passwordStrengthLevel0.backgroundProperty().bind(EasyBind.map(passwordStrength, strengthRater::getBackgroundWithStrengthColor)); - passwordStrengthLevel1.backgroundProperty().bind(EasyBind.map(passwordStrength, strengthRater::getBackgroundWithStrengthColor)); - passwordStrengthLevel2.backgroundProperty().bind(EasyBind.map(passwordStrength, strengthRater::getBackgroundWithStrengthColor)); - passwordStrengthLevel3.backgroundProperty().bind(EasyBind.map(passwordStrength, strengthRater::getBackgroundWithStrengthColor)); - passwordStrengthLevel4.backgroundProperty().bind(EasyBind.map(passwordStrength, strengthRater::getBackgroundWithStrengthColor)); + passwordStrengthLevel0.backgroundProperty().bind(EasyBind.combine(passwordStrength, new SimpleIntegerProperty(0), strengthRater::getBackgroundWithStrengthColor)); + passwordStrengthLevel1.backgroundProperty().bind(EasyBind.combine(passwordStrength, new SimpleIntegerProperty(1), strengthRater::getBackgroundWithStrengthColor)); + passwordStrengthLevel2.backgroundProperty().bind(EasyBind.combine(passwordStrength, new SimpleIntegerProperty(2), strengthRater::getBackgroundWithStrengthColor)); + passwordStrengthLevel3.backgroundProperty().bind(EasyBind.combine(passwordStrength, new SimpleIntegerProperty(3), strengthRater::getBackgroundWithStrengthColor)); + passwordStrengthLevel4.backgroundProperty().bind(EasyBind.combine(passwordStrength, new SimpleIntegerProperty(4), strengthRater::getBackgroundWithStrengthColor)); passwordStrengthLabel.textProperty().bind(EasyBind.map(passwordStrength, strengthRater::getStrengthDescription)); } diff --git a/main/ui/src/main/java/org/cryptomator/ui/controllers/InitializeController.java b/main/ui/src/main/java/org/cryptomator/ui/controllers/InitializeController.java index 96016aa55..d4f42371b 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/controllers/InitializeController.java +++ b/main/ui/src/main/java/org/cryptomator/ui/controllers/InitializeController.java @@ -91,16 +91,11 @@ public class InitializeController extends LocalizedFXMLViewController { okButton.disableProperty().bind(passwordIsEmpty.or(passwordsDiffer)); passwordStrength.bind(EasyBind.map(passwordField.textProperty(), strengthRater::computeRate)); - passwordStrengthLevel0.visibleProperty().bind(passwordStrength.greaterThanOrEqualTo(0)); - passwordStrengthLevel1.visibleProperty().bind(passwordStrength.greaterThanOrEqualTo(1)); - passwordStrengthLevel2.visibleProperty().bind(passwordStrength.greaterThanOrEqualTo(2)); - passwordStrengthLevel3.visibleProperty().bind(passwordStrength.greaterThanOrEqualTo(3)); - passwordStrengthLevel4.visibleProperty().bind(passwordStrength.greaterThanOrEqualTo(4)); - passwordStrengthLevel0.backgroundProperty().bind(EasyBind.map(passwordStrength, strengthRater::getBackgroundWithStrengthColor)); - passwordStrengthLevel1.backgroundProperty().bind(EasyBind.map(passwordStrength, strengthRater::getBackgroundWithStrengthColor)); - passwordStrengthLevel2.backgroundProperty().bind(EasyBind.map(passwordStrength, strengthRater::getBackgroundWithStrengthColor)); - passwordStrengthLevel3.backgroundProperty().bind(EasyBind.map(passwordStrength, strengthRater::getBackgroundWithStrengthColor)); - passwordStrengthLevel4.backgroundProperty().bind(EasyBind.map(passwordStrength, strengthRater::getBackgroundWithStrengthColor)); + passwordStrengthLevel0.backgroundProperty().bind(EasyBind.combine(passwordStrength, new SimpleIntegerProperty(0), strengthRater::getBackgroundWithStrengthColor)); + passwordStrengthLevel1.backgroundProperty().bind(EasyBind.combine(passwordStrength, new SimpleIntegerProperty(1), strengthRater::getBackgroundWithStrengthColor)); + passwordStrengthLevel2.backgroundProperty().bind(EasyBind.combine(passwordStrength, new SimpleIntegerProperty(2), strengthRater::getBackgroundWithStrengthColor)); + passwordStrengthLevel3.backgroundProperty().bind(EasyBind.combine(passwordStrength, new SimpleIntegerProperty(3), strengthRater::getBackgroundWithStrengthColor)); + passwordStrengthLevel4.backgroundProperty().bind(EasyBind.combine(passwordStrength, new SimpleIntegerProperty(4), strengthRater::getBackgroundWithStrengthColor)); passwordStrengthLabel.textProperty().bind(EasyBind.map(passwordStrength, strengthRater::getStrengthDescription)); } diff --git a/main/ui/src/main/java/org/cryptomator/ui/util/PasswordStrengthUtil.java b/main/ui/src/main/java/org/cryptomator/ui/util/PasswordStrengthUtil.java index b2871a9b3..300cee4e1 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/util/PasswordStrengthUtil.java +++ b/main/ui/src/main/java/org/cryptomator/ui/util/PasswordStrengthUtil.java @@ -61,7 +61,7 @@ public class PasswordStrengthUtil { case 4: return Color.web("#27ae60"); default: - return Color.TRANSPARENT; + return Color.web("#ffffff", 0.5); } } @@ -71,6 +71,10 @@ public class PasswordStrengthUtil { return new Background(fill); } + public Background getBackgroundWithStrengthColor(Number score, Number threshold) { + return score.intValue() >= threshold.intValue() ? getBackgroundWithStrengthColor(score) : getBackgroundWithStrengthColor(-1); + } + public String getStrengthDescription(Number score) { String key = "initialize.messageLabel.passwordStrength." + score.intValue(); if (localization.containsKey(key)) { diff --git a/main/ui/src/main/resources/fxml/change_password.fxml b/main/ui/src/main/resources/fxml/change_password.fxml index 44d985526..723bcb5bd 100644 --- a/main/ui/src/main/resources/fxml/change_password.fxml +++ b/main/ui/src/main/resources/fxml/change_password.fxml @@ -57,14 +57,17 @@ -