Fixed various bugs

These are:
* different size of addContact- and SettingsButton
* default icons in light mode for users and groups (even though they are
currently just the version used in dark mode)
* wrong preferred size of unnamed "Login" label in LoginScene
* unopenable LoginScene for some OS (Debian)
* white screen when the current scene is switched

Additionally cleaned up code a bit in MessageControl and
LoginScene(.java)
This commit is contained in:
delvh 2020-07-29 21:59:55 +02:00
parent a539d3014a
commit e7a70d6cda
No known key found for this signature in database
GPG Key ID: 42B77E634CE94D82
7 changed files with 36 additions and 26 deletions

View File

@ -4,6 +4,7 @@ import java.io.IOException;
import java.util.Stack; import java.util.Stack;
import java.util.logging.Level; import java.util.logging.Level;
import javafx.application.Platform;
import javafx.fxml.FXMLLoader; import javafx.fxml.FXMLLoader;
import javafx.scene.Parent; import javafx.scene.Parent;
import javafx.scene.Scene; import javafx.scene.Scene;
@ -125,10 +126,11 @@ public final class SceneContext {
sceneStack.push(scene); sceneStack.push(scene);
stage.setScene(scene); stage.setScene(scene);
if (sceneInfo == SceneInfo.LOGIN_SCENE) stage.setResizable(false); // The LoginScene is the only scene not intended to be resized
else stage.setResizable(true); // 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(); applyCSS();
stage.sizeToScene();
stage.show(); stage.show();
} catch (final IOException e) { } catch (final IOException e) {
EnvoyLog.getLogger(SceneContext.class).log(Level.SEVERE, String.format("Could not load scene for %s: ", sceneInfo), e); EnvoyLog.getLogger(SceneContext.class).log(Level.SEVERE, String.format("Could not load scene for %s: ", sceneInfo), e);

View File

@ -136,23 +136,23 @@ public final class LoginScene {
@FXML @FXML
private void registerSwitchPressed() { private void registerSwitchPressed() {
registration = !registration; if (!registration) {
// case if the current mode is login
// Make repeat password field and label visible / invisible
repeatPasswordField.setVisible(registration);
if (loginButton.getText().equals("Login")) {
loginButton.setText("Register"); loginButton.setText("Register");
loginButton.setPadding(new Insets(2, 116, 2, 116)); loginButton.setPadding(new Insets(2, 116, 2, 116));
registerTextLabel.setText("Already an account?"); registerTextLabel.setText("Already an account?");
registerSwitch.setText("Login"); registerSwitch.setText("Login");
offlineModeButton.setDisable(true);
} else { } else {
// case if the current mode is registration
loginButton.setText("Login"); loginButton.setText("Login");
loginButton.setPadding(new Insets(2, 125, 2, 125)); loginButton.setPadding(new Insets(2, 125, 2, 125));
registerTextLabel.setText("No account yet?"); registerTextLabel.setText("No account yet?");
registerSwitch.setText("Register"); registerSwitch.setText("Register");
offlineModeButton.setDisable(false);
} }
registration = !registration;
// Make repeat password field and label visible / invisible
repeatPasswordField.setVisible(registration);
offlineModeButton.setDisable(registration);
} }
@FXML @FXML
@ -167,7 +167,7 @@ public final class LoginScene {
localDB.setUser(localDB.getUsers().get(identifier)); localDB.setUser(localDB.getUsers().get(identifier));
localDB.initializeUserStorage(); localDB.initializeUserStorage();
localDB.loadUserData(); localDB.loadUserData();
} catch (Exception e) { } catch (final Exception e) {
// User storage empty, wrong user name etc. -> default lastSync // User storage empty, wrong user name etc. -> default lastSync
} }
return localDB.getLastSync(); return localDB.getLastSync();
@ -190,7 +190,7 @@ public final class LoginScene {
try { try {
// Try entering offline mode // Try entering offline mode
localDB.loadUsers(); 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"); if (clientUser == null) throw new EnvoyException("Could not enter offline mode: user name unknown");
client.setSender(clientUser); client.setSender(clientUser);
loadChatScene(); loadChatScene();

View File

@ -40,9 +40,10 @@ import envoy.util.EnvoyLog;
*/ */
public class MessageControl extends Label { 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") private static final DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("dd.MM.yyyy HH:mm:ss")
.withZone(ZoneId.systemDefault()); .withZone(ZoneId.systemDefault());
private static final Map<MessageStatus, Image> statusImages = IconUtil.loadByEnum(MessageStatus.class, 16); private static final Map<MessageStatus, Image> statusImages = IconUtil.loadByEnum(MessageStatus.class, 16);
@ -57,7 +58,7 @@ public class MessageControl extends Label {
// Creating the underlying VBox and the dateLabel // Creating the underlying VBox and the dateLabel
final var hbox = new HBox(); final var hbox = new HBox();
if (message.getSenderID() != localDB.getUser().getID() && message instanceof GroupMessage) { if (message.getSenderID() != localDB.getUser().getID() && message instanceof GroupMessage) {
Label label = new Label(); final var label = new Label();
label.getStyleClass().add("groupMemberNames"); label.getStyleClass().add("groupMemberNames");
label.setText(localDB.getUsers() label.setText(localDB.getUsers()
.values() .values()
@ -73,12 +74,12 @@ public class MessageControl extends Label {
final var vbox = new VBox(hbox); final var vbox = new VBox(hbox);
// Creating the actions for the MenuItems // Creating the actions for the MenuItems
final ContextMenu contextMenu = new ContextMenu(); final var contextMenu = new ContextMenu();
final MenuItem copyMenuItem = new MenuItem("Copy"); final var copyMenuItem = new MenuItem("Copy");
final MenuItem deleteMenuItem = new MenuItem("Delete"); final var deleteMenuItem = new MenuItem("Delete");
final MenuItem forwardMenuItem = new MenuItem("Forward"); final var forwardMenuItem = new MenuItem("Forward");
final MenuItem quoteMenuItem = new MenuItem("Quote"); final var quoteMenuItem = new MenuItem("Quote");
final MenuItem infoMenuItem = new MenuItem("Info"); final var infoMenuItem = new MenuItem("Info");
copyMenuItem.setOnAction(e -> copyMessage(message)); copyMenuItem.setOnAction(e -> copyMessage(message));
deleteMenuItem.setOnAction(e -> deleteMessage(message)); deleteMenuItem.setOnAction(e -> deleteMessage(message));
forwardMenuItem.setOnAction(e -> forwardMessage(message)); forwardMenuItem.setOnAction(e -> forwardMessage(message));
@ -109,13 +110,13 @@ public class MessageControl extends Label {
final var textLabel = new Label(message.getText()); final var textLabel = new Label(message.getText());
textLabel.setMaxWidth(430); textLabel.setMaxWidth(430);
textLabel.setWrapText(true); textLabel.setWrapText(true);
HBox hBoxBottom = new HBox(); final var hBoxBottom = new HBox();
hBoxBottom.getChildren().add(textLabel); hBoxBottom.getChildren().add(textLabel);
// Setting the message status icon and background color // Setting the message status icon and background color
if (message.getSenderID() == localDB.getUser().getID()) { if (message.getSenderID() == localDB.getUser().getID()) {
final var statusIcon = new ImageView(statusImages.get(message.getStatus())); final var statusIcon = new ImageView(statusImages.get(message.getStatus()));
statusIcon.setPreserveRatio(true); statusIcon.setPreserveRatio(true);
Region space = new Region(); final var space = new Region();
HBox.setHgrow(space, Priority.ALWAYS); HBox.setHgrow(space, Priority.ALWAYS);
hBoxBottom.getChildren().add(space); hBoxBottom.getChildren().add(space);
hBoxBottom.getChildren().add(statusIcon); hBoxBottom.getChildren().add(statusIcon);
@ -156,5 +157,10 @@ public class MessageControl extends Label {
*/ */
public static void setLocalDB(LocalDB localDB) { MessageControl.localDB = localDB; } 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; } public boolean isOwnMessage() { return ownMessage; }
} }

View File

@ -66,7 +66,7 @@
<Region id="transparentBackground" prefHeight="77.0" prefWidth="115.0" /> <Region id="transparentBackground" prefHeight="77.0" prefWidth="115.0" />
<VBox id="transparentBackground" alignment="CENTER_RIGHT" prefHeight="200.0" prefWidth="100.0" spacing="5.0"> <VBox id="transparentBackground" alignment="CENTER_RIGHT" prefHeight="200.0" prefWidth="100.0" spacing="5.0">
<children> <children>
<Button fx:id="settingsButton" mnemonicParsing="true" onAction="#settingsButtonClicked" text=""> <Button fx:id="settingsButton" mnemonicParsing="true" onAction="#settingsButtonClicked" prefHeight="30.0" prefWidth="30.0" text="">
<padding> <padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> <Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding> </padding>
@ -74,7 +74,7 @@
<Insets /> <Insets />
</VBox.margin> </VBox.margin>
</Button> </Button>
<Button mnemonicParsing="true" onAction="#addContactButtonClicked" text=" + "> <Button mnemonicParsing="true" onAction="#addContactButtonClicked" prefHeight="30.0" prefWidth="30.0" text=" + ">
<padding> <padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> <Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding> </padding>

View File

@ -32,7 +32,9 @@
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> <Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding> </padding>
</Label> </Label>
<Label alignment="TOP_CENTER" contentDisplay="CENTER" prefHeight="33.0" prefWidth="87.0" text="LOGIN" textAlignment="CENTER"> <Label alignment="TOP_CENTER" contentDisplay="CENTER"
prefHeight="33.0" prefWidth="110.0" text="LOGIN"
textAlignment="CENTER">
<font> <font>
<Font size="26.0" /> <Font size="26.0" />
</font> </font>

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB