Skip to content

Commit

Permalink
0.5.2 - Fix errors in about window
Browse files Browse the repository at this point in the history
  • Loading branch information
georgewoodall82 committed Jul 15, 2024
1 parent 4316cb3 commit 0f7f417
Show file tree
Hide file tree
Showing 13 changed files with 59 additions and 38 deletions.
4 changes: 3 additions & 1 deletion io.github.georgewoodall82.jsymphonic.metainfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
<content_rating type="oars-1.1" />

<releases>
<release version="0.5.1" date="2024-07-15/">
<release version="0.5.2" date="2024-07-15">
</release>
<release version="0.5.1" date="2024-07-15">
</release>
<release version="0.5.0" date="2024-07-14">
</release>
Expand Down
9 changes: 7 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>jsymphonic</groupId>
<artifactId>jsymphonic</artifactId>
<version>0.5.1</version>
<version>0.5.2</version>
<packaging>jar</packaging>
<build>
<plugins>
Expand Down Expand Up @@ -53,6 +53,11 @@
<groupId>org</groupId>
<artifactId>jaudiotagger</artifactId>
<version>2.0.3</version>
</dependency>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.16.1</version>
</dependency>
</dependencies>
</project>
31 changes: 30 additions & 1 deletion src/main/java/com/pipasoft/jsymphonic/ResourceLoader.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
package com.pipasoft.jsymphonic;

import java.io.*;
import java.io.InputStream;
import java.net.URL;
import java.nio.file.Files;
import java.util.stream.Collectors;

import javax.swing.ImageIcon;

import org.apache.commons.io.FileUtils;

/**
* a more centralized place to load resources
*
Expand Down Expand Up @@ -32,4 +38,27 @@ public static ImageIcon getIcon(String name) {
return new ImageIcon(get(name));
}

}
/**
* gets the contents of a file in the resources folder as a String
*
* @param fileName the name/path to a file in the resources folder
* @return the string contents of the file
*/
public static String getResourceFileAsString(String fileName){
try {
ClassLoader classLoader = ClassLoader.getSystemClassLoader();
try (InputStream is = classLoader.getResourceAsStream(fileName)) {
if (is == null) return null;
try (InputStreamReader isr = new InputStreamReader(is);
BufferedReader reader = new BufferedReader(isr)) {
return reader.lines().collect(Collectors.joining(System.lineSeparator()));
}
}

} catch (Exception e) {
e.printStackTrace();
return "";
}
}

}
31 changes: 6 additions & 25 deletions src/main/java/org/danizmax/jsymphonic/gui/JSymphonicAbout.java
Original file line number Diff line number Diff line change
Expand Up @@ -299,31 +299,12 @@ private void initComponents() {
* The license file is stored in "org/danizmax/jsymphonic/resources". It is named "COPYING-xx_XX" where xx_XX is the language code. If the license is not translated into the current language (the file doesn't exist), load the english version named "COPYING.txt".
*/
private void loadLicenseTextArea() {
BufferedReader licenseReader = null;

// Try to load the license file corresponding to the current language code
try {
licenseReader = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream("/org/danizmax/jsymphonic/resources/COPYING_"+Locale.getDefault().toString()+".txt")));
}
catch(Exception e){
try {
// If an exception was thrown, load the english version
licenseReader = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream("/org/danizmax/jsymphonic/resources/COPYING.txt")));
} catch (Exception ex) {
ex.printStackTrace();
Logger.getLogger(JSymphonicAbout.class.getName()).log(Level.SEVERE, null, ex);
}
}

// Load the text from the file to the text area
try {
String str;
while ((str = licenseReader.readLine()) != null) {
licenseTextArea.append(str + "\n"); // Add each read line to the text area
}
licenseReader.close();
}
catch (Exception e) {}

