Display Current User Status and Unread Message Amount in Status Tray Icon #103
@ -56,6 +56,8 @@ public final class StatusTrayIcon implements EventListener {
|
||||
*/
|
||||
private final Image logo;
|
||||
|
||||
private static final Font unreadMessageFont = new Font("sans-serif", Font.PLAIN, 8);
|
||||
|
||||
/**
|
||||
* @return {@code true} if the status tray icon is supported on this platform
|
||||
* @since Envoy Client v0.2-beta
|
||||
@ -200,10 +202,18 @@ public final class StatusTrayIcon implements EventListener {
|
||||
|
||||
// Draw total amount of unread messages, if any are present
|
||||
if (Chat.getTotalUnreadAmount().get() > 0) {
|
||||
|
||||
// Draw black background circle
|
||||
g.setColor(Color.BLACK);
|
||||
g.fillOval(size.width / 2, 0, size.width / 2, size.height / 2);
|
||||
|
||||
// Unread amount in white
|
||||
String unreadAmount = Chat.getTotalUnreadAmount().get() > 9 ? "9+"
|
||||
: String.valueOf(Chat.getTotalUnreadAmount().get());
|
||||
g.setColor(Color.WHITE);
|
||||
g.drawString(String.valueOf(Chat.getTotalUnreadAmount().get()), size.width / 2,
|
||||
g.setFont(unreadMessageFont);
|
||||
g.drawString(unreadAmount,
|
||||
3 * size.width / 4 - g.getFontMetrics().stringWidth(unreadAmount) / 2,
|
||||
size.height / 2);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user