122 lines
4.0 KiB
Java
122 lines
4.0 KiB
Java
package ch.zhaw.gartenverwaltung;
|
|
|
|
import ch.zhaw.gartenverwaltung.backgroundtasks.email.SmtpCredentials;
|
|
import ch.zhaw.gartenverwaltung.types.HardinessZone;
|
|
import javafx.beans.property.BooleanProperty;
|
|
import javafx.beans.property.SimpleBooleanProperty;
|
|
|
|
import java.util.List;
|
|
import java.util.Objects;
|
|
|
|
/**
|
|
* Singleton Class to store default Settings and User Settings
|
|
*/
|
|
public class Settings {
|
|
/*
|
|
* The Class instance to use everywhere
|
|
*/
|
|
|
|
private static final Settings instance;
|
|
/**
|
|
* The current Hardiness zone initialized as default value Zone_8A
|
|
*/
|
|
private HardinessZone currentHardinessZone = HardinessZone.ZONE_8A;
|
|
/**
|
|
* Setting to show or hide the Tutorial in Main Menu
|
|
*/
|
|
private final BooleanProperty showTutorial = new SimpleBooleanProperty(false);
|
|
/**
|
|
* The SMTP Credentials which are used to send E-Mail Notifications
|
|
* The following Google Account is created for Testing:
|
|
* E-Mail Address: pm3.hs22.it21b.win.team1@gmail.com
|
|
* Account Password: Gartenverwaltung.PM3.2022
|
|
* SMTP Password: bisefhhjtrrhtoqr
|
|
*/
|
|
private SmtpCredentials smtpCredentials = new SmtpCredentials("imap.gmail.com", "587", "pm3.hs22.it21b.win.team1@gmail.com", "pm3.hs22.it21b.win.team1@gmail.com", "bisefhhjtrrhtoqr", true);
|
|
/**
|
|
* List of Receivers for E-Mailnotifications. Multiple E-Mailadresses can be separated by ";"
|
|
* Following Public E-mail address was used for Testing: pm3.hs22.it21b.win.team1@mailinator.com
|
|
* The E-Mail inbox of this address can be found here: https://www.mailinator.com/v4/public/inboxes.jsp?to=pm3.hs22.it21b.win.team1
|
|
*/
|
|
private String mailNotificationReceivers = "pm3.hs22.it21b.win.team1@mailinator.com";
|
|
/**
|
|
* String Template to create E-Mail Subject for Notifications
|
|
* Variables: Task Name
|
|
*/
|
|
private String mailNotificationSubjectTemplate = "Task %s is due!";
|
|
/**
|
|
* String Template to create E-Mail Text for Notifications
|
|
* Variables: Task Name, plant Name, nextExecution, Task description
|
|
*/
|
|
private String mailNotificationTextTemplate = "Dear user\nYour gardentask %s for plant %s is due at %tF. Don't forget to confirm in your application if the task is done.\nTask description:\n%s";
|
|
|
|
/**
|
|
* Location of the garden can be set by user (Used for Weather Service)
|
|
*/
|
|
private String location = "";
|
|
|
|
/*
|
|
Create Instance of Settings
|
|
*/
|
|
static {
|
|
instance = new Settings();
|
|
}
|
|
|
|
public static Settings getInstance() {
|
|
return Settings.instance;
|
|
}
|
|
|
|
/**
|
|
* Private constructor to prevent Classes from creating more instances
|
|
*/
|
|
private Settings() {}
|
|
|
|
public HardinessZone getCurrentHardinessZone() {
|
|
return currentHardinessZone;
|
|
}
|
|
|
|
/**
|
|
* Method to set the current Hardiness Zone. If no Hardiness Zone is given the default zone (ZONE_8A) will be used.
|
|
* @param currentHardinessZone the new Hardiness Zone
|
|
*/
|
|
public void setCurrentHardinessZone(HardinessZone currentHardinessZone) {
|
|
this.currentHardinessZone = Objects.requireNonNullElse(currentHardinessZone, HardinessZone.ZONE_8A);
|
|
}
|
|
|
|
public void setShowTutorial (boolean showTutorial) {
|
|
this.showTutorial.setValue(showTutorial);
|
|
}
|
|
|
|
public BooleanProperty getShowTutorialProperty() {
|
|
return this.showTutorial;
|
|
}
|
|
|
|
public boolean getShowTutorial() {
|
|
return this.showTutorial.get();
|
|
}
|
|
|
|
public void setLocation(String location) {
|
|
this.location = location;
|
|
}
|
|
|
|
public String getLocation() {
|
|
return this.location;
|
|
}
|
|
|
|
public SmtpCredentials getSmtpCredentials() {
|
|
return smtpCredentials;
|
|
}
|
|
|
|
public String getMailNotificationReceivers() {
|
|
return mailNotificationReceivers;
|
|
}
|
|
|
|
public String getMailNotificationSubjectTemplate() {
|
|
return mailNotificationSubjectTemplate;
|
|
}
|
|
|
|
public String getMailNotificationTextTemplate() {
|
|
return mailNotificationTextTemplate;
|
|
}
|
|
}
|