Merge remote-tracking branch 'origin/develop' into develop

This commit is contained in:
Jannik 2017-12-09 10:14:45 +01:00
commit 68d3445afe
4 changed files with 29 additions and 23 deletions

View File

@ -71,7 +71,6 @@ public class Main extends Application {
public void start(Stage primaryStage) { public void start(Stage primaryStage) {
try { try {
this.primaryStage = primaryStage; this.primaryStage = primaryStage;
cloudController = new CloudController(mainWindowController);
mainWindow(); mainWindow();
initActions(); initActions();
} catch (Exception e) { } catch (Exception e) {
@ -90,6 +89,7 @@ public class Main extends Application {
mainWindowController = loader.getController(); // Link of FXMLController and controller class mainWindowController = loader.getController(); // Link of FXMLController and controller class
mainWindowController.setMain(this); // call setMain mainWindowController.setMain(this); // call setMain
cloudController = new CloudController(mainWindowController); // call cloudController constructor
// get OS and the specific paths // get OS and the specific paths
if (System.getProperty("os.name").equals("Linux")) { if (System.getProperty("os.name").equals("Linux")) {
@ -158,6 +158,7 @@ public class Main extends Application {
// loading settings and initialize UI, dbController.main() loads all databases // loading settings and initialize UI, dbController.main() loads all databases
mainWindowController.init(); mainWindowController.init();
mainWindowController.dbController.main(); mainWindowController.dbController.main();
// if cloud sync is activated start sync
if(mainWindowController.isCloudSync()) { if(mainWindowController.isCloudSync()) {
cloudController.initializeConnection(mainWindowController.getCloudService(), mainWindowController.getCemuPath()); cloudController.initializeConnection(mainWindowController.getCloudService(), mainWindowController.getCemuPath());
cloudController.stratupCheck(mainWindowController.getCloudService(), mainWindowController.getCemuPath()); cloudController.stratupCheck(mainWindowController.getCloudService(), mainWindowController.getCemuPath());

View File

@ -976,6 +976,11 @@ public class MainWindowController {
//TODO rework for other cloud services //TODO rework for other cloud services
cloudService = "GoogleDrive"; cloudService = "GoogleDrive";
// start cloud sync in new thread
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
if (main.cloudController.initializeConnection(getCloudService(), getCemuPath())) { if (main.cloudController.initializeConnection(getCloudService(), getCemuPath())) {
main.cloudController.sync(getCloudService(), getCemuPath()); main.cloudController.sync(getCloudService(), getCemuPath());
saveSettings(); saveSettings();
@ -990,6 +995,10 @@ public class MainWindowController {
JFXInfoDialog cloudSyncErrorDialog = new JFXInfoDialog(headingText, bodyText, dialogBtnStyle, 450, 170, main.pane); JFXInfoDialog cloudSyncErrorDialog = new JFXInfoDialog(headingText, bodyText, dialogBtnStyle, 450, 170, main.pane);
cloudSyncErrorDialog.show(); cloudSyncErrorDialog.show();
} }
}
});
thread.start();
} }
}; };

View File

@ -106,7 +106,7 @@ public class CloudController {
@Override @Override
public void run() { public void run() {
Platform.runLater(() -> { Platform.runLater(() -> {
mwc.getPlayBtn().setText("syncing..."); // FIXME we get a NullPointerException here, because playBtn dosen't exist mwc.getPlayBtn().setText("syncing...");
}); });
LOGGER.info("starting synchronization in new thread ..."); LOGGER.info("starting synchronization in new thread ...");
@ -121,7 +121,7 @@ public class CloudController {
} }
Platform.runLater(() -> { Platform.runLater(() -> {
mwc.getPlayBtn().setText("play"); // FIXME we get a NullPointerException here, because playBtn dosen't exist mwc.getPlayBtn().setText("play");
mwc.saveSettings(); mwc.saveSettings();
}); });
LOGGER.info("synchronization successful!"); LOGGER.info("synchronization successful!");

View File

@ -103,10 +103,6 @@ public class GoogleDriveController {
// Load client secrets. // Load client secrets.
InputStream in = getClass().getClassLoader().getResourceAsStream("client_secret.json"); InputStream in = getClass().getClassLoader().getResourceAsStream("client_secret.json");
GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(JSON_FACTORY, new InputStreamReader(in)); GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(JSON_FACTORY, new InputStreamReader(in));
//FIXME Linux fails to open a new browser window, application crashes
// see: https://github.com/Seil0/cemu_UI/issues/10
// Build flow and trigger user authorization request.
GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(HTTP_TRANSPORT, JSON_FACTORY, clientSecrets, SCOPES) GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(HTTP_TRANSPORT, JSON_FACTORY, clientSecrets, SCOPES)
.setDataStoreFactory(DATA_STORE_FACTORY) .setDataStoreFactory(DATA_STORE_FACTORY)
.setAccessType("offline") .setAccessType("offline")