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.util.EnvoyLog;
import envoy.data.Message;
import envoy.data.TextMessage;
import envoy.data.MessageBuilder;
import envoy.data.User;
import envoy.event.EventBus;
@ -247,7 +247,7 @@ public class ChatWindow extends JFrame {
if (!messageEnterTextArea.getText().isEmpty()) try {
// 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);
messageList.setModel(currentChat.getModel());

View File

@ -9,7 +9,6 @@ import javax.swing.ListCellRenderer;
import envoy.client.Settings;
import envoy.data.Message;
import envoy.data.TextMessage;
/**
* Defines how a message is displayed.<br>
@ -38,12 +37,11 @@ public class MessageListRenderer extends JLabel implements ListCellRenderer<Mess
setOpaque(true);
// TODO: Handle other message types
final TextMessage message = (TextMessage) value;
// TODO: Handle message attachments
final String text = message.getContent();
final String state = message.getStatus().toString();
final String date = new SimpleDateFormat("dd.MM.yyyy HH.mm").format(message.getDate());
final String text = value.getText();
final String state = value.getStatus().toString();
final String date = new SimpleDateFormat("dd.MM.yyyy HH.mm").format(value.getDate());
// Getting the MessageColor in the Chat of the current theme
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.data.Message;
import envoy.data.TextMessage;
import envoy.event.EventBus;
import envoy.exception.EnvoyException;
@ -79,9 +78,8 @@ public class StatusTrayIcon {
.register(MessageCreationEvent.class,
(evt) -> {
// TODO: Handle other message types
if (displayMessages) trayIcon.displayMessage("New message received",
((TextMessage) ((MessageCreationEvent) evt).get()).getContent(),
MessageType.INFO);
if (displayMessages)
trayIcon.displayMessage("New message received", ((MessageCreationEvent) evt).get().getText(), MessageType.INFO);
});
}
@ -99,4 +97,4 @@ public class StatusTrayIcon {
throw new EnvoyException("Could not attach Envoy tray icon to system tray.", e);
}
}
}
}