Skip to content

Commit b6af8a2

Browse files
author
Flameish
committed
Moved functions
1 parent 6336ebc commit b6af8a2

File tree

4 files changed

+36
-36
lines changed

4 files changed

+36
-36
lines changed

src/gui/GUI.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -808,15 +808,15 @@ else if (manSaveLocation.getText().isEmpty()) {
808808
);
809809
});
810810
sendNewChapterNotificationsCheckBox.addActionListener(actionEvent -> {
811-
EmailConfig.setNotifications(sendNewChapterNotificationsCheckBox.isSelected());
811+
Library.setNotifications(sendNewChapterNotificationsCheckBox.isSelected());
812812
sendEPUBAsAttachmentCheckBox.setSelected(false);
813-
EmailConfig.setUseAttachment(sendEPUBAsAttachmentCheckBox.isSelected());
813+
Library.setUseAttachment(sendEPUBAsAttachmentCheckBox.isSelected());
814814

815815
});
816816
sendEPUBAsAttachmentCheckBox.addActionListener(actionEvent -> {
817-
EmailConfig.setUseAttachment(sendEPUBAsAttachmentCheckBox.isSelected());
817+
Library.setUseAttachment(sendEPUBAsAttachmentCheckBox.isSelected());
818818
sendNewChapterNotificationsCheckBox.setSelected(false);
819-
EmailConfig.setNotifications(sendNewChapterNotificationsCheckBox.isSelected());
819+
Library.setNotifications(sendNewChapterNotificationsCheckBox.isSelected());
820820
updateLastChapterNumberCheckBox.setSelected(false);
821821
Library.setUpdateLast(updateLastChapterNumberCheckBox.isSelected());
822822

@@ -1408,9 +1408,9 @@ void change() {
14081408
emailSLLComboBox = new JComboBox(sslList);
14091409
emailSLLComboBox.setSelectedIndex(EmailConfig.getSSL());
14101410
sendNewChapterNotificationsCheckBox = new JCheckBox();
1411-
sendNewChapterNotificationsCheckBox.setSelected(EmailConfig.useNotifications());
1411+
sendNewChapterNotificationsCheckBox.setSelected(Library.useNotifications());
14121412
sendEPUBAsAttachmentCheckBox = new JCheckBox();
1413-
sendEPUBAsAttachmentCheckBox.setSelected(EmailConfig.useAttachment());
1413+
sendEPUBAsAttachmentCheckBox.setSelected(Library.useAttachment());
14141414

14151415
// Library
14161416
enableCheckingCheckBox = new JCheckBox();

src/library/LibrarySystem.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ private static void pollLibrary() {
4545
String[] cliParams = cliString.split(" ");
4646
autoNovel = init.processParams(init.getParamsFromString(cliParams));
4747
Library.setLastChapter(novelUrl, Library.getNewestChapter(novelUrl));
48-
if(EmailConfig.useAttachment() && !EmailConfig.getHost().isEmpty()) {
48+
if(Library.useAttachment() && !EmailConfig.getHost().isEmpty()) {
4949
mailer.sendAttachment(autoNovel);
5050
System.out.println("[INFO]Email with attachment send.");
5151
}
5252
}
5353
}
5454
// Notification
55-
if(EmailConfig.useNotifications() && chapterDifference > 0 && !EmailConfig.getHost().isEmpty()) {
55+
if(Library.useNotifications() && chapterDifference > 0 && !EmailConfig.getHost().isEmpty()) {
5656
mailer.sendNotification(autoNovel);
5757
System.out.println("[INFO]Notification send.");
5858
// Adjust last downloaded chapter to newest

src/system/persistent/EmailConfig.java

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -37,40 +37,12 @@ public static int getSSL() {
3737
return Integer.parseInt(String.valueOf(email.get("ssl")));
3838
}
3939

40-
public static boolean useNotifications() {
41-
JSONObject email = (JSONObject) Config.data.get("email");
42-
if(email == null || !email.containsKey("useNotifications")) return false;
43-
return (boolean) email.get("useNotifications");
44-
}
45-
46-
public static boolean useAttachment() {
47-
JSONObject email = (JSONObject) Config.data.get("email");
48-
if(email == null || !email.containsKey("useAttachment")) return false;
49-
return (boolean) email.get("useAttachment");
50-
}
51-
5240
public static String getReceiverEmail() {
5341
JSONObject email = (JSONObject) Config.data.get("email");
5442
if(email == null || !email.containsKey("receiverEmail")) return "";
5543
return (String) email.get("receiverEmail");
5644
}
5745

58-
public static void setNotifications(boolean useNotifications) {
59-
JSONObject email = (JSONObject) Config.data.get("email");
60-
if(email == null) email = new JSONObject();
61-
email.put("useNotifications", useNotifications);
62-
Config.data.put("email", email);
63-
Config.saveConfig();
64-
}
65-
66-
public static void setUseAttachment(boolean useAttachment) {
67-
JSONObject email = (JSONObject) Config.data.get("email");
68-
if(email == null) email = new JSONObject();
69-
email.put("useAttachment", useAttachment);
70-
Config.data.put("email", email);
71-
Config.saveConfig();
72-
}
73-
7446
public static void saveEmailSettings(String host, String username, String password, String receiverEmail, int port, int SSL) {
7547
JSONObject email = (JSONObject) Config.data.get("email");
7648
if(email == null) email = new JSONObject();

src/system/persistent/Library.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,34 @@ public static void setAutoDownload(String novelUrl, boolean useAuto) {
157157
Config.saveConfig();
158158
}
159159

160+
public static void setNotifications(boolean useNotifications) {
161+
JSONObject email = (JSONObject) Config.data.get("librarySettings");
162+
if(email == null) email = new JSONObject();
163+
email.put("useNotifications", useNotifications);
164+
Config.data.put("librarySettings", email);
165+
Config.saveConfig();
166+
}
167+
168+
public static boolean useAttachment() {
169+
JSONObject email = (JSONObject) Config.data.get("librarySettings");
170+
if(email == null || !email.containsKey("useAttachment")) return false;
171+
return (boolean) email.get("useAttachment");
172+
}
173+
174+
public static void setUseAttachment(boolean useAttachment) {
175+
JSONObject email = (JSONObject) Config.data.get("librarySettings");
176+
if(email == null) email = new JSONObject();
177+
email.put("useAttachment", useAttachment);
178+
Config.data.put("librarySettings", email);
179+
Config.saveConfig();
180+
}
181+
182+
public static boolean useNotifications() {
183+
JSONObject email = (JSONObject) Config.data.get("librarySettings");
184+
if(email == null || !email.containsKey("useNotifications")) return false;
185+
return (boolean) email.get("useNotifications");
186+
}
187+
160188
public static void setPolling(boolean pollingEnabled) {
161189
JSONObject librarySettings = (JSONObject) Config.data.get("librarySettings");
162190
if(librarySettings == null) librarySettings = new JSONObject();

0 commit comments

Comments
 (0)