extract legal settings to static variable

This commit is contained in:
Oystein Kristoffer Tveit 2021-04-25 22:21:37 +02:00
parent ed0e3bd871
commit 697d2b59a8

View File

@ -18,11 +18,16 @@ import app.model.Model;
public class SettingsProvider implements SettingsProviderI {
private static EventBus eventBus;
private static final String SETTINGS_PATH =
(System.getProperty("os.name").startsWith("Windows"))
? System.getProperty("user.home") + "\\AppData\\Roaming\\/BNNsettings.dat"
: System.getProperty("user.home") + System.getProperty("file.separator") + ".BNNsettings.dat";
private static List<String> legalSettings =
Arrays.asList("Java", "Markdown", "Monokai", "Solarized Light");
public SettingsProvider(EventBus eB) {
setEventBus(eB);
Model.setSettingsProvider(this);
@ -36,7 +41,6 @@ public class SettingsProvider implements SettingsProviderI {
@Override
public void loadSettings() {
List<String> settings = new ArrayList<>();
List<String> legalSettings = Arrays.asList("Java", "Markdown", "Monokai", "Solarized Light");
try (Scanner sc = new Scanner(new File(SETTINGS_PATH))) {
while (sc.hasNextLine()) {
@ -56,7 +60,7 @@ public class SettingsProvider implements SettingsProviderI {
}
} catch (IOException e) {
System.err.println("[WARNING] Couldn't read settings file. Using defaults");
System.err.println("[WARNING] Couldn't find settings file. Using defaults");
eventBus.post(new LanguageChangedEvent("Java"));
eventBus.post(new ThemeChangedEvent("Monokai"));
}