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
Showing only changes of commit 241e5def03 - Show all commits

View File

@ -32,12 +32,12 @@ public final class ChatControl extends HBox {
setPadding(new Insets(0, 0, 3, 0)); setPadding(new Insets(0, 0, 3, 0));
// Profile picture // Profile picture
final var contactProfilePic = var contactProfilePic =
new ProfilePicImageView(chat instanceof GroupChat ? groupIcon : userIcon, 32); new ProfilePicImageView(chat instanceof GroupChat ? groupIcon : userIcon, 32);
getChildren().add(contactProfilePic); getChildren().add(contactProfilePic);
// Spacing // Spacing
final var leftSpacing = new Region(); var leftSpacing = new Region();
leftSpacing.setPrefSize(8, 0); leftSpacing.setPrefSize(8, 0);
leftSpacing.setMinSize(8, 0); leftSpacing.setMinSize(8, 0);
leftSpacing.setMaxSize(8, 0); leftSpacing.setMaxSize(8, 0);
@ -48,17 +48,15 @@ public final class ChatControl extends HBox {
// Unread messages // Unread messages
if (chat.getUnreadAmount() != 0) { if (chat.getUnreadAmount() != 0) {
final var spacing = new Region(); var spacing = new Region();
setHgrow(spacing, Priority.ALWAYS); setHgrow(spacing, Priority.ALWAYS);
getChildren().add(spacing); getChildren().add(spacing);
final var unreadMessagesLabel = new Label(Integer.toString(chat.getUnreadAmount())); var unreadMessagesLabel = new Label(
chat.getUnreadAmount() > 99 ? "99+" : String.valueOf(chat.getUnreadAmount()));
unreadMessagesLabel.setMinSize(15, 15); unreadMessagesLabel.setMinSize(15, 15);
final var vbox = new VBox(); unreadMessagesLabel.setAlignment(Pos.CENTER_RIGHT);
vbox.setAlignment(Pos.CENTER_RIGHT);
unreadMessagesLabel.setAlignment(Pos.CENTER);
unreadMessagesLabel.getStyleClass().add("unread-messages-amount"); unreadMessagesLabel.getStyleClass().add("unread-messages-amount");
vbox.getChildren().add(unreadMessagesLabel); getChildren().add(unreadMessagesLabel);
getChildren().add(vbox);
} }
getStyleClass().add("list-element"); getStyleClass().add("list-element");
} }