Added StatusTrayIcon#displayMessageNotification method

Using this method, a message object can be displayed as a OS-specific
notification, which can be useful in the future to alert the user about
an incoming message while the application is not in focus.
This commit is contained in:
Kai S. K. Engelbart 2019-12-04 18:52:48 +01:00
parent 3c7f95f869
commit b5badae773

View File

@ -7,8 +7,10 @@ import java.awt.PopupMenu;
import java.awt.SystemTray;
import java.awt.Toolkit;
import java.awt.TrayIcon;
import java.awt.TrayIcon.MessageType;
import envoy.exception.EnvoyException;
import envoy.schema.Message;
/**
* Project: <strong>envoy-client</strong><br>
@ -41,6 +43,7 @@ public class StatusTrayIcon {
/**
* Makes this {@link StatusTrayIcon} appear in the system tray.
*
* @throws EnvoyException
*/
public void show() throws EnvoyException {
@ -51,6 +54,13 @@ public class StatusTrayIcon {
}
}
/**
* Notifies the user of a message by displaying a popup.
*
* @param message the {@link Message} object to display in the popup
*/
public void displayMessageNotification(Message message) {
// TODO: Add event listener
// trayIcon.displayMessage("Envoy Client", message, MessageType.INFO);
trayIcon.displayMessage("New message received", message.getContent().get(0).getText(), MessageType.INFO);
}
}