fixed a few cloud sync bugs

* fixed a bug where cemu_UI faild to set the correct text to the playBtn
* fixed cemu_UI crashing when activationg cloud sync under linux
This commit is contained in:
Jannik 2017-12-07 22:52:32 +01:00
parent e4bf16e7a1
commit 95df2b9359
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) {
try {
this.primaryStage = primaryStage;
cloudController = new CloudController(mainWindowController);
mainWindow();
initActions();
} catch (Exception e) {
@ -90,6 +89,7 @@ public class Main extends Application {
mainWindowController = loader.getController(); // Link of FXMLController and controller class
mainWindowController.setMain(this); // call setMain
cloudController = new CloudController(mainWindowController); // call cloudController constructor
// get OS and the specific paths
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
mainWindowController.init();
mainWindowController.dbController.main();
// if cloud sync is activated start sync
if(mainWindowController.isCloudSync()) {
cloudController.initializeConnection(mainWindowController.getCloudService(), mainWindowController.getCemuPath());
cloudController.stratupCheck(mainWindowController.getCloudService(), mainWindowController.getCemuPath());

View File

@ -975,21 +975,30 @@ public class MainWindowController {
cloudSync = true;
//TODO rework for other cloud services
cloudService = "GoogleDrive";
// start cloud sync in new thread
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
if (main.cloudController.initializeConnection(getCloudService(), getCemuPath())) {
main.cloudController.sync(getCloudService(), getCemuPath());
saveSettings();
} else {
cloudSyncToggleBtn.setSelected(false);
if (main.cloudController.initializeConnection(getCloudService(), getCemuPath())) {
main.cloudController.sync(getCloudService(), getCemuPath());
saveSettings();
} else {
cloudSyncToggleBtn.setSelected(false);
//cloud sync init error dialog
String headingText = "Error while initializing cloud sync!";
String bodyText = "There was some truble adding your game."
+ "\nPlease upload the app.log (which can be found in the cemu_UI directory)"
+ "\nto \"https://github.com/Seil0/cemu_UI/issues\" so we can fix this.";
JFXInfoDialog cloudSyncErrorDialog = new JFXInfoDialog(headingText, bodyText, dialogBtnStyle, 450, 170, main.pane);
cloudSyncErrorDialog.show();
}
//cloud sync init error dialog
String headingText = "Error while initializing cloud sync!";
String bodyText = "There was some truble adding your game."
+ "\nPlease upload the app.log (which can be found in the cemu_UI directory)"
+ "\nto \"https://github.com/Seil0/cemu_UI/issues\" so we can fix this.";
JFXInfoDialog cloudSyncErrorDialog = new JFXInfoDialog(headingText, bodyText, dialogBtnStyle, 450, 170, main.pane);
cloudSyncErrorDialog.show();
}
}
});
thread.start();
}
};

View File

@ -54,7 +54,7 @@ public class CloudController {
LOGGER.error("error while initialize connection", e);
return success;
}
success = true;
success = true;
}
if(cloudService.equals("Dropbox")) {
@ -106,7 +106,7 @@ public class CloudController {
@Override
public void run() {
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 ...");
@ -121,7 +121,7 @@ public class CloudController {
}
Platform.runLater(() -> {
mwc.getPlayBtn().setText("play"); // FIXME we get a NullPointerException here, because playBtn dosen't exist
mwc.getPlayBtn().setText("play");
mwc.saveSettings();
});
LOGGER.info("synchronization successful!");

View File

@ -102,11 +102,7 @@ public class GoogleDriveController {
public Credential authorize() throws IOException {
// Load client secrets.
InputStream in = getClass().getClassLoader().getResourceAsStream("client_secret.json");
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.
GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(JSON_FACTORY, new InputStreamReader(in));
GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(HTTP_TRANSPORT, JSON_FACTORY, clientSecrets, SCOPES)
.setDataStoreFactory(DATA_STORE_FACTORY)
.setAccessType("offline")