Added name displaying of groupMessages in groupChats
This commit is contained in:
parent
2db5e4e85b
commit
aad31872fd
@ -15,10 +15,12 @@ import javafx.scene.control.Label;
|
|||||||
import javafx.scene.control.MenuItem;
|
import javafx.scene.control.MenuItem;
|
||||||
import javafx.scene.image.Image;
|
import javafx.scene.image.Image;
|
||||||
import javafx.scene.image.ImageView;
|
import javafx.scene.image.ImageView;
|
||||||
|
import javafx.scene.layout.HBox;
|
||||||
import javafx.scene.layout.VBox;
|
import javafx.scene.layout.VBox;
|
||||||
|
|
||||||
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.Message;
|
import envoy.data.Message;
|
||||||
import envoy.data.Message.MessageStatus;
|
import envoy.data.Message.MessageStatus;
|
||||||
import envoy.data.User;
|
import envoy.data.User;
|
||||||
@ -51,7 +53,28 @@ 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 vbox = new VBox(new Label(dateFormat.format(message.getCreationDate())));
|
final var hbox = new HBox();
|
||||||
|
if (message.getSenderID() != client.getID() && message instanceof GroupMessage) {
|
||||||
|
client.getContacts()
|
||||||
|
.stream()
|
||||||
|
.filter(c -> c instanceof User)
|
||||||
|
.filter(c -> c.getID() == message.getSenderID())
|
||||||
|
.findFirst()
|
||||||
|
.ifPresentOrElse(c -> {
|
||||||
|
Label label = new Label(c.getName() + " ");
|
||||||
|
label.getStyleClass().add("groupMemberNames");
|
||||||
|
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())));
|
||||||
|
final var vbox = new VBox(hbox);
|
||||||
|
|
||||||
// Creating the actions for the MenuItems
|
// Creating the actions for the MenuItems
|
||||||
final ContextMenu contextMenu = new ContextMenu();
|
final ContextMenu contextMenu = new ContextMenu();
|
||||||
|
@ -53,3 +53,8 @@
|
|||||||
#messageEnterContainer {
|
#messageEnterContainer {
|
||||||
-fx-background-color: #363636;
|
-fx-background-color: #363636;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.groupMemberNames {
|
||||||
|
-fx-text-fill: rgb(105.0,0.0,153.0);
|
||||||
|
-fx-font-weight: bold;
|
||||||
|
}
|
||||||
|
Binary file not shown.
Reference in New Issue
Block a user