Skip to content

Commit

Permalink
more logger work and lib updates
Browse files Browse the repository at this point in the history
* jfoenix 1.7.0 -> 1.8.0
* sqlite 3.19.1 -> 3.20.0
* replaced all remaining syso/syse with logger output
* fixed a bug in smmdb api integration by only requesting the first 70 courses (this is a temporary workaround)
* code clean up
* typo fixes
  • Loading branch information
Seil0 committed Sep 12, 2017
1 parent 85fc66e commit 959963f
Show file tree
Hide file tree
Showing 27 changed files with 141 additions and 110 deletions.
4 changes: 2 additions & 2 deletions .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
<classpathentry kind="lib" path="src/libraries/commons-logging-api-1.1.jar"/>
<classpathentry kind="lib" path="src/libraries/commons-vfs2-2.1.1744488.2.jar"/>
<classpathentry kind="lib" path="src/libraries/flow-8.0.1.jar"/>
<classpathentry kind="lib" path="src/libraries/jfoenix-1.7.0.jar"/>
<classpathentry kind="lib" path="src/libraries/sqlite-jdbc-3.19.3.jar"/>
<classpathentry kind="lib" path="src/libraries/zip4j-1.3.2.jar"/>
<classpathentry kind="lib" path="src/libraries/log4j-api-2.8.2.jar"/>
<classpathentry kind="lib" path="src/libraries/log4j-core-2.8.2.jar"/>
<classpathentry kind="lib" path="src/libraries/jfoenix-1.8.0.jar"/>
<classpathentry kind="lib" path="src/libraries/sqlite-jdbc-3.20.0.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
3 changes: 1 addition & 2 deletions bin/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/application/
/resources/
/log4j2.xml
/snippet/
/cloudControllerInstances/
Binary file modified bin/application/CloudController$1.class
Binary file not shown.
Binary file modified bin/application/CloudController$2.class
Binary file not shown.
Binary file modified bin/application/CloudController$3.class
Binary file not shown.
Binary file modified bin/application/CloudController.class
Binary file not shown.
4 changes: 2 additions & 2 deletions bin/application/MainWindow.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@
<Font name="System Bold" size="14.0" />
</font>
</JFXButton>
<JFXButton fx:id="timePlayedBtn" buttonType="RAISED" maxHeight="32.0" minWidth="100.0" onAction="#timePlayedBtnAction" prefHeight="32.0" style="-fx-background-color: #ffffff; -fx-button-type: RAISED; -fx-text-fill: BLACK;" visible="false" AnchorPane.bottomAnchor="10.0" AnchorPane.rightAnchor="516.5" AnchorPane.topAnchor="558.0">
<JFXButton fx:id="totalPlaytimeBtn" buttonType="RAISED" maxHeight="32.0" minWidth="100.0" onAction="#totalPlaytimeBtnAction" prefHeight="32.0" style="-fx-background-color: #ffffff; -fx-button-type: RAISED; -fx-text-fill: BLACK;" visible="false" AnchorPane.bottomAnchor="10.0" AnchorPane.rightAnchor="516.5" AnchorPane.topAnchor="558.0">
</JFXButton>
<JFXButton fx:id="lastTimePlayedBtn" buttonType="RAISED" maxHeight="32.0" minWidth="100.0" onAction="#lastTimePlayedBtnAction" prefHeight="32.0" style="-fx-background-color: #ffffff; -fx-button-type: RAISED; -fx-text-fill: BLACK;" visible="false" AnchorPane.bottomAnchor="10.0" AnchorPane.leftAnchor="516.5" AnchorPane.topAnchor="558.0" />
</children>
</AnchorPane>
</AnchorPane>
Binary file modified bin/application/MainWindowController$12.class
Binary file not shown.
Binary file modified bin/application/MainWindowController.class
Binary file not shown.
Binary file modified bin/application/SmmdbApiQuery.class
Binary file not shown.
Binary file modified bin/application/dbController.class
Binary file not shown.
Binary file modified bin/application/playGame.class
Binary file not shown.
Binary file modified bin/cloudControllerInstances/GoogleDriveController.class
Binary file not shown.
Binary file not shown.
Binary file removed bin/libraries/sqlite-jdbc-3.19.3.jar
Binary file not shown.
Binary file added bin/libraries/sqlite-jdbc-3.20.0.jar
Binary file not shown.
20 changes: 20 additions & 0 deletions bin/log4j2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="INFO">
<Appenders>

