Merge branch 'anas-elgarhy:master' into master

This commit is contained in:
Yosef Mahmmoud 2022-11-07 13:22:37 +02:00 committed by GitHub
commit 965454ec4b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 97 additions and 134 deletions

6
.idea/jpa-buddy.xml Normal file
View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JpaBuddyIdeaProjectConfig">
<option name="renamerInitialized" value="true" />
</component>
</project>

View file

@ -7,4 +7,7 @@
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="17" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" /> <output url="file://$PROJECT_DIR$/out" />
</component> </component>
<component name="ProjectType">
<option name="id" value="jpab" />
</component>
</project> </project>

View file

@ -1,6 +1,6 @@
plugins { plugins {
id("java") id("java")
id("org.jetbrains.intellij") version "1.8.0" id("org.jetbrains.intellij") version "1.9.0"
} }
group = "com.anas.intellij.plugins.ayah" group = "com.anas.intellij.plugins.ayah"
@ -12,10 +12,16 @@ repositories {
} }
dependencies { 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.miglayout:miglayout-swing:11.0")
// implementation("com.github.goxr3plus:java-stream-player:10.0.2") // implementation("com.github.goxr3plus:java-stream-player:10.0.2")
implementation("com.googlecode.soundlibs:jlayer:1.0.1.4") implementation("com.googlecode.soundlibs:jlayer:1.0.1.4")
compileOnly("org.projectlombok:lombok:1.18.24")
annotationProcessor("org.projectlombok:lombok:1.18.24")
testImplementation("org.projectlombok:lombok:1.18.24")
testAnnotationProcessor("org.projectlombok:lombok:1.18.24")
} }
java { java {
sourceCompatibility = JavaVersion.VERSION_11 sourceCompatibility = JavaVersion.VERSION_11
@ -42,7 +48,7 @@ tasks {
patchPluginXml { patchPluginXml {
sinceBuild.set("213") sinceBuild.set("213")
untilBuild.set("222.*") untilBuild.set("223.*")
} }
signPlugin { signPlugin {

View file

@ -7,22 +7,23 @@ import com.intellij.notification.NotificationGroupManager;
import com.intellij.notification.NotificationType; import com.intellij.notification.NotificationType;
import com.intellij.openapi.project.Project; import com.intellij.openapi.project.Project;
import com.intellij.openapi.startup.StartupActivity; import com.intellij.openapi.startup.StartupActivity;
import lombok.val;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.io.IOException; import java.io.IOException;
/** /**
* @author: <a href="https://github.com/anas-elgarhy">Anas Elgarhy</a> * @author <a href="https://github.com/anas-elgarhy">Anas Elgarhy</a>
* @date: 8/18/22 * @since 8/18/22
*/ */
public class AyahStartupActivity implements StartupActivity { public class AyahStartupActivity implements StartupActivity {
@Override @Override
public void runActivity(@NotNull final Project project) { public void runActivity(@NotNull final Project project) {
final var basmalhOnStartSettingsState = AyahSettingsState.getInstance().getBasmalhOnStart(); val basmalhOnStartSettingsState = AyahSettingsState.getInstance().getBasmalhOnStart();
// Basmalh on start // Basmalh on start
if (basmalhOnStartSettingsState.isActive()) { if (basmalhOnStartSettingsState.isActive()) {
try { try {
final var bassmalh = Ayah.getAyah(1, val bassmalh = Ayah.getAyah(1,
basmalhOnStartSettingsState.getEdition().getEditionIdentifier()); basmalhOnStartSettingsState.getEdition().getEditionIdentifier());
NotificationGroupManager.getInstance() NotificationGroupManager.getInstance()
.getNotificationGroup("Basmalh on Start") .getNotificationGroup("Basmalh on Start")

View file

@ -7,8 +7,8 @@ import org.jetbrains.annotations.NotNull;
import java.util.Timer; import java.util.Timer;
/** /**
* @author: <a href="https://github.com/anas-elgarhy">Anas Elgarhy</a> * @author <a href="https://github.com/anas-elgarhy">Anas Elgarhy</a>
* @date: 8/19/22 * @since 8/19/22
*/ */
public enum NotificationTimer { public enum NotificationTimer {
INSTANCE INSTANCE
@ -16,14 +16,21 @@ public enum NotificationTimer {
private final Timer timer; private final Timer timer;
private final NotificationTimerTask notificationTimerTask; private final NotificationTimerTask notificationTimerTask;
private boolean isRunning;
NotificationTimer() { NotificationTimer() {
timer = new Timer(); timer = new Timer();
notificationTimerTask = new NotificationTimerTask(); notificationTimerTask = new NotificationTimerTask();
isRunning = false;
} }
public void start(@NotNull Project project) { public void start(@NotNull Project project) {
if (isRunning) {
return;
}
notificationTimerTask.setProject(project); notificationTimerTask.setProject(project);
schedule(AyahSettingsState.getInstance().getIntervalTimeBetweenNotifications()); schedule(AyahSettingsState.getInstance().getIntervalTimeBetweenNotifications());
isRunning = true;
} }
public void updateIntervalTimeBetweenNotifications(final int intervalTimeBetweenNotifications) { public void updateIntervalTimeBetweenNotifications(final int intervalTimeBetweenNotifications) {

View file

@ -22,8 +22,8 @@ import java.util.TimerTask;
import java.util.logging.Logger; import java.util.logging.Logger;
/** /**
* @author: <a href="https://github.com/anas-elgarhy">Anas Elgarhy</a> * @author <a href="https://github.com/anas-elgarhy">Anas Elgarhy</a>
* @date: 8/19/22 * @since 8/19/22
*/ */
public class NotificationTimerTask extends TimerTask implements PlayerListener { public class NotificationTimerTask extends TimerTask implements PlayerListener {
private Project project; private Project project;
@ -124,12 +124,12 @@ public class NotificationTimerTask extends TimerTask implements PlayerListener {
// Player listener methods. // Player listener methods.
@Override @Override
public void onStarted(final PlaybackEvent event) { public void onStarted() {
isPlaying = true; isPlaying = true;
} }
@Override @Override
public void onFinished(PlaybackEvent event) { public void onFinished() {
isPlaying = false; isPlaying = false;
new Thread(() -> { new Thread(() -> {
try { try {

View file

@ -15,8 +15,8 @@ import java.net.URL;
import java.util.logging.Logger; import java.util.logging.Logger;
/** /**
* @author: <a href="https://github.com/anas-elgarhy">Anas Elgarhy</a> * @author <a href="https://github.com/anas-elgarhy">Anas Elgarhy</a>
* @date: 8/19/22 * @since 8/19/22
*/ */
public class AudioPlayer { public class AudioPlayer {
private final String audioUrl; private final String audioUrl;
@ -56,12 +56,12 @@ public class AudioPlayer {
player.setPlayBackListener(new PlaybackListener() { player.setPlayBackListener(new PlaybackListener() {
@Override @Override
public void playbackStarted(final PlaybackEvent evt) { public void playbackStarted(final PlaybackEvent evt) {
listener.onStarted(evt); listener.onStarted();
} }
@Override @Override
public void playbackFinished(final PlaybackEvent evt) { public void playbackFinished(final PlaybackEvent evt) {
listener.onFinished(evt); listener.onFinished();
} }
}); });
} }

View file

@ -3,10 +3,10 @@ package com.anas.intellij.plugins.ayah.audio;
import javazoom.jl.player.advanced.PlaybackEvent; import javazoom.jl.player.advanced.PlaybackEvent;
/** /**
* @author: <a href="https://github.com/anas-elgarhy">Anas Elgarhy</a> * @author <a href="https://github.com/anas-elgarhy">Anas Elgarhy</a>
* @date: 8/22/22 * @since 8/22/22
*/ */
public interface PlayerListener { public interface PlayerListener {
void onStarted(final PlaybackEvent event); void onStarted();
void onFinished(final PlaybackEvent event); void onFinished();
} }

View file

@ -12,6 +12,11 @@ import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent; import java.awt.event.WindowEvent;
import java.io.IOException; import java.io.IOException;
/**
* @author <a href="https://github.com/anas-elgarhy">Anas Elgarhy</a>
* @since 8/19/22
*/
public class AyahDetailsDialog extends JDialog implements PlayerListener { public class AyahDetailsDialog extends JDialog implements PlayerListener {
private JPanel contentPane; private JPanel contentPane;
private JButton playButton; private JButton playButton;
@ -138,13 +143,13 @@ public class AyahDetailsDialog extends JDialog implements PlayerListener {
} }
@Override @Override
public void onStarted(final PlaybackEvent event) { public void onStarted() {
playButton.setText("Stop"); playButton.setText("Stop");
isPlaying = true; isPlaying = true;
} }
@Override @Override
public void onFinished(final PlaybackEvent event) { public void onFinished() {
if (autoPlayCheckBox.isSelected() && ayah.getNumber() <= Constants.AYAHS_COUNT) { if (autoPlayCheckBox.isSelected() && ayah.getNumber() <= Constants.AYAHS_COUNT) {
if (loadTheAyah(ayah.getNumber() + 1)) { if (loadTheAyah(ayah.getNumber() + 1)) {
audioPlayer = new AudioPlayer(ayah.getAudioUrl()).setListener(this); audioPlayer = new AudioPlayer(ayah.getAudioUrl()).setListener(this);

View file

@ -1,6 +1,7 @@
package com.anas.intellij.plugins.ayah.settings; package com.anas.intellij.plugins.ayah.settings;
import com.anas.intellij.plugins.ayah.NotificationTimer; import com.anas.intellij.plugins.ayah.NotificationTimer;
import com.anas.intellij.plugins.ayah.settings.userinterface.SettingsComponent;
import com.intellij.openapi.options.Configurable; import com.intellij.openapi.options.Configurable;
import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@ -8,8 +9,8 @@ import org.jetbrains.annotations.Nullable;
import javax.swing.*; import javax.swing.*;
/** /**
* @author: <a href="https://github.com/anas-elgarhy">Anas Elgarhy</a> * @author <a href="https://github.com/anas-elgarhy">Anas Elgarhy</a>
* @date: 8/19/22 * @since 8/19/22
*/ */
public class AyahSettingsConfigurable implements Configurable { public class AyahSettingsConfigurable implements Configurable {

View file

@ -7,15 +7,18 @@ import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.openapi.components.State; import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage; import com.intellij.openapi.components.Storage;
import com.intellij.util.xmlb.XmlSerializerUtil; import com.intellij.util.xmlb.XmlSerializerUtil;
import lombok.Getter;
import lombok.Setter;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.io.IOException;
/** /**
* @author: <a href="https://github.com/anas-elgarhy">Anas Elgarhy</a> * @author <a href="https://github.com/anas-elgarhy">Anas Elgarhy</a>
* @date: 8/19/22 * @since 8/19/22
*/ */
@Getter
@Setter
@State( @State(
name = "com.anas.intellij.plugins.ayah.settings.AyahSettingsState", name = "com.anas.intellij.plugins.ayah.settings.AyahSettingsState",
storages = @Storage("ayah.xml") storages = @Storage("ayah.xml")
@ -47,36 +50,4 @@ public class AyahSettingsState implements PersistentStateComponent<AyahSettingsS
public void loadState(@NotNull final AyahSettingsState state) { public void loadState(@NotNull final AyahSettingsState state) {
XmlSerializerUtil.copyBean(state, this); XmlSerializerUtil.copyBean(state, this);
} }
public BasmalhOnStart getBasmalhOnStart() {
return basmalhOnStart;
}
public void setBasmalhOnStart(final BasmalhOnStart basmalhOnStart) {
this.basmalhOnStart = basmalhOnStart;
}
public int getIntervalTimeBetweenNotifications() {
return intervalTimeBetweenNotifications;
}
public void setIntervalTimeBetweenNotifications(final int intervalTimeBetweenNotifications) {
this.intervalTimeBetweenNotifications = intervalTimeBetweenNotifications;
}
public boolean isAutoPlayAudio() {
return autoPlayAudio;
}
public void setAutoPlayAudio(final boolean autoPlayAudio) {
this.autoPlayAudio = autoPlayAudio;
}
public SelectedEdition getEdition() {
return edition;
}
public void setEdition(final SelectedEdition edition) {
this.edition = edition;
}
} }

View file

@ -1,17 +1,19 @@
package com.anas.intellij.plugins.ayah.settings; package com.anas.intellij.plugins.ayah.settings;
import com.anas.alqurancloudapi.edition.Edition; import lombok.Getter;
import com.anas.alqurancloudapi.edition.EditionFormat; import lombok.NonNull;
import lombok.Setter;
import java.io.IOException;
/** /**
* @author: <a href="https://github.com/anas-elgarhy">Anas Elgarhy</a> * @author <a href="https://github.com/anas-elgarhy">Anas Elgarhy</a>
* @date: 8/19/22 * @since 8/19/22
*/ */
@Getter
@Setter
public class BasmalhOnStart { public class BasmalhOnStart {
private boolean isActive; private boolean isActive;
private boolean isSoundActive; private boolean isSoundActive;
@NonNull
private SelectedEdition edition; private SelectedEdition edition;
public BasmalhOnStart() { public BasmalhOnStart() {
@ -19,28 +21,4 @@ public class BasmalhOnStart {
isSoundActive = false; isSoundActive = false;
edition = new SelectedEdition(); edition = new SelectedEdition();
} }
public boolean isActive() {
return isActive;
}
public void setActive(final boolean active) {
isActive = active;
}
public boolean isSoundActive() {
return isSoundActive;
}
public void setSoundActive(final boolean soundActive) {
isSoundActive = soundActive;
}
public SelectedEdition getEdition() {
return edition;
}
public void setEdition(final SelectedEdition edition) {
this.edition = edition;
}
} }

View file

@ -2,13 +2,19 @@ package com.anas.intellij.plugins.ayah.settings;
import com.anas.alqurancloudapi.edition.Edition; import com.anas.alqurancloudapi.edition.Edition;
import com.anas.alqurancloudapi.edition.EditionFormat; import com.anas.alqurancloudapi.edition.EditionFormat;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import java.io.IOException; import java.io.IOException;
/** /**
* @author: <a href="https://github.com/anas-elgarhy">Anas Elgarhy</a> * @author <a href="https://github.com/anas-elgarhy">Anas Elgarhy</a>
* @date: 8/21/22 * @since 8/21/22
*/ */
@AllArgsConstructor
@Getter
@Setter
public class SelectedEdition { public class SelectedEdition {
private String editionIdentifier; private String editionIdentifier;
private int index; private int index;
@ -22,27 +28,4 @@ public class SelectedEdition {
} }
index = 0; index = 0;
} }
public SelectedEdition(final String editionIdentifier, final int index) {
this.editionIdentifier = editionIdentifier;
this.index = index;
}
public String getEditionIdentifier() {
return editionIdentifier;
}
// For XML serialization
public void setEditionIdentifier(final String editionIdentifier) {
this.editionIdentifier = editionIdentifier;
}
public int getIndex() {
return index;
}
// For XML serialization
public void setIndex(final int index) {
this.index = index;
}
} }

View file

@ -1,12 +1,12 @@
package com.anas.intellij.plugins.ayah.settings; package com.anas.intellij.plugins.ayah.settings.userinterface;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.Border; import javax.swing.border.Border;
import java.awt.*; import java.awt.*;
/** /**
* @author: <a href="https://github.com/anas-elgarhy">Anas Elgarhy</a> * @author <a href="https://github.com/anas-elgarhy">Anas Elgarhy</a>
* @date: 8/19/22 * @since 8/19/22
*/ */
public class PanelBuilder { public class PanelBuilder {
private final JPanel panel; private final JPanel panel;

View file

@ -1,26 +1,22 @@
package com.anas.intellij.plugins.ayah.settings; package com.anas.intellij.plugins.ayah.settings.userinterface;
import com.anas.alqurancloudapi.edition.Edition; import com.anas.alqurancloudapi.edition.Edition;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
/** /**
* @author: <a href="https://github.com/anas-elgarhy">Anas Elgarhy</a> * @author <a href="https://github.com/anas-elgarhy">Anas Elgarhy</a>
* @date: 8/20/22 * @since 8/20/22
*/ */
@RequiredArgsConstructor
@Getter
public class ReadableEdition { public class ReadableEdition {
private Edition edition; private final Edition edition;
public ReadableEdition(final Edition edition) {
this.edition = edition;
}
public ReadableEdition(final String identifier) { public ReadableEdition(final String identifier) {
this.edition = new Edition(identifier); this.edition = new Edition(identifier);
} }
public Edition getEdition() {
return edition;
}
@Override @Override
public String toString() { public String toString() {
return edition.getName() + " (" + edition.getLanguage() + ")"; return edition.getName() + " (" + edition.getLanguage() + ")";

View file

@ -1,8 +1,11 @@
package com.anas.intellij.plugins.ayah.settings; package com.anas.intellij.plugins.ayah.settings.userinterface;
import com.anas.alqurancloudapi.edition.Edition; import com.anas.alqurancloudapi.edition.Edition;
import com.anas.alqurancloudapi.edition.EditionFormat; import com.anas.alqurancloudapi.edition.EditionFormat;
import com.anas.intellij.plugins.ayah.settings.AyahSettingsState;
import com.anas.intellij.plugins.ayah.settings.BasmalhOnStart;
import com.anas.intellij.plugins.ayah.settings.SelectedEdition;
import com.intellij.ui.components.JBCheckBox; import com.intellij.ui.components.JBCheckBox;
import com.intellij.ui.components.JBLabel; import com.intellij.ui.components.JBLabel;
import com.intellij.util.ui.FormBuilder; import com.intellij.util.ui.FormBuilder;
@ -16,8 +19,8 @@ import java.util.logging.Logger;
/** /**
* The settings UI. * The settings UI.
* *
* @author: <a href="https://github.com/anas-elgarhy">Anas Elgarhy</a> * @author <a href="https://github.com/anas-elgarhy">Anas Elgarhy</a>
* @date: 8/19/22 * @since 8/19/22
*/ */
public class SettingsComponent { public class SettingsComponent {
private final JPanel panel; private final JPanel panel;

View file

@ -3,6 +3,8 @@
<!-- Unique identifier of the plugin. It should be FQN. It cannot be changed between the plugin versions. --> <!-- Unique identifier of the plugin. It should be FQN. It cannot be changed between the plugin versions. -->
<id>com.anas.intellij.plugins.ayah</id> <id>com.anas.intellij.plugins.ayah</id>
<depends>com.intellij.modules.platform</depends>
<!-- Public plugin name should be written in Title Case. <!-- Public plugin name should be written in Title Case.
Guidelines: https://plugins.jetbrains.com/docs/marketplace/plugin-overview-page.html#plugin-name --> Guidelines: https://plugins.jetbrains.com/docs/marketplace/plugin-overview-page.html#plugin-name -->
<name>Ayah</name> <name>Ayah</name>
@ -39,6 +41,7 @@
Read more: https://plugins.jetbrains.com/docs/intellij/plugin-compatibility.html --> Read more: https://plugins.jetbrains.com/docs/intellij/plugin-compatibility.html -->
<depends>com.intellij.modules.platform</depends> <depends>com.intellij.modules.platform</depends>
<!-- Extension points defined by the plugin. <!-- Extension points defined by the plugin.
Read more: https://plugins.jetbrains.com/docs/intellij/plugin-extension-points.html --> Read more: https://plugins.jetbrains.com/docs/intellij/plugin-extension-points.html -->
<extensions defaultExtensionNs="com.intellij"> <extensions defaultExtensionNs="com.intellij">
@ -55,4 +58,4 @@
<notificationGroup displayType="BALLOON" id="Basmalh on Start" /> <notificationGroup displayType="BALLOON" id="Basmalh on Start" />
<notificationGroup displayType="BALLOON" id="Random Ayah Notification" /> <notificationGroup displayType="BALLOON" id="Random Ayah Notification" />
</extensions> </extensions>
</idea-plugin> </idea-plugin>