Skip to content

Commit 9b7c14a

Browse files
committed
Implemented #23 idea requsted by @Kubis10 and fixed minor ux bugs
1 parent bcdddff commit 9b7c14a

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
lines changed

src/main/java/me/goral/keepmypassworddesktop/controllers/MainAppController.java

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
import static me.goral.keepmypassworddesktop.util.AlertsUtil.showErrorDialog;
2828
import static me.goral.keepmypassworddesktop.util.ConfUtil.createConfFiles;
29+
import static me.goral.keepmypassworddesktop.util.PasswordGeneratorUtil.checkPasswordComplexity;
2930

3031
public class MainAppController {
3132

@@ -79,11 +80,22 @@ protected void onLoginButtonClick() {
7980
username.setPromptText("Username");
8081
PasswordField password = new PasswordField();
8182
password.setPromptText("Password");
83+
Label pwdCheck = new Label("No password");
84+
pwdCheck.setTextFill(Color.web("#b3b3b3"));
85+
86+
password.textProperty().addListener((observable, oldValue, newValue) -> {
87+
Pair<String, Color> res = checkPasswordComplexity(newValue);
88+
pwdCheck.setText(res.getKey());
89+
pwdCheck.setTextFill(res.getValue());
90+
});
8291

8392
grid.add(new Label("Username"), 0, 0);
8493
grid.add(username, 1, 0);
8594
grid.add(new Label("Password"), 0, 1);
8695
grid.add(password, 1, 1);
96+
if (!login) {
97+
grid.add(pwdCheck, 1, 2);
98+
}
8799

88100
username.textProperty().addListener(((observableValue, oldV, newV) -> regBtn.setDisable(newV.trim().isEmpty())));
89101

@@ -96,7 +108,7 @@ protected void onLoginButtonClick() {
96108
String newUname = username.getText();
97109
String newPwd = password.getText();
98110

99-
Pair<String, Color> checker = PasswordGeneratorUtil.checkPasswordComplexity(newPwd);
111+
Pair<String, Color> checker = checkPasswordComplexity(newPwd);
100112

101113
if (password.getText().isEmpty() && !login){
102114
AlertsUtil.showErrorDialog("Error", "There is a problem.", "You can't register with empty password.");
@@ -219,11 +231,23 @@ protected void onLoginButtonClick(String unameString, String passwordString) {
219231
username.setText(unameString);
220232
PasswordField password = new PasswordField();
221233
password.setText(passwordString);
234+
Label pwdCheck = new Label("No password");
235+
pwdCheck.setTextFill(Color.web("#b3b3b3"));
236+
237+
password.textProperty().addListener((observable, oldValue, newValue) -> {
238+
Pair<String, Color> res = checkPasswordComplexity(newValue);
239+
pwdCheck.setText(res.getKey());
240+
pwdCheck.setTextFill(res.getValue());
241+
});
222242

223243
grid.add(new Label("Username"), 0, 0);
224244
grid.add(username, 1, 0);
225245
grid.add(new Label("Password"), 0, 1);
226246
grid.add(password, 1, 1);
247+
if (!login) {
248+
grid.add(pwdCheck, 1, 2);
249+
}
250+
227251

228252
username.textProperty().addListener(((observableValue, oldV, newV) -> regBtn.setDisable(newV.trim().isEmpty())));
229253
regBtn.setDisable(unameString.trim().isEmpty());
@@ -237,7 +261,7 @@ protected void onLoginButtonClick(String unameString, String passwordString) {
237261
String newUname = username.getText();
238262
String newPwd = password.getText();
239263

240-
Pair<String, Color> checker = PasswordGeneratorUtil.checkPasswordComplexity(newPwd);
264+
Pair<String, Color> checker = checkPasswordComplexity(newPwd);
241265

242266
if (password.getText().isEmpty() && !login){
243267
AlertsUtil.showErrorDialog("Error", "There is a problem.", "You can't register with empty password.");

src/main/java/me/goral/keepmypassworddesktop/util/AlertsUtil.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public static void showErrorDialog(String errTitle, String errHeader, String err
7070
/**
7171
* Show a dialog to confirm the deletion of all data
7272
*/
73-
public static void showDeleteDataDialog() {
73+
public static void showDeleteDataDialog(TableView<LoggedController.PasswordRow> tv, boolean s) {
7474
Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
7575
alert.setTitle("Deleting all data");
7676
alert.setHeaderText("You are about to wipe out all your data");
@@ -96,6 +96,8 @@ public static void showDeleteDataDialog() {
9696

9797
if (result.get() == confirm) {
9898
DatabaseHandler.truncateData();
99+
LoggedController lc = new LoggedController();
100+
lc.refreshContentTable(tv, s);
99101
showInformationDialog("Information Dialog", "Data cleared", "All your passwords have been deleted.\n" +
100102
"Have a great day!");
101103
}
@@ -208,9 +210,8 @@ public static void showSettingsDialog(TableView<LoggedController.PasswordRow> tv
208210
alert.close();
209211
});
210212
delData.setOnMouseClicked(mouseEvent -> {
211-
showDeleteDataDialog();
212-
LoggedController lc = new LoggedController();
213-
lc.refreshContentTable(tv, s);
213+
showDeleteDataDialog(tv, s);
214+
alert.close();
214215
});
215216

216217
logout.setOnMouseClicked(mouseEvent -> {

0 commit comments

Comments
 (0)