Display Current User Status and Unread Message Amount in Status Tray Icon #103

Merged
kske merged 8 commits from f/enhanced-status-tray-icon into develop 2020-10-23 17:19:46 +02:00
1 changed files with 11 additions and 1 deletions
Showing only changes of commit e79f60e95e - Show all commits

View File

@ -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);
}