Skip to content

Commit 7585d87

Browse files
authored
Merge pull request #129 from CodeDead/release/v1.4.0
Release/v1.4.0
2 parents bd82d70 + a775c79 commit 7585d87

30 files changed

+276
-178
lines changed

.github/workflows/release.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ jobs:
2323
if: ${{ matrix.os == 'ubuntu-latest' }}
2424
run: sudo apt-get install -y fuse libfuse2
2525

26-
- name: Setup JDK 21
26+
- name: Setup JDK 22
2727
uses: actions/setup-java@v4
2828
with:
29-
java-version: '21'
29+
java-version: '22'
3030
distribution: 'temurin'
3131

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

66-
- name: Setup JDK 21
66+
- name: Setup JDK 22
6767
uses: actions/setup-java@v4
6868
with:
69-
java-version: '21'
69+
java-version: '22'
7070
distribution: 'temurin'
7171

7272
- name: Setup Gradle

.github/workflows/test.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ jobs:
2323
if: ${{ matrix.os == 'ubuntu-latest' }}
2424
run: sudo apt-get install -y fuse libfuse2
2525

26-
- name: Setup JDK 21
26+
- name: Setup JDK 22
2727
uses: actions/setup-java@v4
2828
with:
29-
java-version: '21'
29+
java-version: '22'
3030
distribution: 'temurin'
3131

