Skip to content

Commit

Permalink
Merge pull request #129 from CodeDead/release/v1.4.0
Browse files Browse the repository at this point in the history
Release/v1.4.0
  • Loading branch information
CodeDead authored Jul 16, 2024
2 parents bd82d70 + a775c79 commit 7585d87
Show file tree
Hide file tree
Showing 30 changed files with 276 additions and 178 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ jobs:
if: ${{ matrix.os == 'ubuntu-latest' }}
run: sudo apt-get install -y fuse libfuse2

- name: Setup JDK 21
- name: Setup JDK 22
uses: actions/setup-java@v4
with:
java-version: '21'
java-version: '22'
distribution: 'temurin'

- name: Setup Gradle
Expand Down Expand Up @@ -63,10 +63,10 @@ jobs:
if: ${{ matrix.os == 'ubuntu-latest' }}
run: sudo apt-get install -y fuse libfuse2

- name: Setup JDK 21
- name: Setup JDK 22
uses: actions/setup-java@v4
with:
java-version: '21'
java-version: '22'
distribution: 'temurin'

- name: Setup Gradle
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ jobs:
if: ${{ matrix.os == 'ubuntu-latest' }}
run: sudo apt-get install -y fuse libfuse2

- name: Setup JDK 21
- name: Setup JDK 22
uses: actions/setup-java@v4
with:
java-version: '21'
java-version: '22'
distribution: 'temurin'

