From 6cf3593688e30c22deb066b362d3cb126c606219 Mon Sep 17 00:00:00 2001 From: CodeDead Date: Fri, 12 Jul 2024 15:49:45 +0200 Subject: [PATCH] feat: code refactoring --- README.md | 1 + .../opal/controller/TrayIconController.java | 20 +++- .../OpalApplication_en_US.properties | 101 ------------------ 3 files changed, 17 insertions(+), 105 deletions(-) delete mode 100644 src/main/resources/translations/OpalApplication_en_US.properties diff --git a/README.md b/README.md index 740b08a..edcc23a 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/main/java/com/codedead/opal/controller/TrayIconController.java b/src/main/java/com/codedead/opal/controller/TrayIconController.java index 46e10c9..1719d7b 100644 --- a/src/main/java/com/codedead/opal/controller/TrayIconController.java +++ b/src/main/java/com/codedead/opal/controller/TrayIconController.java @@ -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 (!validTrayIcon()) { return; } } @@ -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 (!validTrayIcon()) { return; } @@ -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 validTrayIcon() { + if (trayIcon == null) { + logger.warn("TrayIcon cannot be null!"); + return false; + } + return true; + } } diff --git a/src/main/resources/translations/OpalApplication_en_US.properties b/src/main/resources/translations/OpalApplication_en_US.properties deleted file mode 100644 index e9551b7..0000000 --- a/src/main/resources/translations/OpalApplication_en_US.properties +++ /dev/null @@ -1,101 +0,0 @@ -About=About -AboutText=Opal was created by DeadLine\n\nAudio: ZapSplat.com\nImages: Remix Icon\nTheme: AtlantaFX\nVersion: 1.3.1\n\nCopyright © 2024 CodeDead -AboutWindowError=Unable to open the About Window! -AboutWindowTitle=Opal - About -AutoUpdate=Automatically check for updates -Birds=Birds -Chatter=Chatter -CheckForUpdates=Check for updates -Close=Close -ConfirmReset=Are you sure you want to reset all settings? -Donate=Donate -Exit=Exit -File=_File -FileExecutionError=Unable to open the file! -Fireplace=Fireplace -General=General -Help=Help -HelpFileError=Unable to open the help file! -HelpMenu=_Help -Homepage=Homepage -Language=Language -License=License -LicenseFileError=Unable to open the license file! -LogLevel=Log level -MainWindowTitle=Opal -Nature=Nature -NewUpdateAvailable=Version {v} is now available. Would you like to download this update? -NoUpdateAvailable=No updates available! -Office=Office -OpenSoundPreset=Open sound preset -OpenSoundPresetError=Unable to open the sound preset! -Phone=Phone -Rain=Rain -Reset=Reset -ResetSettingsError=Unable to reset all settings! -RestartRequired=A restart is required in order to change the language! -Save=Save -SaveSettingsError=Unable to save settings! -SaveSoundPreset=Save sound settings -SaveSoundPresetError=Unable to save the sound settings! -Settings=Settings -SettingsWindowError=Unable to open the Settings Window! -SettingsWindowTitle=Opal - Settings -Thunder=Thunder -Tools=_Tools -Traffic=Traffic -Typing=Typing -UpdateError=Unable to check for updates! -WebsiteError=Unable to open website! -Wind=Wind -River=River -Clock=Clock -Static=Static -Other=Other -Timer=Timer -Enabled=Enabled -Delay=Delay -Seconds=Second(s) -Minutes=Minute(s) -Hours=Hour(s) -TimerDelayTooSmall=Timer delay cannot be smaller than 1! -Fantasy=Fantasy -Fan=Fan -TimerApplicationShutdown=Exit Opal -Cave=Cave -Frogs=Frogs -Zen=Zen -Coffee=Coffee -Zoo=Zoo -Audiences=Audiences -NetworkingEvent=Networking event -TribalFestival=Tribal festival -RugbyFootball=Rugby football -Sleepy=Sleepy -DrumTribalFestival=Drum tribal festival -Gong=Gong -MediaButtons=Media buttons -DragDrop=Drag and drop files -Theme=Theme -Space=Space -Restaurant=Restaurant -Cancel=Cancel -Display=Display -TrayIcon=Tray icon -TrayIconError=Unable to create tray icon! -Ocean=Ocean -Train=Train -WhiteNoise=White noise -RadioFrequencyStatic=Radio frequency static -PinkNoise=Pink noise -BrownNoise=Brown noise -TimerComputerShutdown=Shutdown computer -AudioBalance=Audio balance -Advanced=Advanced -Seagulls=Seagulls -Belltower=Bell tower -SlowMetronome=Metronome (slow) -FastMetronome=Metronome (fast) -PlayPause=Play / Pause -PlayPauseError=Unable to play / pause! -Dolphins=Dolphins