mirror of
https://github.com/anas-elgarhy/Ayah-intellij.git
synced 2024-08-15 00:43:43 +00:00
Merge pull request #4 from anas-elgarhy/fix-forget-playerid-issue
💙 Fix forget edition id issue after close the ide 🥰
This commit is contained in:
commit
5216086123
5 changed files with 35 additions and 31 deletions
|
@ -34,12 +34,7 @@ public class AyahSettingsState implements PersistentStateComponent<AyahSettingsS
|
||||||
basmalhOnStart = new BasmalhOnStart();
|
basmalhOnStart = new BasmalhOnStart();
|
||||||
intervalTimeBetweenNotifications = 30; // 30 minutes
|
intervalTimeBetweenNotifications = 30; // 30 minutes
|
||||||
autoPlayAudio = false;
|
autoPlayAudio = false;
|
||||||
try {
|
edition = new SelectedEdition();
|
||||||
edition = new SelectedEdition(Edition
|
|
||||||
.getEditions(EditionFormat.AUDIO)[0].getIdentifier(), 0);
|
|
||||||
} catch (final IOException e) {
|
|
||||||
edition = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,20 +11,13 @@ import java.io.IOException;
|
||||||
*/
|
*/
|
||||||
public class BasmalhOnStart {
|
public class BasmalhOnStart {
|
||||||
private boolean isActive;
|
private boolean isActive;
|
||||||
private boolean isNotificationActive;
|
|
||||||
private boolean isSoundActive;
|
private boolean isSoundActive;
|
||||||
private SelectedEdition edition;
|
private SelectedEdition edition;
|
||||||
|
|
||||||
public BasmalhOnStart() {
|
public BasmalhOnStart() {
|
||||||
isActive = true;
|
isActive = true;
|
||||||
isNotificationActive = true;
|
|
||||||
isSoundActive = false;
|
isSoundActive = false;
|
||||||
try {
|
edition = new SelectedEdition();
|
||||||
edition = new SelectedEdition(Edition
|
|
||||||
.getEditions(EditionFormat.AUDIO)[0].getIdentifier(), 0);
|
|
||||||
} catch (final IOException e) {
|
|
||||||
edition = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isActive() {
|
public boolean isActive() {
|
||||||
|
@ -35,14 +28,6 @@ public class BasmalhOnStart {
|
||||||
isActive = active;
|
isActive = active;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isNotificationActive() {
|
|
||||||
return isNotificationActive;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNotificationActive(final boolean notificationActive) {
|
|
||||||
isNotificationActive = notificationActive;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSoundActive() {
|
public boolean isSoundActive() {
|
||||||
return isSoundActive;
|
return isSoundActive;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import com.anas.alqurancloudapi.edition.Edition;
|
||||||
* @date: 8/20/22
|
* @date: 8/20/22
|
||||||
*/
|
*/
|
||||||
public class ReadableEdition {
|
public class ReadableEdition {
|
||||||
private final Edition edition;
|
private Edition edition;
|
||||||
|
|
||||||
public ReadableEdition(final Edition edition) {
|
public ReadableEdition(final Edition edition) {
|
||||||
this.edition = edition;
|
this.edition = edition;
|
||||||
|
|
|
@ -1,14 +1,27 @@
|
||||||
package com.anas.intellij.plugins.ayah.settings;
|
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 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
|
* @date: 8/21/22
|
||||||
*/
|
*/
|
||||||
public class SelectedEdition {
|
public class SelectedEdition {
|
||||||
private final String editionIdentifier;
|
private String editionIdentifier;
|
||||||
private final int index;
|
private int index;
|
||||||
|
|
||||||
|
// For XML serialization
|
||||||
|
public SelectedEdition() {
|
||||||
|
try {
|
||||||
|
editionIdentifier = Edition.getEditions(EditionFormat.AUDIO)[0].getIdentifier();
|
||||||
|
} catch (final IOException e) {
|
||||||
|
editionIdentifier = "ar.abdulbasitmurattal";
|
||||||
|
}
|
||||||
|
index = 0;
|
||||||
|
}
|
||||||
|
|
||||||
public SelectedEdition(final String editionIdentifier, final int index) {
|
public SelectedEdition(final String editionIdentifier, final int index) {
|
||||||
this.editionIdentifier = editionIdentifier;
|
this.editionIdentifier = editionIdentifier;
|
||||||
|
@ -19,7 +32,17 @@ public class SelectedEdition {
|
||||||
return editionIdentifier;
|
return editionIdentifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For XML serialization
|
||||||
|
public void setEditionIdentifier(final String editionIdentifier) {
|
||||||
|
this.editionIdentifier = editionIdentifier;
|
||||||
|
}
|
||||||
|
|
||||||
public int getIndex() {
|
public int getIndex() {
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For XML serialization
|
||||||
|
public void setIndex(final int index) {
|
||||||
|
this.index = index;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,12 +86,14 @@ public class SettingsComponent {
|
||||||
notificationsAudioCheckBox.setSelected(settings.isAutoPlayAudio());
|
notificationsAudioCheckBox.setSelected(settings.isAutoPlayAudio());
|
||||||
basmalhPlayerIdComboBox.setEnabled(settings.getBasmalhOnStart().isActive());
|
basmalhPlayerIdComboBox.setEnabled(settings.getBasmalhOnStart().isActive());
|
||||||
|
|
||||||
if (settings.getBasmalhOnStart().getEdition() != null) {
|
if (basmalhPlayerIdComboBox.getItemCount() <= 0) {
|
||||||
basmalhPlayerIdComboBox.setSelectedIndex(settings.getBasmalhOnStart().getEdition().getIndex());
|
basmalhPlayerIdComboBox.addItem(new ReadableEdition(settings.getBasmalhOnStart()
|
||||||
}
|
.getEdition().getEditionIdentifier()));
|
||||||
if (settings.getEdition() != null) {
|
ayahPlayerIdComboBox.addItem(new ReadableEdition(settings.getEdition().getEditionIdentifier()));
|
||||||
ayahPlayerIdComboBox.setSelectedIndex(settings.getEdition().getIndex());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
basmalhPlayerIdComboBox.setSelectedIndex(settings.getBasmalhOnStart().getEdition().getIndex());
|
||||||
|
ayahPlayerIdComboBox.setSelectedIndex(settings.getEdition().getIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addListeners() {
|
private void addListeners() {
|
||||||
|
@ -147,7 +149,6 @@ public class SettingsComponent {
|
||||||
b.setSoundActive(autoPlayBasmalhCheckBox.isSelected());
|
b.setSoundActive(autoPlayBasmalhCheckBox.isSelected());
|
||||||
b.setEdition(new SelectedEdition(((ReadableEdition) Objects.requireNonNull(
|
b.setEdition(new SelectedEdition(((ReadableEdition) Objects.requireNonNull(
|
||||||
basmalhPlayerIdComboBox.getSelectedItem())).getEdition().getIdentifier(), basmalhPlayerIdComboBox.getSelectedIndex()));
|
basmalhPlayerIdComboBox.getSelectedItem())).getEdition().getIdentifier(), basmalhPlayerIdComboBox.getSelectedIndex()));
|
||||||
b.setNotificationActive(notificationsAudioCheckBox.isSelected());
|
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue