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