Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃挋 Fix forget edition id issue after close the ide 馃グ #4

Merged
merged 1 commit into from
Aug 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,7 @@ private AyahSettingsState() {
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();
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,13 @@
*/
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() {
Expand All @@ -35,14 +28,6 @@ public void setActive(final boolean active) {
isActive = active;
}

public boolean isNotificationActive() {
return isNotificationActive;
}

public void setNotificationActive(final boolean notificationActive) {
isNotificationActive = notificationActive;
}

public boolean isSoundActive() {
return isSoundActive;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @date: 8/20/22
*/
public class ReadableEdition {
private final Edition edition;
private Edition edition;

public ReadableEdition(final Edition edition) {
this.edition = edition;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -19,7 +32,17 @@ 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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,14 @@ private void setup() {
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() {
Expand Down Expand Up @@ -147,7 +149,6 @@ public BasmalhOnStart getBasmalhOnStart() {
b.setSoundActive(autoPlayBasmalhCheckBox.isSelected());
b.setEdition(new SelectedEdition(((ReadableEdition) Objects.requireNonNull(
basmalhPlayerIdComboBox.getSelectedItem())).getEdition().getIdentifier(), basmalhPlayerIdComboBox.getSelectedIndex()));
b.setNotificationActive(notificationsAudioCheckBox.isSelected());
return b;
}

Expand Down