diff --git a/client/src/main/java/envoy/client/ui/SceneContext.java b/client/src/main/java/envoy/client/ui/SceneContext.java
index dff69be..d9585fa 100644
--- a/client/src/main/java/envoy/client/ui/SceneContext.java
+++ b/client/src/main/java/envoy/client/ui/SceneContext.java
@@ -4,6 +4,7 @@ import java.io.IOException;
import java.util.Stack;
import java.util.logging.Level;
+import javafx.application.Platform;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
@@ -125,10 +126,11 @@ public final class SceneContext {
sceneStack.push(scene);
stage.setScene(scene);
- if (sceneInfo == SceneInfo.LOGIN_SCENE) stage.setResizable(false);
- else stage.setResizable(true);
+ // The LoginScene is the only scene not intended to be resized
+ // As strange as it seems, this is needed as otherwise the LoginScene won't be
+ // displayed on some OS (...Debian...)
+ Platform.runLater(() -> stage.setResizable(sceneInfo != SceneInfo.LOGIN_SCENE));
applyCSS();
- stage.sizeToScene();
stage.show();
} catch (final IOException e) {
EnvoyLog.getLogger(SceneContext.class).log(Level.SEVERE, String.format("Could not load scene for %s: ", sceneInfo), e);
diff --git a/client/src/main/java/envoy/client/ui/controller/LoginScene.java b/client/src/main/java/envoy/client/ui/controller/LoginScene.java
index def2bb6..2d12891 100644
--- a/client/src/main/java/envoy/client/ui/controller/LoginScene.java
+++ b/client/src/main/java/envoy/client/ui/controller/LoginScene.java
@@ -136,23 +136,23 @@ public final class LoginScene {
@FXML
private void registerSwitchPressed() {
- registration = !registration;
-
- // Make repeat password field and label visible / invisible
- repeatPasswordField.setVisible(registration);
- if (loginButton.getText().equals("Login")) {
+ if (!registration) {
+ // case if the current mode is login
loginButton.setText("Register");
loginButton.setPadding(new Insets(2, 116, 2, 116));
registerTextLabel.setText("Already an account?");
registerSwitch.setText("Login");
- offlineModeButton.setDisable(true);
} else {
+ // case if the current mode is registration
loginButton.setText("Login");
loginButton.setPadding(new Insets(2, 125, 2, 125));
registerTextLabel.setText("No account yet?");
registerSwitch.setText("Register");
- offlineModeButton.setDisable(false);
}
+ registration = !registration;
+ // Make repeat password field and label visible / invisible
+ repeatPasswordField.setVisible(registration);
+ offlineModeButton.setDisable(registration);
}
@FXML
@@ -167,7 +167,7 @@ public final class LoginScene {
localDB.setUser(localDB.getUsers().get(identifier));
localDB.initializeUserStorage();
localDB.loadUserData();
- } catch (Exception e) {
+ } catch (final Exception e) {
// User storage empty, wrong user name etc. -> default lastSync
}
return localDB.getLastSync();
@@ -190,7 +190,7 @@ public final class LoginScene {
try {
// Try entering offline mode
localDB.loadUsers();
- final User clientUser = (User) localDB.getUsers().get(credentials.getIdentifier());
+ final User clientUser = localDB.getUsers().get(credentials.getIdentifier());
if (clientUser == null) throw new EnvoyException("Could not enter offline mode: user name unknown");
client.setSender(clientUser);
loadChatScene();
diff --git a/client/src/main/java/envoy/client/ui/listcell/MessageControl.java b/client/src/main/java/envoy/client/ui/listcell/MessageControl.java
index 129d2c4..9d2d32a 100644
--- a/client/src/main/java/envoy/client/ui/listcell/MessageControl.java
+++ b/client/src/main/java/envoy/client/ui/listcell/MessageControl.java
@@ -40,8 +40,9 @@ import envoy.util.EnvoyLog;
*/
public class MessageControl extends Label {
- private static LocalDB localDB;
- private boolean ownMessage;
+ private boolean ownMessage;
+
+ private static LocalDB localDB;
private static final DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("dd.MM.yyyy HH:mm:ss")
.withZone(ZoneId.systemDefault());
@@ -57,7 +58,7 @@ public class MessageControl extends Label {
// Creating the underlying VBox and the dateLabel
final var hbox = new HBox();
if (message.getSenderID() != localDB.getUser().getID() && message instanceof GroupMessage) {
- Label label = new Label();
+ final var label = new Label();
label.getStyleClass().add("groupMemberNames");
label.setText(localDB.getUsers()
.values()
@@ -73,12 +74,12 @@ public class MessageControl extends Label {
final var vbox = new VBox(hbox);
// Creating the actions for the MenuItems
- final ContextMenu contextMenu = new ContextMenu();
- final MenuItem copyMenuItem = new MenuItem("Copy");
- final MenuItem deleteMenuItem = new MenuItem("Delete");
- final MenuItem forwardMenuItem = new MenuItem("Forward");
- final MenuItem quoteMenuItem = new MenuItem("Quote");
- final MenuItem infoMenuItem = new MenuItem("Info");
+ final var contextMenu = new ContextMenu();
+ final var copyMenuItem = new MenuItem("Copy");
+ final var deleteMenuItem = new MenuItem("Delete");
+ final var forwardMenuItem = new MenuItem("Forward");
+ final var quoteMenuItem = new MenuItem("Quote");
+ final var infoMenuItem = new MenuItem("Info");
copyMenuItem.setOnAction(e -> copyMessage(message));
deleteMenuItem.setOnAction(e -> deleteMessage(message));
forwardMenuItem.setOnAction(e -> forwardMessage(message));
@@ -109,13 +110,13 @@ public class MessageControl extends Label {
final var textLabel = new Label(message.getText());
textLabel.setMaxWidth(430);
textLabel.setWrapText(true);
- HBox hBoxBottom = new HBox();
+ final var hBoxBottom = new HBox();
hBoxBottom.getChildren().add(textLabel);
// Setting the message status icon and background color
if (message.getSenderID() == localDB.getUser().getID()) {
final var statusIcon = new ImageView(statusImages.get(message.getStatus()));
statusIcon.setPreserveRatio(true);
- Region space = new Region();
+ final var space = new Region();
HBox.setHgrow(space, Priority.ALWAYS);
hBoxBottom.getChildren().add(space);
hBoxBottom.getChildren().add(statusIcon);
@@ -156,5 +157,10 @@ public class MessageControl extends Label {
*/
public static void setLocalDB(LocalDB localDB) { MessageControl.localDB = localDB; }
+ /**
+ * @return whether the message stored by this {@code MessageControl} has been
+ * sent by this user of Envoy
+ * @since Envoy Client v0.1-beta
+ */
public boolean isOwnMessage() { return ownMessage; }
}
diff --git a/client/src/main/resources/fxml/ChatScene.fxml b/client/src/main/resources/fxml/ChatScene.fxml
index 9ce9ef9..65efe79 100644
--- a/client/src/main/resources/fxml/ChatScene.fxml
+++ b/client/src/main/resources/fxml/ChatScene.fxml
@@ -66,7 +66,7 @@
-