From 85bfe1839035a905c17cf519508f5945f83a3a40 Mon Sep 17 00:00:00 2001 From: delvh Date: Sun, 5 Jul 2020 15:37:13 +0200 Subject: [PATCH] Cleaned up a bit --- .settings/org.eclipse.jdt.core.prefs | 6 +++--- .../envoy/client/data/audio/AudioPlayer.java | 12 ++++++------ .../envoy/client/data/audio/AudioRecorder.java | 18 +++++++++--------- .../java/envoy/client/ui/AudioControl.java | 4 ++-- .../client/ui/listcell/MessageControl.java | 16 ++++++++++++---- src/main/resources/css/base.css | 6 +++++- 6 files changed, 37 insertions(+), 25 deletions(-) diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index 5e625c6..65c71af 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -245,7 +245,7 @@ org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert org.eclipse.jdt.core.formatter.insert_new_line_after_label=insert org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=insert org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert @@ -439,7 +439,7 @@ org.eclipse.jdt.core.formatter.keep_code_block_on_one_line=one_line_if_empty org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=true org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false org.eclipse.jdt.core.formatter.keep_enum_constant_declaration_on_one_line=one_line_never -org.eclipse.jdt.core.formatter.keep_enum_declaration_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_enum_declaration_on_one_line=one_line_if_empty org.eclipse.jdt.core.formatter.keep_if_then_body_block_on_one_line=one_line_if_single_item org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false org.eclipse.jdt.core.formatter.keep_lambda_body_block_on_one_line=one_line_always @@ -450,7 +450,7 @@ org.eclipse.jdt.core.formatter.keep_simple_for_body_on_same_line=false org.eclipse.jdt.core.formatter.keep_simple_getter_setter_on_one_line=true org.eclipse.jdt.core.formatter.keep_simple_while_body_on_same_line=false org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=true -org.eclipse.jdt.core.formatter.keep_type_declaration_on_one_line=one_line_never +org.eclipse.jdt.core.formatter.keep_type_declaration_on_one_line=one_line_if_empty org.eclipse.jdt.core.formatter.lineSplit=150 org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false diff --git a/src/main/java/envoy/client/data/audio/AudioPlayer.java b/src/main/java/envoy/client/data/audio/AudioPlayer.java index acdc576..61982db 100644 --- a/src/main/java/envoy/client/data/audio/AudioPlayer.java +++ b/src/main/java/envoy/client/data/audio/AudioPlayer.java @@ -10,27 +10,27 @@ import envoy.exception.EnvoyException; * Project: envoy-client
* File: AudioPlayer.java
* Created: 05.07.2020
- * + * * @author Kai S. K. Engelbart * @since Envoy Client v0.1-beta */ public final class AudioPlayer { - private final AudioFormat format; + private final AudioFormat format; private final DataLine.Info info; private Clip clip; /** * Initializes the player with the default audio format. - * + * * @since Envoy Client v0.1-beta */ public AudioPlayer() { this(AudioRecorder.DEFAULT_AUDIO_FORMAT); } /** * Initializes the player with a given audio format. - * + * * @param format the audio format to use * @since Envoy Client v0.1-beta */ @@ -47,7 +47,7 @@ public final class AudioPlayer { /** * Plays back an audio clip. - * + * * @param data the data of the clip * @throws EnvoyException if the play back failed * @since Envoy Client v0.1-beta @@ -57,7 +57,7 @@ public final class AudioPlayer { clip = (Clip) AudioSystem.getLine(info); clip.open(format, data, 0, data.length); clip.start(); - } catch (LineUnavailableException e) { + } catch (final LineUnavailableException e) { throw new EnvoyException("Cannot play back audio", e); } } diff --git a/src/main/java/envoy/client/data/audio/AudioRecorder.java b/src/main/java/envoy/client/data/audio/AudioRecorder.java index c6a4ed2..85dafae 100644 --- a/src/main/java/envoy/client/data/audio/AudioRecorder.java +++ b/src/main/java/envoy/client/data/audio/AudioRecorder.java @@ -22,7 +22,7 @@ public final class AudioRecorder { /** * The default audio format used for recording and play back. - * + * * @since Envoy Client v0.1-beta */ public static final AudioFormat DEFAULT_AUDIO_FORMAT = new AudioFormat(16000, 16, 1, true, false); @@ -35,14 +35,14 @@ public final class AudioRecorder { /** * Initializes the recorder with the default audio format. - * + * * @since Envoy Client v0.1-beta */ public AudioRecorder() { this(DEFAULT_AUDIO_FORMAT); } /** * Initializes the recorder with a given audio format. - * + * * @param format the audio format to use * @since Envoy Client v0.1-beta */ @@ -65,7 +65,7 @@ public final class AudioRecorder { /** * Starts the audio recording. - * + * * @throws EnvoyException if starting the recording failed * @since Envoy Client v0.1-beta */ @@ -81,7 +81,7 @@ public final class AudioRecorder { tempFile = Files.createTempFile("recording", "wav"); // Start the recording - var ais = new AudioInputStream(line); + final var ais = new AudioInputStream(line); AudioSystem.write(ais, AudioFileFormat.Type.WAVE, tempFile.toFile()); } catch (IOException | LineUnavailableException e) { throw new EnvoyException("Cannot record voice", e); @@ -90,7 +90,7 @@ public final class AudioRecorder { /** * Stops the recording. - * + * * @return the finished recording * @throws EnvoyException if finishing the recording failed * @since Envoy Client v0.1-beta @@ -99,17 +99,17 @@ public final class AudioRecorder { try { line.stop(); line.close(); - byte[] data = Files.readAllBytes(tempFile); + final byte[] data = Files.readAllBytes(tempFile); Files.delete(tempFile); return data; - } catch (IOException e) { + } catch (final IOException e) { throw new EnvoyException("Cannot save voice recording", e); } } /** * Cancels the active recording. - * + * * @since Envoy Client v0.1-beta */ public void cancel() { diff --git a/src/main/java/envoy/client/ui/AudioControl.java b/src/main/java/envoy/client/ui/AudioControl.java index eca232f..d82fd24 100644 --- a/src/main/java/envoy/client/ui/AudioControl.java +++ b/src/main/java/envoy/client/ui/AudioControl.java @@ -18,7 +18,7 @@ import envoy.util.EnvoyLog; * Project: envoy-client
* File: AudioControl.java
* Created: 05.07.2020
- * + * * @author Kai S. K. Engelbart * @since Envoy Client v0.1-beta */ @@ -30,7 +30,7 @@ public final class AudioControl extends HBox { /** * Initializes the audio control. - * + * * @param audioData the audio data to play. * @since Envoy Client v0.1-beta */ diff --git a/src/main/java/envoy/client/ui/listcell/MessageControl.java b/src/main/java/envoy/client/ui/listcell/MessageControl.java index 7017f7c..a5a9404 100644 --- a/src/main/java/envoy/client/ui/listcell/MessageControl.java +++ b/src/main/java/envoy/client/ui/listcell/MessageControl.java @@ -11,7 +11,6 @@ import javafx.scene.layout.VBox; import envoy.client.ui.AudioControl; import envoy.client.ui.IconUtil; -import envoy.data.Attachment.AttachmentType; import envoy.data.Message; import envoy.data.Message.MessageStatus; import envoy.data.User; @@ -41,9 +40,18 @@ public class MessageControl extends VBox { // Creating the underlying VBox, the dateLabel and the textLabel super(new Label(dateFormat.format(message.getCreationDate()))); - // Voice attachment - if (message.hasAttachment() && message.getAttachment().getType() == AttachmentType.VOICE) - getChildren().add(new AudioControl(message.getAttachment().getData())); + // Handling message attachment display + if (message.hasAttachment()) switch (message.getAttachment().getType()) { + case PICTURE: + break; + case VIDEO: + break; + case VOICE: + getChildren().add(new AudioControl(message.getAttachment().getData())); + break; + case DOCUMENT: + break; + } final var textLabel = new Label(message.getText()); textLabel.setWrapText(true); diff --git a/src/main/resources/css/base.css b/src/main/resources/css/base.css index 9230b0f..2830bc6 100644 --- a/src/main/resources/css/base.css +++ b/src/main/resources/css/base.css @@ -1,4 +1,4 @@ -.button, .list-cell { +.button, .list-cell, .progress-bar * { -fx-background-radius: 5.0em; } @@ -26,6 +26,10 @@ -fx-text-fill: transparent; } +.progress-bar{ + -fx-progress-color: blue; +} + .online { -fx-text-fill: limegreen; }