Fixed problems with groupMemberName displaying
This commit is contained in:
parent
79a121b6b5
commit
60791f2913
@ -242,7 +242,7 @@ public final class ChatScene implements Restorable {
|
|||||||
|
|
||||||
chatList.setItems(FXCollections.observableList(localDB.getChats()));
|
chatList.setItems(FXCollections.observableList(localDB.getChats()));
|
||||||
contactLabel.setText(localDB.getUser().getName());
|
contactLabel.setText(localDB.getUser().getName());
|
||||||
MessageControl.setUser(localDB.getUser());
|
MessageControl.setLocalDB(localDB);
|
||||||
if (!client.isOnline()) updateInfoLabel("You are offline", "infoLabel-info");
|
if (!client.isOnline()) updateInfoLabel("You are offline", "infoLabel-info");
|
||||||
|
|
||||||
recorder = new AudioRecorder();
|
recorder = new AudioRecorder();
|
||||||
|
@ -238,5 +238,6 @@ public final class LoginScene {
|
|||||||
sceneContext.getStage().setMinWidth(843);
|
sceneContext.getStage().setMinWidth(843);
|
||||||
sceneContext.load(SceneContext.SceneInfo.CHAT_SCENE);
|
sceneContext.load(SceneContext.SceneInfo.CHAT_SCENE);
|
||||||
sceneContext.<ChatScene>getController().initializeData(sceneContext, localDB, client, writeProxy);
|
sceneContext.<ChatScene>getController().initializeData(sceneContext, localDB, client, writeProxy);
|
||||||
|
sceneContext.getStage().centerOnScreen();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ import javafx.scene.image.ImageView;
|
|||||||
import javafx.scene.layout.HBox;
|
import javafx.scene.layout.HBox;
|
||||||
import javafx.scene.layout.VBox;
|
import javafx.scene.layout.VBox;
|
||||||
|
|
||||||
|
import envoy.client.data.LocalDB;
|
||||||
import envoy.client.ui.AudioControl;
|
import envoy.client.ui.AudioControl;
|
||||||
import envoy.client.ui.IconUtil;
|
import envoy.client.ui.IconUtil;
|
||||||
import envoy.data.GroupMessage;
|
import envoy.data.GroupMessage;
|
||||||
@ -34,11 +35,12 @@ import envoy.util.EnvoyLog;
|
|||||||
* Created: <strong>01.07.2020</strong><br>
|
* Created: <strong>01.07.2020</strong><br>
|
||||||
*
|
*
|
||||||
* @author Leon Hofmeister
|
* @author Leon Hofmeister
|
||||||
* @since Envoy Client v0.1-beta
|
* @author Maximilian Käfer
|
||||||
|
* @since Envoy Client v0.2-beta
|
||||||
*/
|
*/
|
||||||
public class MessageControl extends Label {
|
public class MessageControl extends Label {
|
||||||
|
|
||||||
private static User client;
|
private static LocalDB localDB;
|
||||||
private boolean ownMessage;
|
private boolean ownMessage;
|
||||||
|
|
||||||
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")
|
||||||
@ -54,24 +56,18 @@ public class MessageControl extends Label {
|
|||||||
public MessageControl(Message message) {
|
public MessageControl(Message message) {
|
||||||
// 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() != client.getID() && message instanceof GroupMessage) {
|
if (message.getSenderID() != localDB.getUser().getID() && message instanceof GroupMessage) {
|
||||||
client.getContacts()
|
Label label = new Label();
|
||||||
|
label.getStyleClass().add("groupMemberNames");
|
||||||
|
label.setText(localDB.getUsers()
|
||||||
|
.values()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(c -> c instanceof User)
|
|
||||||
.filter(c -> c.getID() == message.getSenderID())
|
.filter(c -> c.getID() == message.getSenderID())
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.ifPresentOrElse(c -> {
|
.map(User::getName)
|
||||||
Label label = new Label(c.getName() + " ");
|
.orElse("Unknown User"));
|
||||||
label.getStyleClass().add("groupMemberNames");
|
label.setPadding(new Insets(0, 5, 0, 0));
|
||||||
hbox.getChildren().add(label);
|
hbox.getChildren().add(label);
|
||||||
}, () -> {
|
|
||||||
Label label = new Label("Unknown User ");
|
|
||||||
label.getStyleClass().add("groupMemberNames");
|
|
||||||
hbox.getChildren().add(label);
|
|
||||||
});
|
|
||||||
// TODO improve offline login (contacts list is empty when logging in offline)
|
|
||||||
// TODO when contact is added, unknown user has to change immediately to the
|
|
||||||
// name, not only after relogging
|
|
||||||
}
|
}
|
||||||
hbox.getChildren().add(new Label(dateFormat.format(message.getCreationDate())));
|
hbox.getChildren().add(new Label(dateFormat.format(message.getCreationDate())));
|
||||||
final var vbox = new VBox(hbox);
|
final var vbox = new VBox(hbox);
|
||||||
@ -114,7 +110,7 @@ public class MessageControl extends Label {
|
|||||||
textLabel.setWrapText(true);
|
textLabel.setWrapText(true);
|
||||||
vbox.getChildren().add(textLabel);
|
vbox.getChildren().add(textLabel);
|
||||||
// Setting the message status icon and background color
|
// Setting the message status icon and background color
|
||||||
if (message.getSenderID() == client.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);
|
||||||
vbox.getChildren().add(statusIcon);
|
vbox.getChildren().add(statusIcon);
|
||||||
@ -147,10 +143,10 @@ public class MessageControl extends Label {
|
|||||||
private void saveAttachment(Message message) { logger.log(Level.FINEST, "attachment saving was requested for " + message); }
|
private void saveAttachment(Message message) { logger.log(Level.FINEST, "attachment saving was requested for " + message); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param client the user who has logged in
|
* @param localDB the localDB
|
||||||
* @since Envoy Client v0.1-beta
|
* @since Envoy Client v0.2-beta
|
||||||
*/
|
*/
|
||||||
public static void setUser(User client) { MessageControl.client = client; }
|
public static void setLocalDB(LocalDB localDB) { MessageControl.localDB = localDB; }
|
||||||
|
|
||||||
public boolean isOwnMessage() { return ownMessage; }
|
public boolean isOwnMessage() { return ownMessage; }
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user