From 3f6eeece7d9cb3bd0b4094c7be39f8f3cd5713e5 Mon Sep 17 00:00:00 2001 From: Seil0 Date: Sun, 2 Dec 2018 23:51:14 +0100 Subject: [PATCH] updated some libs, code clean up * openjfx 11 -> 11.0.1 * jfoenix 9.0.6 -> 9.0.8 * sqlite-jdbc 3.23.2 -> 3.25.2 * google-api-services-drive rev129 -> rev136 * jackson-core 2.9.6 -> 2.9.7 --- pom.xml | 62 +----- .../application/MainWindowController.java | 189 +++++++----------- .../cemu_UI/controller/CloudController.java | 51 +++-- .../cemu_UI/datatypes/GlobalDataTypes.java | 29 +++ 4 files changed, 134 insertions(+), 197 deletions(-) create mode 100644 src/main/java/com/cemu_UI/datatypes/GlobalDataTypes.java diff --git a/pom.xml b/pom.xml index b340728..9d4e913 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com cemu_UI - 0.3.1-SNAPSHOT + 0.3.2-SNAPSHOT jar cemu_UI cemu_UI is a simple, material design graphical frontend for cemu, a Wii U emulator @@ -27,25 +27,25 @@ org.openjfx javafx-controls - 11 + 11.0.1 org.openjfx javafx-fxml - 11 + 11.0.1 org.openjfx javafx-media - 11 + 11.0.1 com.jfoenix jfoenix - 9.0.6 + 9.0.8 @@ -57,7 +57,7 @@ org.xerial sqlite-jdbc - 3.23.1 + 3.25.2 @@ -92,14 +92,6 @@ 1.11 - - - io.datafx - flow - 8.0.1 - - - net.lingala.zip4j @@ -115,18 +107,11 @@ 1.1.1 - - - com.google.api-client - google-api-client - 1.25.0 - - com.google.apis google-api-services-drive - v3-rev129-1.25.0 + v3-rev136-1.25.0 @@ -143,20 +128,6 @@ 1.25.0 - - - com.google.oauth-client - google-oauth-client - 1.25.0 - - - - - com.google.oauth-client - google-oauth-client-java6 - 1.25.0 - - com.google.oauth-client @@ -168,15 +139,7 @@ com.fasterxml.jackson.core jackson-core - 2.9.6 - - - - - javax.servlet - javax.servlet-api - 4.0.1 - provided + 2.9.7 @@ -186,13 +149,6 @@ 6.1.26 - - - org.mortbay.jetty - jetty-util - 6.1.26 - - @@ -229,7 +185,7 @@ org.apache.maven.plugins maven-shade-plugin - 3.1.1 + 3.2.1 package diff --git a/src/main/java/com/cemu_UI/application/MainWindowController.java b/src/main/java/com/cemu_UI/application/MainWindowController.java index 99e6640..dd5b480 100644 --- a/src/main/java/com/cemu_UI/application/MainWindowController.java +++ b/src/main/java/com/cemu_UI/application/MainWindowController.java @@ -57,6 +57,7 @@ import com.cemu_UI.controller.DBController; import com.cemu_UI.controller.SmmdbAPIController; import com.cemu_UI.controller.UpdateController; import com.cemu_UI.datatypes.CourseTableDataType; +import com.cemu_UI.datatypes.GlobalDataTypes.CloudService; import com.cemu_UI.datatypes.SmmdbApiDataType; import com.cemu_UI.datatypes.UIROMDataType; import com.cemu_UI.uiElements.JFXEditGameDialog; @@ -109,130 +110,73 @@ import net.lingala.zip4j.exception.ZipException; public class MainWindowController { - @FXML - private JFXButton aboutBtn; - @FXML - private JFXButton settingsBtn; - @FXML - private JFXButton addBtn; - @FXML - private JFXButton reloadRomsBtn; - @FXML - private JFXButton smmdbBtn; - @FXML - private JFXButton cemuTFBtn; - @FXML - private JFXButton romTFBtn; - @FXML - private JFXButton updateBtn; - @FXML - private JFXButton smmdbDownloadBtn; - @FXML - private JFXButton playBtn; - @FXML - private JFXButton lastTimePlayedBtn; - @FXML - JFXButton totalPlaytimeBtn; + @FXML private JFXButton aboutBtn; + @FXML private JFXButton settingsBtn; + @FXML private JFXButton addBtn; + @FXML private JFXButton reloadRomsBtn; + @FXML private JFXButton smmdbBtn; + @FXML private JFXButton cemuTFBtn; + @FXML private JFXButton romTFBtn; + @FXML private JFXButton updateBtn; + @FXML private JFXButton smmdbDownloadBtn; + @FXML private JFXButton playBtn; + @FXML private JFXButton lastTimePlayedBtn; + @FXML JFXButton totalPlaytimeBtn; - @FXML - private JFXHamburger menuHam; + @FXML private JFXHamburger menuHam; - @FXML - private JFXTextField cemuTextField; - @FXML - private JFXTextField romTextField; - @FXML - private JFXTextField courseSearchTextFiled; - @FXML - private JFXTextField executeCommandTextFiled; + @FXML private JFXTextField cemuTextField; + @FXML private JFXTextField romTextField; + @FXML private JFXTextField courseSearchTextFiled; + @FXML private JFXTextField executeCommandTextFiled; - @FXML - private TextFlow smmdbTextFlow; + @FXML private TextFlow smmdbTextFlow; - @FXML - private JFXColorPicker colorPicker; + @FXML private JFXColorPicker colorPicker; - @FXML - private JFXToggleButton cloudSyncToggleBtn; - @FXML - private JFXToggleButton autoUpdateToggleBtn; - @FXML - private JFXToggleButton fullscreenToggleBtn; + @FXML private JFXToggleButton cloudSyncToggleBtn; + @FXML private JFXToggleButton autoUpdateToggleBtn; + @FXML private JFXToggleButton fullscreenToggleBtn; - @FXML - private ChoiceBox languageChoisBox; - @FXML - private ChoiceBox branchChoisBox; + @FXML private ChoiceBox languageChoisBox; + @FXML private ChoiceBox branchChoisBox; - @FXML - private AnchorPane mainAnchorPane; - @FXML - private AnchorPane gamesAnchorPane; - @FXML - private AnchorPane settingsAnchorPane; - @FXML - private AnchorPane smmdbAnchorPane; + @FXML private AnchorPane mainAnchorPane; + @FXML private AnchorPane gamesAnchorPane; + @FXML private AnchorPane settingsAnchorPane; + @FXML private AnchorPane smmdbAnchorPane; - @FXML - private ScrollPane mainScrollPane; - @FXML - private ScrollPane settingsScrollPane; - @FXML - private ScrollPane smmdbScrollPane; - @FXML - private ScrollPane smmdbImageViewScrollPane; + @FXML private ScrollPane mainScrollPane; + @FXML private ScrollPane settingsScrollPane; + @FXML private ScrollPane smmdbScrollPane; + @FXML private ScrollPane smmdbImageViewScrollPane; - @FXML - private VBox sideMenuVBox; + @FXML private VBox sideMenuVBox; - @FXML - private HBox topHBox; - @FXML - private HBox bottomHBox; + @FXML private HBox topHBox; + @FXML private HBox bottomHBox; - @FXML - private ImageView smmdbImageView; + @FXML private ImageView smmdbImageView; - @FXML - private Label helpLbl; - @FXML - private Label cemu_UISettingsLbl; - @FXML - private Label cemuDirectoryLbl; - @FXML - private Label romDirectoryLbl; - @FXML - private Label mainColorLbl; - @FXML - private Label languageLbl; - @FXML - private Label updateLbl; - @FXML - private Label branchLbl; - @FXML - private Label cemuSettingsLbl; - @FXML - private Label licensesLbl; + @FXML private Label helpLbl; + @FXML private Label cemu_UISettingsLbl; + @FXML private Label cemuDirectoryLbl; + @FXML private Label romDirectoryLbl; + @FXML private Label mainColorLbl; + @FXML private Label languageLbl; + @FXML private Label updateLbl; + @FXML private Label branchLbl; + @FXML private Label cemuSettingsLbl; + @FXML private Label licensesLbl; - @FXML - private JFXTreeTableView courseTreeTable = new JFXTreeTableView(); + @FXML private JFXTreeTableView courseTreeTable = new JFXTreeTableView(); - @FXML - private TreeItem root = new TreeItem<>(new CourseTableDataType("", "", 0, 0)); + @FXML private TreeItem root = new TreeItem<>(new CourseTableDataType("", "", 0, 0)); - @FXML - private JFXTreeTableColumn titleColumn = new JFXTreeTableColumn<>("title"); - @FXML - private JFXTreeTableColumn idColumn = new JFXTreeTableColumn<>("id"); - @FXML - private JFXTreeTableColumn starsColumn = new JFXTreeTableColumn<>("stars"); - @FXML - private JFXTreeTableColumn timeColumn = new JFXTreeTableColumn<>("time"); - - @SuppressWarnings("unused") - private enum CloudService { - GoogleDrive, Dropbox - } + @FXML private JFXTreeTableColumn titleColumn = new JFXTreeTableColumn<>("title"); + @FXML private JFXTreeTableColumn idColumn = new JFXTreeTableColumn<>("id"); + @FXML private JFXTreeTableColumn starsColumn = new JFXTreeTableColumn<>("stars"); + @FXML private JFXTreeTableColumn timeColumn = new JFXTreeTableColumn<>("time"); private Main main; private DBController dbController; @@ -248,7 +192,7 @@ public class MainWindowController { private boolean useBeta = false; private boolean fullscreen; private boolean cloudSync; - private String cloudService = ""; // set cloud provider (at the moment only GoogleDrive, Dropbox is planed) + private CloudService cloudService; private String cemuPath; private String romDirectoryPath; private String gameExecutePath; @@ -257,8 +201,8 @@ public class MainWindowController { private String selectedGameTitleID; private String selectedGameTitle; private String id; - private String version = "0.3.1"; - private String buildNumber = "081"; + private String version = "0.3.2"; + private String buildNumber = "085"; private String versionName = "Purple Comet"; private int xPos = -200; private int yPos = 17; @@ -1020,7 +964,7 @@ public class MainWindowController { cloudSync = true; //TODO rework for other cloud services // CloudService service = CloudService.GoogleDrive; - cloudService = "GoogleDrive"; + cloudService = CloudService.GoogleDrive; // start cloud sync in new thread Thread thread = new Thread(new Runnable() { @@ -1606,7 +1550,7 @@ public class MainWindowController { if (getCloudService() == null) { props.setProperty("cloudService", ""); } else { - props.setProperty("cloudService", getCloudService()); + props.setProperty("cloudService", getCloudService().toString()); } props.setProperty("folderID", main.getCloudController().getFolderID(getCloudService())); props.setProperty("lastLocalSync", String.valueOf(getLastLocalSync())); @@ -1689,10 +1633,19 @@ public class MainWindowController { } try { - setCloudService(props.getProperty("cloudService")); + switch (props.getProperty("cloudService")) { + case "GoogleDrive": + setCloudService(CloudService.GoogleDrive); + break; + case "Dropbox": + setCloudService(CloudService.Dropbox); + break; + default: + break; + } } catch (Exception e) { LOGGER.error("could not load cloudSync", e); - setCloudService(""); + setCloudService(null); } try { @@ -1920,11 +1873,11 @@ public class MainWindowController { this.selectedGameTitleID = selectedGameTitleID; } - public String getCloudService() { + public CloudService getCloudService() { return cloudService; } - public void setCloudService(String cloudService) { + public void setCloudService(CloudService cloudService) { this.cloudService = cloudService; } diff --git a/src/main/java/com/cemu_UI/controller/CloudController.java b/src/main/java/com/cemu_UI/controller/CloudController.java index 6e3f385..829a059 100644 --- a/src/main/java/com/cemu_UI/controller/CloudController.java +++ b/src/main/java/com/cemu_UI/controller/CloudController.java @@ -32,6 +32,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import com.cemu_UI.application.MainWindowController; +import com.cemu_UI.datatypes.GlobalDataTypes.CloudService; import com.cemu_UI.vendorCloudController.GoogleDriveController; import javafx.application.Platform; @@ -48,11 +49,11 @@ public class CloudController { private GoogleDriveController googleDriveController = new GoogleDriveController(); private static final Logger LOGGER = LogManager.getLogger(CloudController.class.getName()); - public boolean initializeConnection(String cloudService, String cemuDirectory) { + public boolean initializeConnection(CloudService cloudService, String cemuDirectory) { boolean success = false; LOGGER.info("sartting cloud initialisation ..."); - if(cloudService.equals("GoogleDrive")) { + if(cloudService == CloudService.GoogleDrive) { LOGGER.info("selected service is Google Drive"); try { googleDriveController.main(cemuDirectory); @@ -63,7 +64,7 @@ public class CloudController { success = true; } - if(cloudService.equals("Dropbox")) { + if(cloudService == CloudService.Dropbox) { LOGGER.info("selected service is Dropbox"); } LOGGER.info("cloud initialisation done!"); @@ -76,7 +77,7 @@ public class CloudController { * @param cemuDirectory * @param cemu_UIDirectory */ - public void sync(String cloudService, String cemuDirectory, String cemu_UIDirectory) { + public void sync(CloudService cloudService, String cemuDirectory, String cemu_UIDirectory) { // running sync in a new thread, instead of blocking the main thread Thread thread = new Thread(new Runnable() { @@ -88,18 +89,18 @@ public class CloudController { mwc.getPlayBtn().setText("syncing..."); }); LOGGER.info("starting synchronization in new thread ..."); - + // zip the saves folder File zipFile = zipSavegames(cemu_UIDirectory, cemuDirectory); // upload the zip switch (cloudService) { - + // use GoogleDriveController - case "GoogleDrive": + case GoogleDrive: LOGGER.info("using GoogleDriveController"); long lastCloudSync = googleDriveController.getLastCloudSync(); - + if (!googleDriveController.checkFolder()) { LOGGER.info("cloud sync folder dosen't exist, creating one!"); googleDriveController.creatFolder(); @@ -107,7 +108,7 @@ public class CloudController { } else if (mwc.getLastLocalSync() > lastCloudSync) { LOGGER.info("local is new, going to upload zip"); googleDriveController.uploadZipFile(zipFile); - } else if(mwc.getLastLocalSync() < lastCloudSync) { + } else if (mwc.getLastLocalSync() < lastCloudSync) { LOGGER.info("cloud is new, going to download zip"); unzipSavegames(cemuDirectory, googleDriveController.downloadZipFile(cemu_UIDirectory)); mwc.setLastLocalSync(lastCloudSync); @@ -116,21 +117,18 @@ public class CloudController { LOGGER.info("nothing to do"); break; } - mwc.setLastLocalSync(Long.parseLong(zipFile.getName().substring(0, zipFile.getName().length()-4))); // set time of last sucessfull sync - break; - - - - case "Dropbox": - + mwc.setLastLocalSync(Long.parseLong(zipFile.getName().substring(0, zipFile.getName().length() - 4))); // set time of last sucessfull sync + break; + + case Dropbox: + // do the thing break; - default: LOGGER.warn("no cloud vendor found!"); break; } - + zipFile.delete(); // delete zipfile in cem_UI directory Platform.runLater(() -> { @@ -138,11 +136,12 @@ public class CloudController { mwc.getPlayBtn().setDisable(false); mwc.saveSettings(); }); - LOGGER.info("synchronization successful!"); } catch (Exception e) { - LOGGER.error("There was an error during syncronisation! Please open a new issue on the cemu_UI github page:", e); + LOGGER.error( + "There was an error during syncronisation! Please open a new issue on the cemu_UI github page:", + e); } } }); @@ -199,25 +198,25 @@ public class CloudController { } } - public String getFolderID(String cloudService) { + public String getFolderID(CloudService cloudService) { String folderID = ""; if (cloudService != null) { - if (cloudService.equals("GoogleDrive")) { + if (cloudService == CloudService.GoogleDrive) { folderID = googleDriveController.getFolderID(); } - if (cloudService.equals("Dropbox")) { + if (cloudService == CloudService.Dropbox) { } } return folderID; } - public void setFolderID(String folderID, String cloudService) { + public void setFolderID(String folderID, CloudService cloudService) { if (cloudService != null) { - if (cloudService.equals("GoogleDrive")) { + if (cloudService == CloudService.GoogleDrive) { googleDriveController.setFolderID(folderID); } - if (cloudService.equals("Dropbox")) { + if (cloudService == CloudService.Dropbox) { } } diff --git a/src/main/java/com/cemu_UI/datatypes/GlobalDataTypes.java b/src/main/java/com/cemu_UI/datatypes/GlobalDataTypes.java new file mode 100644 index 0000000..2d37806 --- /dev/null +++ b/src/main/java/com/cemu_UI/datatypes/GlobalDataTypes.java @@ -0,0 +1,29 @@ +/** + * cemu_UI + * + * Copyright 2017-2018 <@Seil0> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +package com.cemu_UI.datatypes; + +public class GlobalDataTypes { + + public enum CloudService { + GoogleDrive, Dropbox + } +}