<Console name="console" target="SYSTEM_OUT">
<PatternLayout pattern="[%-5level] %d{yyyy-MM-dd HH:mm:ss} [%t] %c{1} - %msg%n" />
</Console>

<File name="file" fileName="${sys:logFilename}" immediateFlush="true">
<PatternLayout pattern="[%-5level] %d{yyyy-MM-dd HH:mm:ss} [%t] %c{1} - %msg%n" />
</File>

</Appenders>
<Loggers>
<Root level="debug" additivity="false">
<AppenderRef ref="console" />
<AppenderRef ref="file"/>
</Root>
</Loggers>
</Configuration>
28 changes: 16 additions & 12 deletions src/application/CloudController.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
import java.io.File;
import java.io.IOException;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import cloudControllerInstances.GoogleDriveController;
import javafx.application.Platform;

Expand All @@ -27,26 +30,27 @@ public CloudController(Main ma) {

private Main main;
private GoogleDriveController googleDriveController = new GoogleDriveController();
private static final Logger LOGGER = LogManager.getLogger(CloudController.class.getName());

void initializeConnection(String cloudService, String cemuDirectory) {
System.out.println("sartting cloud initialisation... ");
LOGGER.info("sartting cloud initialisation ...");
if(cloudService.equals("GoogleDrive")) {
System.out.println("selected service is Google Drive");
LOGGER.info("selected service is Google Drive");
try {
googleDriveController.main(cemuDirectory);
} catch (IOException e) {
e.printStackTrace();
LOGGER.error("error while initialize connection", e);
}
}
if(cloudService.equals("Dropbox")) {
System.out.println("selected service is Dropbox");
LOGGER.info("selected service is Dropbox");
}
System.out.println("cloud initialisation done!");
LOGGER.info("cloud initialisation done!");
}

void stratupCheck(String cloudService, String cemuDirectory) {
if(cloudService.equals("GoogleDrive")) {
System.out.println("starting startup check google drive...");
LOGGER.info("starting startup check google drive ...");
try {
if (!googleDriveController.checkFolder()) {
googleDriveController.creatFolder();
Expand All @@ -69,7 +73,7 @@ public void run() {
sync(cloudService, cemuDirectory);
}
} catch (IOException e) {
e.printStackTrace();
LOGGER.error("google drive startup check failed", e);
}
}
if(cloudService.equals("Dropbox")) {
Expand All @@ -88,13 +92,13 @@ public void run() {
Platform.runLater(() -> {
main.mainWindowController.getPlayBtn().setText("syncing...");
});
System.out.println("starting sync in new thread...");
LOGGER.info("starting synchronization in new thread ...");

if(cloudService.equals("GoogleDrive")) {
try {
googleDriveController.sync(cemuDirectory);
} catch (IOException e) {
e.printStackTrace();
LOGGER.error("google drive synchronization failed", e);
}
}
if(cloudService.equals("Dropbox")) {
Expand All @@ -104,7 +108,7 @@ public void run() {
main.mainWindowController.getPlayBtn().setText("play");
});
main.mainWindowController.saveSettings();
System.out.println("sync finished!");
LOGGER.info("synchronization successful!");
}
});
thread.start();
Expand All @@ -117,13 +121,13 @@ void uploadFile(String cloudService, File file) {
new Thread() {
@Override
public void run() {
System.out.println("starting uploadFile in new thread...");
LOGGER.info("starting uploadFile in new thread ...");

if(cloudService.equals("GoogleDrive")) {
try {
googleDriveController.uploadFile(file);
} catch (IOException e) {
e.printStackTrace();
LOGGER.error("google drive uploadFile failed" ,e);
}
}
if(cloudService.equals("Dropbox")) {
Expand Down
4 changes: 2 additions & 2 deletions src/application/MainWindow.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@
<Font name="System Bold" size="14.0" />
</font>
</JFXButton>
<JFXButton fx:id="timePlayedBtn" buttonType="RAISED" maxHeight="32.0" minWidth="100.0" onAction="#timePlayedBtnAction" prefHeight="32.0" style="-fx-background-color: #ffffff; -fx-button-type: RAISED; -fx-text-fill: BLACK;" visible="false" AnchorPane.bottomAnchor="10.0" AnchorPane.rightAnchor="516.5" AnchorPane.topAnchor="558.0">
<JFXButton fx:id="totalPlaytimeBtn" buttonType="RAISED" maxHeight="32.0" minWidth="100.0" onAction="#totalPlaytimeBtnAction" prefHeight="32.0" style="-fx-background-color: #ffffff; -fx-button-type: RAISED; -fx-text-fill: BLACK;" visible="false" AnchorPane.bottomAnchor="10.0" AnchorPane.rightAnchor="516.5" AnchorPane.topAnchor="558.0">
</JFXButton>
<JFXButton fx:id="lastTimePlayedBtn" buttonType="RAISED" maxHeight="32.0" minWidth="100.0" onAction="#lastTimePlayedBtnAction" prefHeight="32.0" style="-fx-background-color: #ffffff; -fx-button-type: RAISED; -fx-text-fill: BLACK;" visible="false" AnchorPane.bottomAnchor="10.0" AnchorPane.leftAnchor="516.5" AnchorPane.topAnchor="558.0" />
</children>
</AnchorPane>
</AnchorPane>
32 changes: 16 additions & 16 deletions src/application/MainWindowController.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public class MainWindowController {
private JFXButton lastTimePlayedBtn;

@FXML
JFXButton timePlayedBtn;
JFXButton totalPlaytimeBtn;

@FXML
private JFXHamburger menuHam;
Expand Down Expand Up @@ -218,9 +218,9 @@ public class MainWindowController {
private String selectedGameTitleID;
private String selectedGameTitle;
private String id;
private String version = "0.1.6";
private String buildNumber = "037";
private String versionName = "Throwback Galaxy";
private String version = "0.1.7";
private String buildNumber = "039";
private String versionName = "Throwback Galaxy";
private int xPos = -200;
private int yPos = 17;
private int xPosHelper;
Expand Down Expand Up @@ -661,7 +661,7 @@ void playBtnAction(ActionEvent event) throws InterruptedException, IOException{
}

@FXML
void timePlayedBtnAction(ActionEvent event){
void totalPlaytimeBtnAction(ActionEvent event){

}

Expand Down Expand Up @@ -1010,7 +1010,7 @@ public void handle(MouseEvent event) {
//setting last played
if(dbController.getLastPlayed(titleID).equals("") || dbController.getLastPlayed(titleID).equals(null)){
lastTimePlayedBtn.setText("Last played, never");
timePlayedBtn.setText(dbController.getTimePlayed(titleID)+ " min");
totalPlaytimeBtn.setText(dbController.getTotalPlaytime(titleID)+ " min");
}else{
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");

Expand All @@ -1025,12 +1025,12 @@ public void handle(MouseEvent event) {
}else{
lastTimePlayedBtn.setText("Last played, "+dbController.getLastPlayed(titleID));
}
if(Integer.parseInt(dbController.getTimePlayed(titleID)) > 60){
int hoursPlayed = (int) Math.floor(Integer.parseInt(dbController.getTimePlayed(titleID))/60);
int minutesPlayed = Integer.parseInt(dbController.getTimePlayed(titleID))-60*hoursPlayed;
timePlayedBtn.setText(hoursPlayed+"h "+minutesPlayed+"min");
if(Integer.parseInt(dbController.getTotalPlaytime(titleID)) > 60){
int hoursPlayed = (int) Math.floor(Integer.parseInt(dbController.getTotalPlaytime(titleID))/60);
int minutesPlayed = Integer.parseInt(dbController.getTotalPlaytime(titleID))-60*hoursPlayed;
totalPlaytimeBtn.setText(hoursPlayed+"h "+minutesPlayed+"min");
}else{
timePlayedBtn.setText(dbController.getTimePlayed(titleID)+ " min");
totalPlaytimeBtn.setText(dbController.getTotalPlaytime(titleID)+ " min");
}
}

Expand Down Expand Up @@ -1261,7 +1261,7 @@ private void applyColor() {
}

void saveSettings(){
LOGGER.info("saving Settings...");
LOGGER.info("saving Settings ...");
OutputStream outputStream; //new output-stream
try {
props.setProperty("cemuPath", getCemuPath());
Expand Down Expand Up @@ -1293,7 +1293,7 @@ void saveSettings(){
* if a value is not present, default is used instead
*/
void loadSettings(){
LOGGER.info("loading settings...");
LOGGER.info("loading settings ...");
InputStream inputStream;
try {
if(System.getProperty("os.name").equals("Linux")){
Expand Down Expand Up @@ -1394,7 +1394,7 @@ private void sideMenuSlideOut(){
private void playBtnSlideIn(){
playBtn.setVisible(true);
lastTimePlayedBtn.setVisible(true);
timePlayedBtn.setVisible(true);
totalPlaytimeBtn.setVisible(true);
playTrue = true;

TranslateTransition playBtnTransition = new TranslateTransition(Duration.millis(300), playBtn);
Expand All @@ -1407,7 +1407,7 @@ private void playBtnSlideIn(){
lastTimePlayedBtnTransition.setToY(0);
lastTimePlayedBtnTransition.play();

TranslateTransition timePlayedBtnTransition = new TranslateTransition(Duration.millis(300), timePlayedBtn);
TranslateTransition timePlayedBtnTransition = new TranslateTransition(Duration.millis(300), totalPlaytimeBtn);
timePlayedBtnTransition.setFromY(55);
timePlayedBtnTransition.setToY(0);
timePlayedBtnTransition.play();
Expand All @@ -1425,7 +1425,7 @@ void playBtnSlideOut(){
lastTimePlayedBtnTransition.setToY(56);
lastTimePlayedBtnTransition.play();

TranslateTransition timePlayedBtnTransition = new TranslateTransition(Duration.millis(300), timePlayedBtn);
TranslateTransition timePlayedBtnTransition = new TranslateTransition(Duration.millis(300), totalPlaytimeBtn);
timePlayedBtnTransition.setFromY(0);
timePlayedBtnTransition.setToY(56);
timePlayedBtnTransition.play();
Expand Down
6 changes: 4 additions & 2 deletions src/application/SmmdbApiQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@

public class SmmdbApiQuery {

private String URL = "http://smmdb.ddns.net/api/getcourses?";
//FIXME limit=70 as workaround for to long response, courseDataGz is to long
private String URL = "http://smmdb.ddns.net/api/getcourses?format=json&limit=70";
private static final Logger LOGGER = LogManager.getLogger(SmmdbApiQuery.class.getName());

public SmmdbApiQuery() {
Expand All @@ -42,13 +43,14 @@ public ArrayList<SmmdbApiDataType> startQuery() {
BufferedReader ina = new BufferedReader(new InputStreamReader(apiUrl.openStream()));
output = ina.readLine();
ina.close();
System.out.println(output);
LOGGER.info("response from " + URL + " was valid");
} catch (IOException e) {
LOGGER.error("error while making api request or reading response");
LOGGER.error("response from " + URL + " was: " + output, e);
}

String apiOutput = "{ \"courses\": " + output + "}";
String apiOutput = "{ \"courses\": " + output + "}";
JsonArray items = Json.parse(apiOutput).asObject().get("courses").asArray();

for (JsonValue item : items) {
Expand Down
Loading

0 comments on commit 959963f

Please sign in to comment.