Integrated the new Message class from envoy-common

This commit is contained in:
Kai S. K. Engelbart 2019-12-31 11:27:52 +02:00
parent e66dba8812
commit 3cebdc8997
3 changed files with 9 additions and 13 deletions

View File

@ -14,7 +14,7 @@ import envoy.client.event.ThemeChangeEvent;
import envoy.client.ui.settings.SettingsScreen; import envoy.client.ui.settings.SettingsScreen;
import envoy.client.util.EnvoyLog; import envoy.client.util.EnvoyLog;
import envoy.data.Message; import envoy.data.Message;
import envoy.data.TextMessage; import envoy.data.MessageBuilder;
import envoy.data.User; import envoy.data.User;
import envoy.event.EventBus; import envoy.event.EventBus;
@ -247,7 +247,7 @@ public class ChatWindow extends JFrame {
if (!messageEnterTextArea.getText().isEmpty()) try { if (!messageEnterTextArea.getText().isEmpty()) try {
// Create and send message object // Create and send message object
final Message message = new TextMessage(0, localDB.getUser(), currentChat.getRecipient(), messageEnterTextArea.getText()); final Message message = new MessageBuilder(localDB.getUser(), currentChat.getRecipient()).setText(messageEnterTextArea.getText()).build();
currentChat.appendMessage(message); currentChat.appendMessage(message);
messageList.setModel(currentChat.getModel()); messageList.setModel(currentChat.getModel());

View File

@ -9,7 +9,6 @@ import javax.swing.ListCellRenderer;
import envoy.client.Settings; import envoy.client.Settings;
import envoy.data.Message; import envoy.data.Message;
import envoy.data.TextMessage;
/** /**
* Defines how a message is displayed.<br> * Defines how a message is displayed.<br>
@ -38,12 +37,11 @@ public class MessageListRenderer extends JLabel implements ListCellRenderer<Mess
setOpaque(true); setOpaque(true);
// TODO: Handle other message types // TODO: Handle message attachments
final TextMessage message = (TextMessage) value;
final String text = message.getContent(); final String text = value.getText();
final String state = message.getStatus().toString(); final String state = value.getStatus().toString();
final String date = new SimpleDateFormat("dd.MM.yyyy HH.mm").format(message.getDate()); final String date = new SimpleDateFormat("dd.MM.yyyy HH.mm").format(value.getDate());
// Getting the MessageColor in the Chat of the current theme // Getting the MessageColor in the Chat of the current theme
String textColor = Settings.getInstance().getThemes().get(Settings.getInstance().getCurrentTheme()).getMessageColorChat().toHex(); String textColor = Settings.getInstance().getThemes().get(Settings.getInstance().getCurrentTheme()).getMessageColorChat().toHex();

View File

@ -7,7 +7,6 @@ import java.awt.event.WindowEvent;
import envoy.client.event.MessageCreationEvent; import envoy.client.event.MessageCreationEvent;
import envoy.data.Message; import envoy.data.Message;
import envoy.data.TextMessage;
import envoy.event.EventBus; import envoy.event.EventBus;
import envoy.exception.EnvoyException; import envoy.exception.EnvoyException;
@ -79,9 +78,8 @@ public class StatusTrayIcon {
.register(MessageCreationEvent.class, .register(MessageCreationEvent.class,
(evt) -> { (evt) -> {
// TODO: Handle other message types // TODO: Handle other message types
if (displayMessages) trayIcon.displayMessage("New message received", if (displayMessages)
((TextMessage) ((MessageCreationEvent) evt).get()).getContent(), trayIcon.displayMessage("New message received", ((MessageCreationEvent) evt).get().getText(), MessageType.INFO);
MessageType.INFO);
}); });
} }