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">
<output url="file://$PROJECT_DIR$/out" />
</component>
<component name="ProjectType">
<option name="id" value="jpab" />
</component>
</project>

View file

@ -1,6 +1,6 @@
plugins {
id("java")
id("org.jetbrains.intellij") version "1.8.0"
id("org.jetbrains.intellij") version "1.9.0"
}
group = "com.anas.intellij.plugins.ayah"
@ -12,10 +12,16 @@ 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")
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 {
sourceCompatibility = JavaVersion.VERSION_11
@ -42,7 +48,7 @@ tasks {
patchPluginXml {
sinceBuild.set("213")
untilBuild.set("222.*")
untilBuild.set("223.*")
}
signPlugin {

View file

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

View file

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

View file

@ -22,8 +22,8 @@ import java.util.TimerTask;
import java.util.logging.Logger;
/**
* @author: <a href="https://github.com/anas-elgarhy">Anas Elgarhy</a>
* @date: 8/19/22
* @author <a href="https://github.com/anas-elgarhy">Anas Elgarhy</a>
* @since 8/19/22
*/
public class NotificationTimerTask extends TimerTask implements PlayerListener {
private Project project;
@ -124,12 +124,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;
new Thread(() -> {
try {

View file

@ -15,8 +15,8 @@ import java.net.URL;
import java.util.logging.Logger;
/**
* @author: <a href="https://github.com/anas-elgarhy">Anas Elgarhy</a>
* @date: 8/19/22
* @author <a href="https://github.com/anas-elgarhy">Anas Elgarhy</a>
* @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();
}
});
}

View file

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

View file

@ -12,6 +12,11 @@ import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
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 {
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);

View file

@ -1,6 +1,7 @@
package com.anas.intellij.plugins.ayah.settings;
import com.anas.intellij.plugins.ayah.NotificationTimer;
import com.anas.intellij.plugins.ayah.settings.userinterface.SettingsComponent;
import com.intellij.openapi.options.Configurable;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.Nullable;
@ -8,8 +9,8 @@ import org.jetbrains.annotations.Nullable;
import javax.swing.*;
/**
* @author: <a href="https://github.com/anas-elgarhy">Anas Elgarhy</a>
* @date: 8/19/22
* @author <a href="https://github.com/anas-elgarhy">Anas Elgarhy</a>
* @since 8/19/22
*/
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.Storage;
import com.intellij.util.xmlb.XmlSerializerUtil;
import lombok.Getter;
import lombok.Setter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.IOException;
/**
* @author: <a href="https://github.com/anas-elgarhy">Anas Elgarhy</a>
* @date: 8/19/22
* @author <a href="https://github.com/anas-elgarhy">Anas Elgarhy</a>
* @since 8/19/22
*/
@Getter
@Setter
@State(
name = "com.anas.intellij.plugins.ayah.settings.AyahSettingsState",
storages = @Storage("ayah.xml")
@ -47,36 +50,4 @@ public class AyahSettingsState implements PersistentStateComponent<AyahSettingsS
public void loadState(@NotNull final AyahSettingsState state) {
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;
import com.anas.alqurancloudapi.edition.Edition;
import com.anas.alqurancloudapi.edition.EditionFormat;
import java.io.IOException;
import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;
/**
* @author: <a href="https://github.com/anas-elgarhy">Anas Elgarhy</a>
* @date: 8/19/22
* @author <a href="https://github.com/anas-elgarhy">Anas Elgarhy</a>
* @since 8/19/22
*/
@Getter
@Setter
public class BasmalhOnStart {
private boolean isActive;
private boolean isSoundActive;
@NonNull
private SelectedEdition edition;
public BasmalhOnStart() {
@ -19,28 +21,4 @@ public class BasmalhOnStart {
isSoundActive = false;
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.EditionFormat;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import java.io.IOException;
/**
* @author: <a href="https://github.com/anas-elgarhy">Anas Elgarhy</a>
* @date: 8/21/22
* @author <a href="https://github.com/anas-elgarhy">Anas Elgarhy</a>
* @since 8/21/22
*/
@AllArgsConstructor
@Getter
@Setter
public class SelectedEdition {
private String editionIdentifier;
private int index;
@ -22,27 +28,4 @@ public class SelectedEdition {
}
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.border.Border;
import java.awt.*;
/**
* @author: <a href="https://github.com/anas-elgarhy">Anas Elgarhy</a>
* @date: 8/19/22
* @author <a href="https://github.com/anas-elgarhy">Anas Elgarhy</a>
* @since 8/19/22
*/
public class PanelBuilder {
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 lombok.Getter;
import lombok.RequiredArgsConstructor;
/**
* @author: <a href="https://github.com/anas-elgarhy">Anas Elgarhy</a>
* @date: 8/20/22
* @author <a href="https://github.com/anas-elgarhy">Anas Elgarhy</a>
* @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() + ")";

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.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.JBLabel;
import com.intellij.util.ui.FormBuilder;
@ -16,8 +19,8 @@ import java.util.logging.Logger;
/**
* The settings UI.
*
* @author: <a href="https://github.com/anas-elgarhy">Anas Elgarhy</a>
* @date: 8/19/22
* @author <a href="https://github.com/anas-elgarhy">Anas Elgarhy</a>
* @since 8/19/22
*/
public class SettingsComponent {
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. -->
<id>com.anas.intellij.plugins.ayah</id>
<depends>com.intellij.modules.platform</depends>
<!-- Public plugin name should be written in Title Case.
Guidelines: https://plugins.jetbrains.com/docs/marketplace/plugin-overview-page.html#plugin-name -->
<name>Ayah</name>
@ -39,6 +41,7 @@
Read more: https://plugins.jetbrains.com/docs/intellij/plugin-compatibility.html -->
<depends>com.intellij.modules.platform</depends>
<!-- Extension points defined by the plugin.
Read more: https://plugins.jetbrains.com/docs/intellij/plugin-extension-points.html -->
<extensions defaultExtensionNs="com.intellij">