- name: Setup Gradle
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,6 @@ This library is maintained by CodeDead. You can find more about us using the fol
* [Twitter](https://twitter.com/C0DEDEAD)
* [Facebook](https://facebook.com/deadlinecodedead)
* [Reddit](https://reddit.com/r/CodeDead)
* [ X ](https://x.com/C0DEDEAD)

Copyright © 2024 CodeDead
14 changes: 7 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ plugins {
}

group 'com.codedead'
version '1.3.1'
version '1.4.0'

def currentOS = DefaultNativePlatform.currentOperatingSystem

java {
targetCompatibility = JavaVersion.VERSION_21
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_22
sourceCompatibility = JavaVersion.VERSION_22
}

application {
Expand All @@ -25,7 +25,7 @@ application {
}

javafx {
version = '22'
version = '22.0.1'
configuration = 'implementation'
modules = ['javafx.base', 'javafx.controls', 'javafx.fxml', 'javafx.media']
}
Expand Down Expand Up @@ -142,9 +142,9 @@ repositories {
dependencies {
implementation 'org.apache.logging.log4j:log4j-core:2.23.1'
implementation 'io.github.mkpaz:atlantafx-base:2.0.1'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.17.0'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.2'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.17.2'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.3'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.3'
}

tasks.named('test') {
Expand Down
2 changes: 2 additions & 0 deletions gradle/gradle-daemon-jvm.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#This file is generated by updateDaemonJvm
toolchainVersion=22
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,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
7 changes: 5 additions & 2 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down Expand Up @@ -84,7 +86,8 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down
2 changes: 2 additions & 0 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand Down
22 changes: 12 additions & 10 deletions src/main/java/com/codedead/opal/controller/LanguageController.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ public static int getLanguageIndexFromLocale(final String locale) {
case "de-de" -> 1;
case "es-es" -> 2;
case "fr-fr" -> 3;
case "jp-jp" -> 4;
case "nl-nl" -> 5;
case "ru-ru" -> 6;
case "tr-tr" -> 7;
case "zh-cn" -> 8;
case "hi-in" -> 4;
case "jp-jp" -> 5;
case "nl-nl" -> 6;
case "ru-ru" -> 7;
case "tr-tr" -> 8;
case "zh-cn" -> 9;
default -> 0;
};
}
Expand All @@ -42,11 +43,12 @@ public static String getLocaleFromLanguageIndex(final int index) {
case 1 -> "de-DE";
case 2 -> "es-ES";
case 3 -> "fr-FR";
case 4 -> "jp-JP";
case 5 -> "nl-NL";
case 6 -> "ru-RU";
case 7 -> "tr-TR";
case 8 -> "zh-CN";
case 4 -> "hi-in";
case 5 -> "jp-JP";
case 6 -> "nl-NL";
case 7 -> "ru-RU";
case 8 -> "tr-TR";
case 9 -> "zh-CN";
default -> DEFAULT_LOCALE;
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,20 @@ public final class MainWindowController implements IAudioTimer, TrayIconListener
private GridPane grpControls;
@FXML
private CheckMenuItem mniTimerEnabled;
@FXML
private MenuItem mniCountDown;

private TrayIconController trayIconController;
private SettingsController settingsController;
private UpdateController updateController;
private ResourceBundle translationBundle;
private TimerTask timerTask;
private boolean timerEnabled;
private TimerTask countDownTask;
private final String platformName;
private final HelpUtils helpUtils;
private final ObjectMapper objectMapper;
private final Timer timer;
private final Timer countDownTimer;
private final IAudioTimer audioTimer;
private final Logger logger;

Expand All @@ -65,6 +69,7 @@ public MainWindowController() {
helpUtils = new HelpUtils();

this.timer = new Timer();
this.countDownTimer = new Timer();
this.audioTimer = this;
this.objectMapper = new ObjectMapper();
}
Expand Down Expand Up @@ -182,7 +187,7 @@ private void checkForUpdates(final boolean showNoUpdates, final boolean showErro
} else {
logger.info("No updates available");
if (showNoUpdates) {
FxUtils.showInformationAlert(translationBundle.getString("NoUpdateAvailable"), null);
FxUtils.showInformationAlert(translationBundle.getString("NoUpdateAvailable"), getClass().getResourceAsStream(SharedVariables.ICON_URL));
}
}
} catch (final InterruptedException | IOException | InvalidHttpResponseCodeException | URISyntaxException ex) {
Expand Down Expand Up @@ -256,7 +261,7 @@ public void run() {
*/
@FXML
private void initialize() {
mniTimerEnabled.setOnAction(e -> {
mniTimerEnabled.setOnAction(_ -> {
if (mniTimerEnabled.isSelected()) {
final Properties properties = settingsController.getProperties();
final long timerDelay = Long.parseLong(properties.getProperty("timerDelay", "3600000"));
Expand Down Expand Up @@ -420,7 +425,7 @@ private void settingsAction() {
primaryStage.getIcons().add(new Image(Objects.requireNonNull(getClass().getResourceAsStream(SharedVariables.ICON_URL))));
primaryStage.setScene(new Scene(root));

primaryStage.setOnHiding(event -> ThemeController.setTheme(settingsController.getProperties().getProperty("theme", "Light").toLowerCase()));
primaryStage.setOnHiding(_ -> ThemeController.setTheme(settingsController.getProperties().getProperty("theme", "Light").toLowerCase()));

logger.info("Showing the SettingsWindow");
primaryStage.show();
Expand Down Expand Up @@ -530,8 +535,8 @@ private void updateAction() {
*/
@Override
public void fired() {
cancelTimer();
getAllSoundPanes(grpControls).forEach(SoundPane::pause);
mniTimerEnabled.setSelected(false);

if (Boolean.parseBoolean(settingsController.getProperties().getProperty("timerComputerShutdown", "false"))) {
final String command = switch (platformName.toLowerCase()) {
Expand Down Expand Up @@ -620,13 +625,18 @@ private void onDragDropped(final DragEvent dragEvent) {
public void cancelTimer() {
logger.info("Cancelling the Timer to stop all MediaPlayer objects");

timerEnabled = false;

if (timerTask != null) {
timerTask.cancel();
timer.purge();
}

if (countDownTask != null) {
countDownTask.cancel();
countDownTimer.purge();
}

Platform.runLater(() -> mniCountDown.setVisible(false));

if (audioTimer != null) {
audioTimer.cancelled();
}
Expand All @@ -643,25 +653,48 @@ public void scheduleTimer(final long delay) {

logger.info("Scheduling the Timer to stop all MediaPlayer objects after {} millisecond(s)", delay);

timerEnabled = true;

if (timerTask != null) {
timerTask.cancel();
timer.purge();
}

if (countDownTask != null) {
countDownTask.cancel();
countDownTimer.purge();
}

timerTask = new TimerTask() {
@Override
public void run() {
logger.info("Timer has fired");
if (timerEnabled) {
audioTimer.fired();
}
timerEnabled = false;
audioTimer.fired();
}
};

countDownTask = new TimerTask() {
final long seconds = delay / 1000;
int i = 0;

@Override
public void run() {
i++;
long timeLeft = (seconds - (i % seconds));

// Calculate hours, minutes and seconds
long hours = timeLeft / 3600;
long minutes = (timeLeft % 3600) / 60;
long seconds = timeLeft % 60;

// Format the values to HH:MM:SS with leading zeros if necessary
final String timeLeftFormatted = String.format("%02d:%02d:%02d", hours, minutes, seconds);
Platform.runLater(() -> mniCountDown.setText(timeLeftFormatted));
}
};

timer.schedule(timerTask, delay);
countDownTimer.schedule(countDownTask, 0, 1000);

mniCountDown.setVisible(true);
}

/**
Expand Down
28 changes: 20 additions & 8 deletions src/main/java/com/codedead/opal/controller/TrayIconController.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ private void createTrayIcon() throws IOException {

if (trayIconListener != null) {
// Platform.runLater to run on the JavaFX thread
displayItem.addActionListener(e -> Platform.runLater(trayIconListener::onShowHide));
settingsItem.addActionListener(e -> Platform.runLater(trayIconListener::onSettings));
aboutItem.addActionListener(e -> Platform.runLater(trayIconListener::onAbout));
exitItem.addActionListener(e -> Platform.runLater(trayIconListener::onExit));
displayItem.addActionListener(_ -> Platform.runLater(trayIconListener::onShowHide));
settingsItem.addActionListener(_ -> Platform.runLater(trayIconListener::onSettings));
aboutItem.addActionListener(_ -> Platform.runLater(trayIconListener::onAbout));
exitItem.addActionListener(_ -> Platform.runLater(trayIconListener::onExit));

localTrayIcon.addMouseListener(new java.awt.event.MouseAdapter() {
@Override
Expand Down Expand Up @@ -98,8 +98,7 @@ public void showTrayIcon() throws IOException {
logger.info("Displaying tray icon");
if (trayIcon == null) {
createTrayIcon();
if (trayIcon == null) {
logger.warn("TrayIcon cannot be null!");
if (invalidTrayIcon()) {
return;
}
}
Expand All @@ -119,8 +118,8 @@ public void showTrayIcon() throws IOException {
*/
public void hideTrayIcon() {
logger.info("Hiding tray icon");
if (trayIcon == null) {
logger.warn("TrayIcon cannot be null!");

if (invalidTrayIcon()) {
return;
}

Expand All @@ -129,4 +128,17 @@ public void hideTrayIcon() {

trayIcon = null;
}

/**
* Check if the tray icon is valid
*
* @return True if the tray icon is valid, false otherwise
*/
private boolean invalidTrayIcon() {
if (trayIcon == null) {
logger.warn("TrayIcon cannot be null!");
return true;
}
return false;
}
}
2 changes: 1 addition & 1 deletion src/main/java/com/codedead/opal/utils/SharedVariables.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
public final class SharedVariables {

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

Expand Down
3 changes: 1 addition & 2 deletions src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
module Opal {
requires java.base;
requires java.net.http;
requires javafx.controls;
requires javafx.fxml;
requires java.desktop;
requires java.compiler;
requires java.naming;
requires javafx.media;
//noinspection Java9RedundantRequiresStatement
requires jdk.crypto.ec; // Added for SSL handshakes
requires org.apache.logging.log4j;
requires org.apache.logging.log4j.core;
requires com.fasterxml.jackson.core;
Expand Down
Binary file added src/main/resources/audio/dolphin.mp3
Binary file not shown.
Binary file added src/main/resources/audio/largeCrowd.mp3
Binary file not shown.
Binary file added src/main/resources/audio/rollercoaster.mp3
Binary file not shown.
Loading

0 comments on commit 7585d87

Please sign in to comment.