Skip to content

Commit

Permalink
Merge pull request #29 from CodeDead/release/v1.0.2
Browse files Browse the repository at this point in the history
Release/v1.0.2
  • Loading branch information
CodeDead authored Apr 4, 2022
2 parents 4cbfabd + d453122 commit 89f44d7
Showing 24 changed files with 225 additions and 46 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -59,7 +59,7 @@ especially if you're targeting a specific platform and installation method.

The following dependencies are universal:

* [JDK17](https://openjdk.java.net/projects/jdk/17/)
* [JDK18](https://openjdk.java.net/projects/jdk/18/)
* [JavaFX](https://openjfx.io)
* [Gradle](https://gradle.org)
* [FasterXML/jackson](https://github.com/FasterXML/jackson)
@@ -97,6 +97,5 @@ This library is maintained by CodeDead. You can find more about us using the fol
* [Website](https://codedead.com)
* [Twitter](https://twitter.com/C0DEDEAD)
* [Facebook](https://facebook.com/deadlinecodedead)
* [Reddit](https://reddit.com/r/CodeDead/)

Copyright © 2021 CodeDead
Copyright © 2022 CodeDead
28 changes: 14 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ plugins {
id 'idea'
id 'eclipse'
id 'application'
id 'org.beryx.jlink' version '2.24.4'
id "org.beryx.jlink" version "2.25.0"
}

group 'com.codedead'
@@ -14,8 +14,8 @@ version '1.0.1'
def currentOS = DefaultNativePlatform.currentOperatingSystem

java {
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_18
sourceCompatibility = JavaVersion.VERSION_18
}

application {
@@ -39,7 +39,7 @@ jlink {
'--win-menu-group', 'CodeDead',
'--win-shortcut',
'--win-dir-chooser',
'--copyright', 'Copyright (c) 2021 CodeDead',
'--copyright', 'Copyright (c) 2022 CodeDead',
'--description', 'Opal is a free and open-source JavaFX application that can play relaxing music in the background',
'--vendor', 'CodeDead',
'--license-file', 'LICENSE'
@@ -53,7 +53,7 @@ jlink {
'--linux-shortcut',
'--linux-package-name', 'opal-codedead',
'--linux-rpm-license-type', 'GPLv3',
'--copyright', 'Copyright (c) 2021 CodeDead',
'--copyright', 'Copyright (c) 2022 CodeDead',
'--description', 'Opal is a free and open-source JavaFX application that can play relaxing music in the background',
'--vendor', 'CodeDead',
'--license-file', 'LICENSE'
@@ -112,15 +112,15 @@ if (currentOS.isWindows()) {
}

dependencies {
implementation "org.openjfx:javafx-base:17.0.1:${platform}"
implementation "org.openjfx:javafx-controls:17.0.1:${platform}"
implementation "org.openjfx:javafx-graphics:17.0.1:${platform}"
implementation "org.openjfx:javafx-fxml:17.0.1:${platform}"
implementation "org.openjfx:javafx-media:17.0.1:${platform}"
implementation "org.apache.logging.log4j:log4j-core:2.14.1"
implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.0'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
implementation "org.openjfx:javafx-base:18:${platform}"
implementation "org.openjfx:javafx-controls:18:${platform}"
implementation "org.openjfx:javafx-graphics:18:${platform}"
implementation "org.openjfx:javafx-fxml:18:${platform}"
implementation "org.openjfx:javafx-media:18:${platform}"
implementation 'org.apache.logging.log4j:log4j-core:2.17.2'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.2.2'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
}

test {
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
5 changes: 3 additions & 2 deletions src/main/java/com/codedead/opal/OpalApplication.java
Original file line number Diff line number Diff line change
@@ -3,7 +3,6 @@
import com.codedead.opal.controller.UpdateController;
import com.codedead.opal.utils.FxUtils;
import com.codedead.opal.utils.SharedVariables;
import javafx.application.Platform;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -22,6 +21,8 @@
import java.io.IOException;
import java.util.*;

import static com.codedead.opal.utils.SharedVariables.DEFAULT_LOCALE;

public class OpalApplication extends Application {

private static final Logger logger = LogManager.getLogger(OpalApplication.class);
@@ -75,7 +76,7 @@ public void start(final Stage primaryStage) {

logger.info("Finished creating the SettingsController");

final String languageTag = properties.getProperty("locale", "en-US");
final String languageTag = properties.getProperty("locale", DEFAULT_LOCALE);

logger.info("Attempting to load the ResourceBundle for locale {}", languageTag);

Original file line number Diff line number Diff line change
@@ -17,6 +17,8 @@
import java.util.Properties;
import java.util.ResourceBundle;

import static com.codedead.opal.utils.SharedVariables.DEFAULT_LOCALE;

public final class AboutWindowController {

@FXML
@@ -61,7 +63,7 @@ public void setSettingsController(final SettingsController settingsController) {
this.settingsController = settingsController;

final Properties properties = settingsController.getProperties();
final String languageTag = properties.getProperty("locale", "en-US");
final String languageTag = properties.getProperty("locale", DEFAULT_LOCALE);

logger.info("Attempting to load the ResourceBundle for locale {}", languageTag);

Original file line number Diff line number Diff line change
@@ -60,6 +60,8 @@ public AudioController(final IAudioTimer audioTimer) throws URISyntaxException {
mediaPlayers.put("cave", new MediaPlayer(new Media(Objects.requireNonNull(getClass().getResource("/audio/cave.mp3")).toURI().toString())));
mediaPlayers.put("frogs", new MediaPlayer(new Media(Objects.requireNonNull(getClass().getResource("/audio/frogs.mp3")).toURI().toString())));
mediaPlayers.put("zen", new MediaPlayer(new Media(Objects.requireNonNull(getClass().getResource("/audio/zen.mp3")).toURI().toString())));
mediaPlayers.put("coffee", new MediaPlayer(new Media(Objects.requireNonNull(getClass().getResource("/audio/coffee.mp3")).toURI().toString())));
mediaPlayers.put("zoo", new MediaPlayer(new Media(Objects.requireNonNull(getClass().getResource("/audio/zoo.mp3")).toURI().toString())));

mediaVolumes = new HashMap<>();
for (final Map.Entry<String, MediaPlayer> entry : mediaPlayers.entrySet()) {
Original file line number Diff line number Diff line change
@@ -12,6 +12,8 @@
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuItem;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.DragEvent;
@@ -28,8 +30,14 @@
import java.net.URISyntaxException;
import java.util.*;

import static com.codedead.opal.utils.SharedVariables.DEFAULT_LOCALE;

public final class MainWindowController implements IAudioTimer {

@FXML
private SoundPane snpZoo;
@FXML
private SoundPane snpCoffee;
@FXML
private SoundPane snpZen;
@FXML
@@ -101,8 +109,6 @@ public final class MainWindowController implements IAudioTimer {
private UpdateController updateController;
private ResourceBundle translationBundle;

private boolean isPortable;

private final Logger logger;

/**
@@ -145,10 +151,8 @@ public void setControllers(final SettingsController settingsController, final Up

final Properties properties = settingsController.getProperties();

final String languageTag = properties.getProperty("locale", "en-US");

final String languageTag = properties.getProperty("locale", DEFAULT_LOCALE);
final boolean shouldUpdate = Boolean.parseBoolean(properties.getProperty("autoUpdate", "true"));
isPortable = Boolean.parseBoolean(properties.getProperty("portable", "false"));

logger.info("Attempting to load the ResourceBundle for locale {}", languageTag);

@@ -169,7 +173,7 @@ private void checkForUpdates(final boolean showNoUpdates) {
logger.info("Attempting to check for updates");

try {
final Optional<PlatformUpdate> platformUpdate = updateController.checkForUpdates(platformName, isPortable);
final Optional<PlatformUpdate> platformUpdate = updateController.checkForUpdates(platformName, SharedVariables.PORTABLE);
if (platformUpdate.isPresent()) {
final PlatformUpdate update = platformUpdate.get();

@@ -294,6 +298,8 @@ private void initialize() {
snpCave.getSlider().valueProperty().addListener((observableValue, oldValue, newValue) -> audioController.setPlayerVolume("cave", newValue.doubleValue() / 100));
snpFrogs.getSlider().valueProperty().addListener((observableValue, oldValue, newValue) -> audioController.setPlayerVolume("frogs", newValue.doubleValue() / 100));
snpZen.getSlider().valueProperty().addListener((observableValue, oldValue, newValue) -> audioController.setPlayerVolume("zen", newValue.doubleValue() / 100));
snpCoffee.getSlider().valueProperty().addListener((observableValue, oldValue, newValue) -> audioController.setPlayerVolume("coffee", newValue.doubleValue() / 100));
snpZoo.getSlider().valueProperty().addListener((observableValue, oldValue, newValue) -> audioController.setPlayerVolume("zoo", newValue.doubleValue() / 100));

mniTimerEnabled.setOnAction(e ->
{
@@ -355,6 +361,8 @@ private void openSoundPreset(final String filePath) {
case "cave" -> snpCave.getSlider().setValue(entry.getValue() * 100);
case "frogs" -> snpFrogs.getSlider().setValue(entry.getValue() * 100);
case "zen" -> snpZen.getSlider().setValue(entry.getValue() * 100);
case "coffee" -> snpCoffee.getSlider().setValue(entry.getValue() * 100);
case "zoo" -> snpZoo.getSlider().setValue(entry.getValue() * 100);
default -> logger.info("Unknown key found: {}", entry.getKey());
}
}
@@ -417,6 +425,8 @@ private void resetAction() {
snpCave.getSlider().setValue(0);
snpFrogs.getSlider().setValue(0);
snpZen.getSlider().setValue(0);
snpCoffee.getSlider().setValue(0);
snpZoo.getSlider().setValue(0);
}

/**
@@ -425,7 +435,6 @@ private void resetAction() {
@FXML
private void exitAction() {
logger.info("Exiting the application");

System.exit(0);
}

Original file line number Diff line number Diff line change
@@ -19,6 +19,8 @@
import java.util.ResourceBundle;
import java.util.concurrent.TimeUnit;

import static com.codedead.opal.utils.SharedVariables.DEFAULT_LOCALE;

public final class SettingsWindowController {

@FXML
@@ -48,6 +50,9 @@ public SettingsWindowController() {
logger.info("Initializing new SettingsWindowController object");
}

/**
* Method that is invoked to initialize the FXML window
*/
@FXML
private void initialize() {
logger.info("Initializing SettingsWindow");
@@ -65,7 +70,7 @@ public void setSettingsController(final SettingsController settingsController) {
this.settingsController = settingsController;

properties = settingsController.getProperties();
final String languageTag = properties.getProperty("locale", "en-US");
final String languageTag = properties.getProperty("locale", DEFAULT_LOCALE);

logger.info("Attempting to load the ResourceBundle for locale {}", languageTag);

@@ -81,16 +86,19 @@ public void setSettingsController(final SettingsController settingsController) {
private void loadSettings() {
logger.info("Attempting to load all settings");
final boolean autoUpdate = Boolean.parseBoolean(properties.getProperty("autoUpdate", "true"));
final String locale = properties.getProperty("locale", "en-US");
final String locale = properties.getProperty("locale", DEFAULT_LOCALE);
final String logLevel = properties.getProperty("loglevel", "INFO");
long timerDelay = Long.parseLong(properties.getProperty("timerDelay", "3600000"));
final int delayType = Integer.parseInt(properties.getProperty("timerDelayType", "0"));
chbAutoUpdate.setSelected(Boolean.parseBoolean(properties.getProperty("timerApplicationShutdown", "false")));

chbAutoUpdate.setSelected(autoUpdate);
chbTimerApplicationShutdown.setSelected(Boolean.parseBoolean(properties.getProperty("timerApplicationShutdown", "false")));

switch (locale.toLowerCase()) {
case "fr-fr" -> cboLanguage.getSelectionModel().select(1);
case "nl-nl" -> cboLanguage.getSelectionModel().select(2);
case "es-es" -> cboLanguage.getSelectionModel().select(1);
case "fr-fr" -> cboLanguage.getSelectionModel().select(2);
case "nl-nl" -> cboLanguage.getSelectionModel().select(3);
case "ru-ru" -> cboLanguage.getSelectionModel().select(4);
default -> cboLanguage.getSelectionModel().select(0);
}

@@ -131,7 +139,7 @@ private void loadSettings() {
private void resetSettingsAction() {
logger.info("Attempting to reset all settings");
if (FxUtils.showConfirmationAlert(translationBundle.getString("ConfirmReset"), getClass().getResourceAsStream(SharedVariables.ICON_URL))) {
showAlertIfLanguageMismatch("en-US");
showAlertIfLanguageMismatch(DEFAULT_LOCALE);

try {
settingsController.createDefaultProperties();
@@ -153,13 +161,16 @@ private void saveSettingsAction() {
logger.info("Attempting to save all settings");

properties.setProperty("autoUpdate", Boolean.toString(chbAutoUpdate.isSelected()));
properties.setProperty("trayIcon", Boolean.toString(chbAutoUpdate.isSelected()));

showAlertIfLanguageMismatch(properties.getProperty("locale", "en-US"));
showAlertIfLanguageMismatch(properties.getProperty("locale", DEFAULT_LOCALE));

switch (cboLanguage.getSelectionModel().getSelectedIndex()) {
case 1 -> properties.setProperty("locale", "fr-FR");
case 2 -> properties.setProperty("locale", "nl-NL");
default -> properties.setProperty("locale", "en-US");
case 1 -> properties.setProperty("locale", "es-es");
case 2 -> properties.setProperty("locale", "fr-FR");
case 3 -> properties.setProperty("locale", "nl-NL");
case 4 -> properties.setProperty("locale", "ru-RU");
default -> properties.setProperty("locale", DEFAULT_LOCALE);
}

properties.setProperty("loglevel", cboLogLevel.getValue());
@@ -215,7 +226,7 @@ private void showAlertIfLanguageMismatch(final String languageToMatch) {
final String newLanguage = switch (cboLanguage.getSelectionModel().getSelectedIndex()) {
case 1 -> "fr-FR";
case 2 -> "nl-NL";
default -> "en-US";
default -> DEFAULT_LOCALE;
};

if (!languageToMatch.equals(newLanguage)) {
2 changes: 2 additions & 0 deletions src/main/java/com/codedead/opal/utils/SharedVariables.java
Original file line number Diff line number Diff line change
@@ -4,6 +4,8 @@ public final class SharedVariables {

public static final String ICON_URL = "/images/opal.png";
public static final String CURRENT_VERSION = "1.0.1.0";
public static final boolean PORTABLE = false;
public static final String DEFAULT_LOCALE = "en-US";

public static final String PROPERTIES_RESOURCE_LOCATION = "default.properties";
public static final String PROPERTIES_FILE_LOCATION = System.getProperty("user.home") + "/.opal/opal.properties";
Binary file added src/main/resources/audio/coffee.mp3
Binary file not shown.
Binary file added src/main/resources/audio/zoo.mp3
Binary file not shown.
1 change: 0 additions & 1 deletion src/main/resources/default.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
locale=en-US
autoUpdate=true
updateApi=https://codedead.com/Software/Opal/version.json
portable=false
loglevel=INFO
timerDelay=3600000
timerDelayType=2
Binary file modified src/main/resources/documents/help.pdf
Binary file not shown.
Binary file added src/main/resources/images/coffee.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/resources/images/zoo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion src/main/resources/translations/OpalApplication.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
About=About
AboutText=Opal was created by DeadLine\n\nAudio: ZapSplat.com\nImages: Remix Icon\nTheme: Modena\nVersion: 1.0.1\n\nCopyright © 2021 CodeDead
AboutText=Opal was created by DeadLine\n\nAudio: ZapSplat.com\nImages: Remix Icon\nTheme: Modena\nVersion: 1.0.1\n\nCopyright © 2022 CodeDead
AboutWindowError=Unable to open the About Window!
AboutWindowTitle=Opal - About
AutoUpdate=Automatically check for updates
@@ -65,3 +65,5 @@ TimerApplicationShutdown=Exit Opal
Cave=Cave
Frogs=Frogs
Zen=Zen
Coffee=Coffee
Zoo=Zoo
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
About=About
AboutText=Opal was created by DeadLine\n\nAudio: ZapSplat.com\nImages: Remix Icon\nTheme: Modena\nVersion: 1.0.1\n\nCopyright © 2021 CodeDead
AboutText=Opal was created by DeadLine\n\nAudio: ZapSplat.com\nImages: Remix Icon\nTheme: Modena\nVersion: 1.0.1\n\nCopyright © 2022 CodeDead
AboutWindowError=Unable to open the About Window!
AboutWindowTitle=Opal - About
AutoUpdate=Automatically check for updates
@@ -65,3 +65,5 @@ TimerApplicationShutdown=Exit Opal
Cave=Cave
Frogs=Frogs
Zen=Zen
Coffee=Coffee
Zoo=Zoo
Loading

0 comments on commit 89f44d7

Please sign in to comment.