Added attachment icons and notified user if an attachment is present

This commit is contained in:
delvh
2020-07-05 23:25:07 +02:00
parent ceec10d819
commit 3af3592e7a
7 changed files with 46 additions and 15 deletions

View File

@ -79,6 +79,9 @@ public final class ChatScene implements Restorable {
@FXML
private MenuItem deleteContactMenuItem;
@FXML
private ImageView attachmentView;
private LocalDB localDB;
private Client client;
private WriteProxy writeProxy;
@ -264,9 +267,15 @@ public final class ChatScene implements Restorable {
} else {
pendingAttachment = new Attachment(recorder.finish(), AttachmentType.VOICE);
recording = false;
Platform.runLater(() -> { voiceButton.setText("Record Voice Message"); checkPostConditions(false); });
Platform.runLater(() -> {
voiceButton.setText("Record Voice Message");
checkPostConditions(false);
attachmentView.setImage(IconUtil.load(settings.getCurrentTheme().equals("dark") ? "/icons/attachment_present_white.png"
: "/icons/attachment_present_black.png", 20));
attachmentView.setVisible(true);
});
}
} catch (EnvoyException e) {
} catch (final EnvoyException e) {
logger.log(Level.SEVERE, "Could not record audio: ", e);
Platform.runLater(new Alert(AlertType.ERROR, "Could not record audio")::showAndWait);
}
@ -359,12 +368,13 @@ public final class ChatScene implements Restorable {
final var text = messageTextArea.getText().strip();
try {
// Create and send message
var builder = new MessageBuilder(localDB.getUser().getID(), currentChat.getRecipient().getID(), localDB.getIDGenerator()).setText(text);
final var builder = new MessageBuilder(localDB.getUser().getID(), currentChat.getRecipient().getID(), localDB.getIDGenerator())
.setText(text);
if (pendingAttachment != null) {
builder.setAttachment(pendingAttachment);
pendingAttachment = null;
}
var message = builder.build();
final var message = builder.build();
// Send message
writeProxy.writeMessage(message);