From 35d225b1715a1b29a5312b7f6442b92b5a9b6fa7 Mon Sep 17 00:00:00 2001 From: Anas Elgarhy Date: Wed, 2 Nov 2022 23:06:04 +0200 Subject: [PATCH] Improve the code yooo --- build.gradle.kts | 2 +- .../plugins/ayah/AyahStartupActivity.java | 4 ++-- .../plugins/ayah/NotificationTimer.java | 4 ++-- .../plugins/ayah/NotificationTimerTask.java | 8 ++++---- .../plugins/ayah/audio/AudioPlayer.java | 8 ++++---- .../plugins/ayah/audio/PlayerListener.java | 8 ++++---- .../ayah/dialogs/AyahDetailsDialog.java | 9 +++++++-- .../settings/AyahSettingsConfigurable.java | 4 ++-- .../ayah/settings/AyahSettingsState.java | 4 ++-- .../plugins/ayah/settings/BasmalhOnStart.java | 6 ++++-- .../plugins/ayah/settings/SelectedEdition.java | 4 ++-- .../settings/userinterface/PanelBuilder.java | 4 ++-- .../userinterface/ReadableEdition.java | 18 +++++++----------- .../userinterface/SettingsComponent.java | 4 ++-- src/main/resources/META-INF/plugin.xml | 8 ++------ 15 files changed, 47 insertions(+), 48 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index a1eab61..d4c5ad2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -12,7 +12,7 @@ repositories { } dependencies { - implementation("com.github.anas-elgarhy:alquran-cloud-api:0.4.0-v1") + implementation("com.github.anas-elgarhy:alquran-cloud-api:0.4.0-v1") // TODO: fix this implementation("com.miglayout:miglayout-swing:11.0") // implementation("com.github.goxr3plus:java-stream-player:10.0.2") implementation("com.googlecode.soundlibs:jlayer:1.0.1.4") diff --git a/src/main/java/com/anas/intellij/plugins/ayah/AyahStartupActivity.java b/src/main/java/com/anas/intellij/plugins/ayah/AyahStartupActivity.java index a69c0a7..525e35f 100644 --- a/src/main/java/com/anas/intellij/plugins/ayah/AyahStartupActivity.java +++ b/src/main/java/com/anas/intellij/plugins/ayah/AyahStartupActivity.java @@ -12,8 +12,8 @@ import org.jetbrains.annotations.NotNull; import java.io.IOException; /** - * @author: Anas Elgarhy - * @date: 8/18/22 + * @author Anas Elgarhy + * @since 8/18/22 */ public class AyahStartupActivity implements StartupActivity { @Override diff --git a/src/main/java/com/anas/intellij/plugins/ayah/NotificationTimer.java b/src/main/java/com/anas/intellij/plugins/ayah/NotificationTimer.java index adec670..91ccfd6 100644 --- a/src/main/java/com/anas/intellij/plugins/ayah/NotificationTimer.java +++ b/src/main/java/com/anas/intellij/plugins/ayah/NotificationTimer.java @@ -7,8 +7,8 @@ import org.jetbrains.annotations.NotNull; import java.util.Timer; /** - * @author: Anas Elgarhy - * @date: 8/19/22 + * @author Anas Elgarhy + * @since 8/19/22 */ public enum NotificationTimer { INSTANCE diff --git a/src/main/java/com/anas/intellij/plugins/ayah/NotificationTimerTask.java b/src/main/java/com/anas/intellij/plugins/ayah/NotificationTimerTask.java index 78ea9a7..2add5fb 100644 --- a/src/main/java/com/anas/intellij/plugins/ayah/NotificationTimerTask.java +++ b/src/main/java/com/anas/intellij/plugins/ayah/NotificationTimerTask.java @@ -20,8 +20,8 @@ import java.util.TimerTask; import java.util.logging.Logger; /** - * @author: Anas Elgarhy - * @date: 8/19/22 + * @author Anas Elgarhy + * @since 8/19/22 */ public class NotificationTimerTask extends TimerTask implements PlayerListener { private Project project; @@ -103,12 +103,12 @@ public class NotificationTimerTask extends TimerTask implements PlayerListener { // Player listener methods. @Override - public void onStarted(final PlaybackEvent event) { + public void onStarted() { isPlaying = true; } @Override - public void onFinished(PlaybackEvent event) { + public void onFinished() { isPlaying = false; } } diff --git a/src/main/java/com/anas/intellij/plugins/ayah/audio/AudioPlayer.java b/src/main/java/com/anas/intellij/plugins/ayah/audio/AudioPlayer.java index 2f78291..b64c124 100644 --- a/src/main/java/com/anas/intellij/plugins/ayah/audio/AudioPlayer.java +++ b/src/main/java/com/anas/intellij/plugins/ayah/audio/AudioPlayer.java @@ -15,8 +15,8 @@ import java.net.URL; import java.util.logging.Logger; /** - * @author: Anas Elgarhy - * @date: 8/19/22 + * @author Anas Elgarhy + * @since 8/19/22 */ public class AudioPlayer { private final String audioUrl; @@ -56,12 +56,12 @@ public class AudioPlayer { player.setPlayBackListener(new PlaybackListener() { @Override public void playbackStarted(final PlaybackEvent evt) { - listener.onStarted(evt); + listener.onStarted(); } @Override public void playbackFinished(final PlaybackEvent evt) { - listener.onFinished(evt); + listener.onFinished(); } }); } diff --git a/src/main/java/com/anas/intellij/plugins/ayah/audio/PlayerListener.java b/src/main/java/com/anas/intellij/plugins/ayah/audio/PlayerListener.java index 40d45eb..696cfac 100644 --- a/src/main/java/com/anas/intellij/plugins/ayah/audio/PlayerListener.java +++ b/src/main/java/com/anas/intellij/plugins/ayah/audio/PlayerListener.java @@ -3,10 +3,10 @@ package com.anas.intellij.plugins.ayah.audio; import javazoom.jl.player.advanced.PlaybackEvent; /** - * @author: Anas Elgarhy - * @date: 8/22/22 + * @author Anas Elgarhy + * @since 8/22/22 */ public interface PlayerListener { - void onStarted(final PlaybackEvent event); - void onFinished(final PlaybackEvent event); + void onStarted(); + void onFinished(); } diff --git a/src/main/java/com/anas/intellij/plugins/ayah/dialogs/AyahDetailsDialog.java b/src/main/java/com/anas/intellij/plugins/ayah/dialogs/AyahDetailsDialog.java index 3f242c4..a0f8a1b 100644 --- a/src/main/java/com/anas/intellij/plugins/ayah/dialogs/AyahDetailsDialog.java +++ b/src/main/java/com/anas/intellij/plugins/ayah/dialogs/AyahDetailsDialog.java @@ -12,6 +12,11 @@ import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.io.IOException; +/** + * @author Anas Elgarhy + * @since 8/19/22 + */ + public class AyahDetailsDialog extends JDialog implements PlayerListener { private JPanel contentPane; private JButton playButton; @@ -138,13 +143,13 @@ public class AyahDetailsDialog extends JDialog implements PlayerListener { } @Override - public void onStarted(final PlaybackEvent event) { + public void onStarted() { playButton.setText("Stop"); isPlaying = true; } @Override - public void onFinished(final PlaybackEvent event) { + public void onFinished() { if (autoPlayCheckBox.isSelected() && ayah.getNumber() <= Constants.AYAHS_COUNT) { if (loadTheAyah(ayah.getNumber() + 1)) { audioPlayer = new AudioPlayer(ayah.getAudioUrl()).setListener(this); diff --git a/src/main/java/com/anas/intellij/plugins/ayah/settings/AyahSettingsConfigurable.java b/src/main/java/com/anas/intellij/plugins/ayah/settings/AyahSettingsConfigurable.java index 23dc275..f7094d3 100644 --- a/src/main/java/com/anas/intellij/plugins/ayah/settings/AyahSettingsConfigurable.java +++ b/src/main/java/com/anas/intellij/plugins/ayah/settings/AyahSettingsConfigurable.java @@ -9,8 +9,8 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; /** - * @author: Anas Elgarhy - * @date: 8/19/22 + * @author Anas Elgarhy + * @since 8/19/22 */ public class AyahSettingsConfigurable implements Configurable { diff --git a/src/main/java/com/anas/intellij/plugins/ayah/settings/AyahSettingsState.java b/src/main/java/com/anas/intellij/plugins/ayah/settings/AyahSettingsState.java index 4cf3148..64c8505 100644 --- a/src/main/java/com/anas/intellij/plugins/ayah/settings/AyahSettingsState.java +++ b/src/main/java/com/anas/intellij/plugins/ayah/settings/AyahSettingsState.java @@ -14,8 +14,8 @@ import org.jetbrains.annotations.Nullable; /** - * @author: Anas Elgarhy - * @date: 8/19/22 + * @author Anas Elgarhy + * @since 8/19/22 */ @Getter @Setter diff --git a/src/main/java/com/anas/intellij/plugins/ayah/settings/BasmalhOnStart.java b/src/main/java/com/anas/intellij/plugins/ayah/settings/BasmalhOnStart.java index 95c8985..c68d821 100644 --- a/src/main/java/com/anas/intellij/plugins/ayah/settings/BasmalhOnStart.java +++ b/src/main/java/com/anas/intellij/plugins/ayah/settings/BasmalhOnStart.java @@ -1,17 +1,19 @@ package com.anas.intellij.plugins.ayah.settings; import lombok.Getter; +import lombok.NonNull; import lombok.Setter; /** - * @author: Anas Elgarhy - * @date: 8/19/22 + * @author Anas Elgarhy + * @since 8/19/22 */ @Getter @Setter public class BasmalhOnStart { private boolean isActive; private boolean isSoundActive; + @NonNull private SelectedEdition edition; public BasmalhOnStart() { diff --git a/src/main/java/com/anas/intellij/plugins/ayah/settings/SelectedEdition.java b/src/main/java/com/anas/intellij/plugins/ayah/settings/SelectedEdition.java index 851c82e..7dd3e3b 100644 --- a/src/main/java/com/anas/intellij/plugins/ayah/settings/SelectedEdition.java +++ b/src/main/java/com/anas/intellij/plugins/ayah/settings/SelectedEdition.java @@ -9,8 +9,8 @@ import lombok.Setter; import java.io.IOException; /** - * @author: Anas Elgarhy - * @date: 8/21/22 + * @author Anas Elgarhy + * @since 8/21/22 */ @AllArgsConstructor @Getter diff --git a/src/main/java/com/anas/intellij/plugins/ayah/settings/userinterface/PanelBuilder.java b/src/main/java/com/anas/intellij/plugins/ayah/settings/userinterface/PanelBuilder.java index 0134d38..ce6e393 100644 --- a/src/main/java/com/anas/intellij/plugins/ayah/settings/userinterface/PanelBuilder.java +++ b/src/main/java/com/anas/intellij/plugins/ayah/settings/userinterface/PanelBuilder.java @@ -5,8 +5,8 @@ import javax.swing.border.Border; import java.awt.*; /** - * @author: Anas Elgarhy - * @date: 8/19/22 + * @author Anas Elgarhy + * @since 8/19/22 */ public class PanelBuilder { private final JPanel panel; diff --git a/src/main/java/com/anas/intellij/plugins/ayah/settings/userinterface/ReadableEdition.java b/src/main/java/com/anas/intellij/plugins/ayah/settings/userinterface/ReadableEdition.java index c9f0492..de3ff6b 100644 --- a/src/main/java/com/anas/intellij/plugins/ayah/settings/userinterface/ReadableEdition.java +++ b/src/main/java/com/anas/intellij/plugins/ayah/settings/userinterface/ReadableEdition.java @@ -1,26 +1,22 @@ package com.anas.intellij.plugins.ayah.settings.userinterface; import com.anas.alqurancloudapi.edition.Edition; +import lombok.Getter; +import lombok.RequiredArgsConstructor; /** - * @author: Anas Elgarhy - * @date: 8/20/22 + * @author Anas Elgarhy + * @since 8/20/22 */ +@RequiredArgsConstructor +@Getter public class ReadableEdition { - private Edition edition; - - public ReadableEdition(final Edition edition) { - this.edition = edition; - } + private final Edition edition; public ReadableEdition(final String identifier) { this.edition = new Edition(identifier); } - public Edition getEdition() { - return edition; - } - @Override public String toString() { return edition.getName() + " (" + edition.getLanguage() + ")"; diff --git a/src/main/java/com/anas/intellij/plugins/ayah/settings/userinterface/SettingsComponent.java b/src/main/java/com/anas/intellij/plugins/ayah/settings/userinterface/SettingsComponent.java index 6e10ed9..ced1c85 100644 --- a/src/main/java/com/anas/intellij/plugins/ayah/settings/userinterface/SettingsComponent.java +++ b/src/main/java/com/anas/intellij/plugins/ayah/settings/userinterface/SettingsComponent.java @@ -19,8 +19,8 @@ import java.util.logging.Logger; /** * The settings UI. * - * @author: Anas Elgarhy - * @date: 8/19/22 + * @author Anas Elgarhy + * @since 8/19/22 */ public class SettingsComponent { private final JPanel panel; diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index e005c71..776f0e3 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -41,11 +41,7 @@ Read more: https://plugins.jetbrains.com/docs/intellij/plugin-compatibility.html --> com.intellij.modules.platform - - - - + @@ -62,4 +58,4 @@ - \ No newline at end of file +