String license = ResourceLoader.getResourceFileAsString("COPYING_"+Locale.getDefault().toString()+".txt");
if (license == null || license.isBlank()) {
license = ResourceLoader.getResourceFileAsString("COPYING.txt");
}
licenseTextArea.append(license); // Add each read line to the text area
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,11 @@ private void importButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-
}//GEN-LAST:event_importButtonActionPerformed

private void aboutMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_aboutMenuItemActionPerformed
JSymphonicAbout ab = new JSymphonicAbout(java.util.ResourceBundle.getBundle("localization/jsymphonicwindow").getString("JSymphonicWindow.About_JSymphonic"), java.util.ResourceBundle.getBundle("localization/misc").getString("global.version"),java.util.ResourceBundle.getBundle("localization/jsymphonicwindow").getString("JSymphonicWindow.Thanks_for_using"), java.util.ResourceBundle.getBundle("localization/jsymphonicwindow").getString("JSymphonicWindow.The_JSymphonic_team"));
JSymphonicAbout ab = new JSymphonicAbout(
java.util.ResourceBundle.getBundle("localization/jsymphonicwindow").getString("JSymphonicWindow.About_JSymphonic"),
java.util.ResourceBundle.getBundle("localization/misc").getString("global.version"),
java.util.ResourceBundle.getBundle("localization/jsymphonicwindow").getString("JSymphonicWindow.Thanks_for_using"),
java.util.ResourceBundle.getBundle("localization/jsymphonicwindow").getString("JSymphonicWindow.The_JSymphonic_team"));
ab.setLocationRelativeTo(this);
ab.setVisible(true);
}//GEN-LAST:event_aboutMenuItemActionPerformed
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/localization/misc.properties
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ global.Filter=Filter
global.Help=Help
global.No=No
global.OK = OK
global.version=JSymphonic v0.5.1
global.version=JSymphonic v0.5.2
global.warning=Warning!
global.Yes=Yes

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/localization/misc_de_DE.properties
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ global.Filter=Filter
global.Help=Hilfe
global.No=Nein
global.OK = OK
global.version=JSymphonic v0.5.1
global.version=JSymphonic v0.5.2
global.Yes=Ja

# Log frame
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/localization/misc_es_ES.properties
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ global.Filter=Filtrar
global.Help=Ayuda
global.No=No
global.OK = Ok
global.version=JSymphonic v0.5.1
global.version=JSymphonic v0.5.2
global.warning=\u00A1Cuidado!
global.Yes=Si

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/localization/misc_fr_FR.properties
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ global.Filter=Filtre
global.Help=Aide
global.No=Non
global.OK = OK
global.version=JSymphonic v0.5.1
global.version=JSymphonic v0.5.2
global.warning=Attention!
global.Yes=Oui

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/localization/misc_it_IT.properties
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ global.Filter=Filtro
global.Help=Aiuto
global.No=No
global.OK = OK
global.version=JSymphonic v0.5.1
global.version=JSymphonic v0.5.2
global.Yes=Si

# Log frame
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/localization/misc_sv_SV.properties
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ global.Filter=Filtrera
global.Help=Hj\u00E4lp
global.No=Nej
global.OK = OK
global.version=JSymphonic v0.5.1
global.version=JSymphonic v0.5.2
global.warning=Varning!
global.Yes=Ja

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/localization/misc_tr_TR.properties
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ global.Filter=Filtre
global.Help=Yardim
global.No=Hayir
global.OK = OK
global.version=JSymphonic v0.5.1
global.version=JSymphonic v0.5.2
global.warning=Dikkat
global.Yes=Evet

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/localization/misc_zh_TW.properties
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ global.Filter=\u904E\u6FFE\u5668
global.Help=\u8AAA\u660E
global.No=\u4E0D
global.OK = \u78BA\u8A8D
global.version=JSymphonic v0.5.1
global.version=JSymphonic v0.5.2
global.warning=\u8B66\u544A!
global.Yes=\u662F

Expand Down

0 comments on commit 0f7f417

Please sign in to comment.