3232
- name: Setup Gradle

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -115,5 +115,6 @@ This library is maintained by CodeDead. You can find more about us using the fol
115115
* [Twitter](https://twitter.com/C0DEDEAD)
116116
* [Facebook](https://facebook.com/deadlinecodedead)
117117
* [Reddit](https://reddit.com/r/CodeDead)
118+
* [ X ](https://x.com/C0DEDEAD)
118119

119120
Copyright © 2024 CodeDead

build.gradle

+7-7
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ plugins {
1010
}
1111

1212
group 'com.codedead'
13-
version '1.3.1'
13+
version '1.4.0'
1414

1515
def currentOS = DefaultNativePlatform.currentOperatingSystem
1616

1717
java {
18-
targetCompatibility = JavaVersion.VERSION_21
19-
sourceCompatibility = JavaVersion.VERSION_21
18+
targetCompatibility = JavaVersion.VERSION_22
19+
sourceCompatibility = JavaVersion.VERSION_22
2020
}
2121

2222
application {
@@ -25,7 +25,7 @@ application {
2525
}
2626

2727
javafx {
28-
version = '22'
28+
version = '22.0.1'
2929
configuration = 'implementation'
3030
modules = ['javafx.base', 'javafx.controls', 'javafx.fxml', 'javafx.media']
3131
}
@@ -142,9 +142,9 @@ repositories {
142142
dependencies {
143143
implementation 'org.apache.logging.log4j:log4j-core:2.23.1'
144144
implementation 'io.github.mkpaz:atlantafx-base:2.0.1'
145-
implementation 'com.fasterxml.jackson.core:jackson-databind:2.17.0'
146-
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.2'
147-
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.2'
145+
implementation 'com.fasterxml.jackson.core:jackson-databind:2.17.2'
146+
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.3'
147+
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.3'
148148
}
149149

150150
tasks.named('test') {

gradle/gradle-daemon-jvm.properties

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#This file is generated by updateDaemonJvm
2+
toolchainVersion=22

gradle/wrapper/gradle-wrapper.jar

51 Bytes
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

gradlew

+5-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717
#
18+
# SPDX-License-Identifier: Apache-2.0
19+
#
1820

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

8992
# Use the maximum available, or set MAX_FD != -1 to use that value.
9093
MAX_FD=maximum

gradlew.bat

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
@rem See the License for the specific language governing permissions and
1414
@rem limitations under the License.
1515
@rem
16+
@rem SPDX-License-Identifier: Apache-2.0
17+
@rem
1618

1719
@if "%DEBUG%"=="" @echo off
1820
@rem ##########################################################################

src/main/java/com/codedead/opal/controller/LanguageController.java

+12-10
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@ public static int getLanguageIndexFromLocale(final String locale) {
2222
case "de-de" -> 1;
2323
case "es-es" -> 2;
2424
case "fr-fr" -> 3;
25-
case "jp-jp" -> 4;
26-
case "nl-nl" -> 5;
27-
case "ru-ru" -> 6;
28-
case "tr-tr" -> 7;
29-
case "zh-cn" -> 8;
25+
case "hi-in" -> 4;
26+
case "jp-jp" -> 5;
27+
case "nl-nl" -> 6;
28+
case "ru-ru" -> 7;
29+
case "tr-tr" -> 8;
30+
case "zh-cn" -> 9;
3031
default -> 0;
3132
};
3233
}
@@ -42,11 +43,12 @@ public static String getLocaleFromLanguageIndex(final int index) {
4243
case 1 -> "de-DE";
4344
case 2 -> "es-ES";
4445
case 3 -> "fr-FR";
45-
case 4 -> "jp-JP";
46-
case 5 -> "nl-NL";
47-
case 6 -> "ru-RU";
48-
case 7 -> "tr-TR";
49-
case 8 -> "zh-CN";
46+
case 4 -> "hi-in";
47+
case 5 -> "jp-JP";
48+
case 6 -> "nl-NL";
49+
case 7 -> "ru-RU";
50+
case 8 -> "tr-TR";
51+
case 9 -> "zh-CN";
5052
default -> DEFAULT_LOCALE;
5153
};
5254
}

src/main/java/com/codedead/opal/controller/MainWindowController.java

+46-13
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,20 @@ public final class MainWindowController implements IAudioTimer, TrayIconListener
4141
private GridPane grpControls;
4242
@FXML
4343
private CheckMenuItem mniTimerEnabled;
44+
@FXML
45+
private MenuItem mniCountDown;
46+
4447
private TrayIconController trayIconController;
4548
private SettingsController settingsController;
4649
private UpdateController updateController;
4750
private ResourceBundle translationBundle;
4851
private TimerTask timerTask;
49-
private boolean timerEnabled;
52+
private TimerTask countDownTask;
5053
private final String platformName;
5154
private final HelpUtils helpUtils;
5255
private final ObjectMapper objectMapper;
5356
private final Timer timer;
57+
private final Timer countDownTimer;
5458
private final IAudioTimer audioTimer;
5559
private final Logger logger;
5660

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

6771
this.timer = new Timer();
72+
this.countDownTimer = new Timer();
6873
this.audioTimer = this;
6974
this.objectMapper = new ObjectMapper();
7075
}
@@ -182,7 +187,7 @@ private void checkForUpdates(final boolean showNoUpdates, final boolean showErro
182187
} else {
183188
logger.info("No updates available");
184189
if (showNoUpdates) {
185-
FxUtils.showInformationAlert(translationBundle.getString("NoUpdateAvailable"), null);
190+
FxUtils.showInformationAlert(translationBundle.getString("NoUpdateAvailable"), getClass().getResourceAsStream(SharedVariables.ICON_URL));
186191
}
187192
}
188193
} catch (final InterruptedException | IOException | InvalidHttpResponseCodeException | URISyntaxException ex) {
@@ -256,7 +261,7 @@ public void run() {
256261
*/
257262
@FXML
258263
private void initialize() {
259-
mniTimerEnabled.setOnAction(e -> {
264+
mniTimerEnabled.setOnAction(_ -> {
260265
if (mniTimerEnabled.isSelected()) {
261266
final Properties properties = settingsController.getProperties();
262267
final long timerDelay = Long.parseLong(properties.getProperty("timerDelay", "3600000"));
@@ -420,7 +425,7 @@ private void settingsAction() {
420425
primaryStage.getIcons().add(new Image(Objects.requireNonNull(getClass().getResourceAsStream(SharedVariables.ICON_URL))));
421426
primaryStage.setScene(new Scene(root));
422427

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

425430
logger.info("Showing the SettingsWindow");
426431
primaryStage.show();
@@ -530,8 +535,8 @@ private void updateAction() {
530535
*/
531536
@Override
532537
public void fired() {
538+
cancelTimer();
533539
getAllSoundPanes(grpControls).forEach(SoundPane::pause);
534-
mniTimerEnabled.setSelected(false);
535540

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

623-
timerEnabled = false;
624-
625628
if (timerTask != null) {
626629
timerTask.cancel();
627630
timer.purge();
628631
}
629632

633+
if (countDownTask != null) {
634+
countDownTask.cancel();
635+
countDownTimer.purge();
636+
}
637+
638+
Platform.runLater(() -> mniCountDown.setVisible(false));
639+
630640
if (audioTimer != null) {
631641
audioTimer.cancelled();
632642
}
@@ -643,25 +653,48 @@ public void scheduleTimer(final long delay) {
643653

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

646-
timerEnabled = true;
647-
648656
if (timerTask != null) {
649657
timerTask.cancel();
650658
timer.purge();
651659
}
652660

661+
if (countDownTask != null) {
662+
countDownTask.cancel();
663+
countDownTimer.purge();
664+
}
665+
653666
timerTask = new TimerTask() {
654667
@Override
655668
public void run() {
656669
logger.info("Timer has fired");
657-
if (timerEnabled) {
658-
audioTimer.fired();
659-
}
660-
timerEnabled = false;
670+
audioTimer.fired();
671+
}
672+
};
673+
674+
countDownTask = new TimerTask() {
675+
final long seconds = delay / 1000;
676+
int i = 0;
677+
678+
@Override
679+
public void run() {
680+
i++;
681+
long timeLeft = (seconds - (i % seconds));
682+
683+
// Calculate hours, minutes and seconds
684+
long hours = timeLeft / 3600;
685+
long minutes = (timeLeft % 3600) / 60;
686+
long seconds = timeLeft % 60;
687+
688+
// Format the values to HH:MM:SS with leading zeros if necessary
689+
final String timeLeftFormatted = String.format("%02d:%02d:%02d", hours, minutes, seconds);
690+
Platform.runLater(() -> mniCountDown.setText(timeLeftFormatted));
661691
}
662692
};
663693

664694
timer.schedule(timerTask, delay);
695+
countDownTimer.schedule(countDownTask, 0, 1000);
696+
697+
mniCountDown.setVisible(true);
665698
}
666699

667700
/**

src/main/java/com/codedead/opal/controller/TrayIconController.java

+20-8
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ private void createTrayIcon() throws IOException {
6161

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

6969
localTrayIcon.addMouseListener(new java.awt.event.MouseAdapter() {
7070
@Override
@@ -98,8 +98,7 @@ public void showTrayIcon() throws IOException {
9898
logger.info("Displaying tray icon");
9999
if (trayIcon == null) {
100100
createTrayIcon();
101-
if (trayIcon == null) {
102-
logger.warn("TrayIcon cannot be null!");
101+
if (invalidTrayIcon()) {
103102
return;
104103
}
105104
}
@@ -119,8 +118,8 @@ public void showTrayIcon() throws IOException {
119118
*/
120119
public void hideTrayIcon() {
121120
logger.info("Hiding tray icon");
122-
if (trayIcon == null) {
123-
logger.warn("TrayIcon cannot be null!");
121+
122+
if (invalidTrayIcon()) {
124123
return;
125124
}
126125

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

130129
trayIcon = null;
131130
}
131+
132+
/**
133+
* Check if the tray icon is valid
134+
*
135+
* @return True if the tray icon is valid, false otherwise
136+
*/
137+
private boolean invalidTrayIcon() {
138+
if (trayIcon == null) {
139+
logger.warn("TrayIcon cannot be null!");
140+
return true;
141+
}
142+
return false;
143+
}
132144
}

src/main/java/com/codedead/opal/utils/SharedVariables.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
public final class SharedVariables {
44

55
public static final String ICON_URL = "/images/opal.png";
6-
public static final String CURRENT_VERSION = "1.3.1.0";
6+
public static final String CURRENT_VERSION = "1.4.0.0";
77
public static final boolean PORTABLE = false;
88
public static final String DEFAULT_LOCALE = "en-US";
99

src/main/java/module-info.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
module Opal {
2+
requires java.base;
23
requires java.net.http;
34
requires javafx.controls;
45
requires javafx.fxml;
56
requires java.desktop;
67
requires java.compiler;
78
requires java.naming;
89
requires javafx.media;
9-
//noinspection Java9RedundantRequiresStatement
10-
requires jdk.crypto.ec; // Added for SSL handshakes
1110
requires org.apache.logging.log4j;
1211
requires org.apache.logging.log4j.core;
1312
requires com.fasterxml.jackson.core;

src/main/resources/audio/dolphin.mp3

558 KB
Binary file not shown.
1.41 MB
Binary file not shown.
1.22 MB
Binary file not shown.

0 commit comments

Comments
 (0)