Added ability to change the user name on the client side

This commit is contained in:
delvh 2020-08-01 09:54:18 +02:00
parent b02c2fdc65
commit 498f3ef43d
2 changed files with 22 additions and 2 deletions

View File

@ -1,7 +1,11 @@
package envoy.client.ui.settings; package envoy.client.ui.settings;
import javafx.event.EventHandler;
import javafx.scene.control.Alert; import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType; import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.TextField;
import javafx.scene.input.InputEvent;
import javafx.scene.layout.HBox;
import envoy.client.event.SendEvent; import envoy.client.event.SendEvent;
import envoy.client.ui.SceneContext; import envoy.client.ui.SceneContext;
@ -30,7 +34,22 @@ public class UserSettingsPane extends SettingsPane {
* @param user the user who wants to customize his profile * @param user the user who wants to customize his profile
* @since Envoy Client v0.2-beta * @since Envoy Client v0.2-beta
*/ */
public UserSettingsPane(SceneContext sceneContext, User user) { super("User"); } public UserSettingsPane(SceneContext sceneContext, User user) {
super("User"); // Display of profile picture change mechanism
final var hbox = new HBox();
// Displaying the username change mechanism
final var username = user.getName();
final var usernameTextField = new TextField(username);
final EventHandler<? super InputEvent> textChanged = e -> {
newUsername = usernameTextField.getText();
usernameChanged = newUsername != username;
};
usernameTextField.setOnInputMethodTextChanged(textChanged);
usernameTextField.setOnKeyTyped(textChanged);
hbox.getChildren().add(usernameTextField);
vbox.getChildren().add(hbox);
}
/** /**
* Saves the given input and sends the changed input to the server * Saves the given input and sends the changed input to the server

View File

@ -70,7 +70,8 @@ public class Startup {
new IDGeneratorRequestProcessor(), new IDGeneratorRequestProcessor(),
new UserSearchProcessor(), new UserSearchProcessor(),
new ContactOperationProcessor(), new ContactOperationProcessor(),
new IsTypingProcessor()))); new IsTypingProcessor(),
new NameChangeProcessor())));
// Initialize the current message ID // Initialize the current message ID
final PersistenceManager persistenceManager = PersistenceManager.getInstance(); final PersistenceManager persistenceManager = PersistenceManager.getInstance();