Fixed visual issues as per @delvh 's request

This commit is contained in:
delvh 2020-06-09 22:24:09 +02:00
parent b953586859
commit 8ba718f7b1
6 changed files with 12 additions and 18 deletions

View File

@ -91,7 +91,7 @@ public class Client implements Closeable {
SerializationUtils.writeBytesWithLength(credentials, socket.getOutputStream()); SerializationUtils.writeBytesWithLength(credentials, socket.getOutputStream());
// Wait for a maximum of five seconds to acquire the sender object // Wait for a maximum of five seconds to acquire the sender object
long start = System.currentTimeMillis(); final long start = System.currentTimeMillis();
while (sender == null) { while (sender == null) {
// Quit immediately after handshake rejection // Quit immediately after handshake rejection
@ -162,7 +162,7 @@ public class Client implements Closeable {
eventBus.register(SendEvent.class, evt -> { eventBus.register(SendEvent.class, evt -> {
try { try {
sendEvent(evt.get()); sendEvent(evt.get());
} catch (IOException e) { } catch (final IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
}); });
@ -221,7 +221,7 @@ public class Client implements Closeable {
*/ */
public Map<String, Contact> getUsers() { public Map<String, Contact> getUsers() {
checkOnline(); checkOnline();
Map<String, Contact> users = new HashMap<>(); final Map<String, Contact> users = new HashMap<>();
contacts.forEach(u -> users.put(u.getName(), u)); contacts.forEach(u -> users.put(u.getName(), u));
users.put(sender.getName(), sender); users.put(sender.getName(), sender);
return users; return users;

View File

@ -232,9 +232,6 @@ public final class ChatScene {
*/ */
@FXML @FXML
private void checkKeyCombination(KeyEvent e) { private void checkKeyCombination(KeyEvent e) {
// TODO: Letting go of ctrl automatically posts a message. Needs to be fixed
// soon.
// Automatic sending of messages via (ctrl +) enter // Automatic sending of messages via (ctrl +) enter
if (!postButton.isDisabled() && settings.isEnterToSend() && e.getCode() == KeyCode.ENTER if (!postButton.isDisabled() && settings.isEnterToSend() && e.getCode() == KeyCode.ENTER
|| !settings.isEnterToSend() && e.getCode() == KeyCode.ENTER && e.isControlDown()) || !settings.isEnterToSend() && e.getCode() == KeyCode.ENTER && e.isControlDown())

View File

@ -104,9 +104,7 @@ public final class LoginScene {
if (registerCheckBox.isSelected() && !passwordField.getText().equals(repeatPasswordField.getText())) { if (registerCheckBox.isSelected() && !passwordField.getText().equals(repeatPasswordField.getText())) {
clearPasswordFields(); clearPasswordFields();
new Alert(AlertType.ERROR, "The entered password is unequal to the repeated one").showAndWait(); new Alert(AlertType.ERROR, "The entered password is unequal to the repeated one").showAndWait();
} else { } else performHandshake(new LoginCredentials(userTextField.getText(), passwordField.getText().toCharArray(), registerCheckBox.isSelected()));
performHandshake(new LoginCredentials(userTextField.getText(), passwordField.getText().toCharArray(), registerCheckBox.isSelected()));
}
} }
@FXML @FXML
@ -120,7 +118,6 @@ public final class LoginScene {
// Make repeat password field and label visible / invisible // Make repeat password field and label visible / invisible
repeatPasswordField.setVisible(registerCheckBox.isSelected()); repeatPasswordField.setVisible(registerCheckBox.isSelected());
repeatPasswordLabel.setVisible(registerCheckBox.isSelected()); repeatPasswordLabel.setVisible(registerCheckBox.isSelected());
clearPasswordFields(); clearPasswordFields();
} }
@ -148,12 +145,12 @@ public final class LoginScene {
try { try {
// Try entering offline mode // Try entering offline mode
localDB.loadUsers(); localDB.loadUsers();
User clientUser = (User) localDB.getUsers().get(credentials.getIdentifier()); final User clientUser = (User) localDB.getUsers().get(credentials.getIdentifier());
if (clientUser == null) throw new EnvoyException("Could not enter offline mode: user name unknown"); if (clientUser == null) throw new EnvoyException("Could not enter offline mode: user name unknown");
client.setSender(clientUser); client.setSender(clientUser);
new Alert(AlertType.WARNING, "A connection to the server could not be established. Starting in offline mode.").showAndWait(); new Alert(AlertType.WARNING, "A connection to the server could not be established. Starting in offline mode.").showAndWait();
loadChatScene(); loadChatScene();
} catch (Exception e) { } catch (final Exception e) {
new Alert(AlertType.ERROR, "Client error: " + e).showAndWait(); new Alert(AlertType.ERROR, "Client error: " + e).showAndWait();
System.exit(1); System.exit(1);
} }