added support for updating to different branches
* added support for updating to different branches * smmdb api fixed bad response from http url, using https now * code clean-up
This commit is contained in:
parent
40c6084412
commit
61e02f6ac1
|
@ -7,6 +7,7 @@
|
|||
<?import com.jfoenix.controls.JFXToggleButton?>
|
||||
<?import com.jfoenix.controls.JFXTreeTableView?>
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.ChoiceBox?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.ScrollPane?>
|
||||
<?import javafx.scene.image.ImageView?>
|
||||
|
@ -88,6 +89,8 @@
|
|||
<Label fx:id="updateLbl" layoutX="10.0" layoutY="315.0" text="Updates" AnchorPane.leftAnchor="10.0" AnchorPane.topAnchor="315.0" />
|
||||
<JFXButton fx:id="updateBtn" layoutX="14.0" layoutY="335.0" onAction="#updateBtnAction" prefHeight="32.0" text="check now!" AnchorPane.leftAnchor="14.0" AnchorPane.topAnchor="335.0" />
|
||||
<JFXToggleButton fx:id="autoUpdateToggleBtn" layoutX="10.0" layoutY="372.0" onAction="#autoUpdateToggleBtnAction" text="check for updates on startup" AnchorPane.leftAnchor="10.0" AnchorPane.topAnchor="372.0" />
|
||||
<ChoiceBox fx:id="branchChoisBox" layoutX="270.0" layoutY="339.0" prefWidth="150.0" AnchorPane.leftAnchor="270.0" AnchorPane.topAnchor="339.0" />
|
||||
<Label fx:id="branchLbl" layoutX="204.0" layoutY="337.0" prefHeight="32.0" text="Branch" AnchorPane.leftAnchor="204.0" AnchorPane.topAnchor="335.0" />
|
||||
</children>
|
||||
</AnchorPane>
|
||||
</content>
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -7,6 +7,7 @@
|
|||
<?import com.jfoenix.controls.JFXToggleButton?>
|
||||
<?import com.jfoenix.controls.JFXTreeTableView?>
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.ChoiceBox?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.ScrollPane?>
|
||||
<?import javafx.scene.image.ImageView?>
|
||||
|
@ -88,6 +89,8 @@
|
|||
<Label fx:id="updateLbl" layoutX="10.0" layoutY="315.0" text="Updates" AnchorPane.leftAnchor="10.0" AnchorPane.topAnchor="315.0" />
|
||||
<JFXButton fx:id="updateBtn" layoutX="14.0" layoutY="335.0" onAction="#updateBtnAction" prefHeight="32.0" text="check now!" AnchorPane.leftAnchor="14.0" AnchorPane.topAnchor="335.0" />
|
||||
<JFXToggleButton fx:id="autoUpdateToggleBtn" layoutX="10.0" layoutY="372.0" onAction="#autoUpdateToggleBtnAction" text="check for updates on startup" AnchorPane.leftAnchor="10.0" AnchorPane.topAnchor="372.0" />
|
||||
<ChoiceBox fx:id="branchChoisBox" layoutX="270.0" layoutY="339.0" prefWidth="150.0" AnchorPane.leftAnchor="270.0" AnchorPane.topAnchor="339.0" />
|
||||
<Label fx:id="branchLbl" layoutX="204.0" layoutY="337.0" prefHeight="32.0" text="Branch" AnchorPane.leftAnchor="204.0" AnchorPane.topAnchor="335.0" />
|
||||
</children>
|
||||
</AnchorPane>
|
||||
</content>
|
||||
|
|
|
@ -81,6 +81,7 @@ import javafx.scene.control.Alert.AlertType;
|
|||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ButtonBar.ButtonData;
|
||||
import javafx.scene.control.ButtonType;
|
||||
import javafx.scene.control.ChoiceBox;
|
||||
import javafx.scene.control.ContextMenu;
|
||||
import javafx.scene.control.Dialog;
|
||||
import javafx.scene.control.Label;
|
||||
|
@ -170,6 +171,9 @@ public class MainWindowController {
|
|||
|
||||
@FXML
|
||||
private JFXToggleButton fullscreenToggleBtn;
|
||||
|
||||
@FXML
|
||||
private ChoiceBox<String> branchChoisBox;
|
||||
|
||||
@FXML
|
||||
private AnchorPane mainAnchorPane;
|
||||
|
@ -219,6 +223,9 @@ public class MainWindowController {
|
|||
@FXML
|
||||
private Label updateLbl;
|
||||
|
||||
@FXML
|
||||
private Label branchLbl;
|
||||
|
||||
@FXML
|
||||
private Label cemuSettingsLbl;
|
||||
|
||||
|
@ -251,6 +258,7 @@ public class MainWindowController {
|
|||
private boolean playTrue = false;
|
||||
private boolean smmdbTrue = false;
|
||||
private boolean autoUpdate = false;
|
||||
private boolean useBeta = false;
|
||||
private boolean fullscreen;
|
||||
private boolean cloudSync;
|
||||
private String cloudService = ""; //set cloud provider (at the moment only GoogleDrive, Dropbox is planed)
|
||||
|
@ -280,6 +288,7 @@ public class MainWindowController {
|
|||
private File configFileLinux = new File(dirLinux + "/config.xml");
|
||||
File pictureCacheWin = new File(dirWin+"/picture_cache");
|
||||
File pictureCacheLinux = new File(dirLinux+"/picture_cache");
|
||||
private ObservableList<String> branches = FXCollections.observableArrayList("stable", "beta");
|
||||
private ObservableList<String> smmIDs = FXCollections.observableArrayList("fe31b7f2", "44fc5929"); //TODO add more IDs
|
||||
private ObservableList<UIROMDataType> games = FXCollections.observableArrayList();
|
||||
ObservableList<SmmdbApiDataType> courses = FXCollections.observableArrayList();
|
||||
|
@ -328,8 +337,14 @@ public class MainWindowController {
|
|||
fullscreenToggleBtn.setSelected(isFullscreen());
|
||||
cloudSyncToggleBtn.setSelected(isCloudSync());
|
||||
autoUpdateToggleBtn.setSelected(isAutoUpdate());
|
||||
updateBtn.setDisable(false); // TODO
|
||||
autoUpdateToggleBtn.setDisable(false); // TODO
|
||||
branchChoisBox.setItems(branches);
|
||||
|
||||
if (isUseBeta()) {
|
||||
branchChoisBox.getSelectionModel().select(1);
|
||||
} else {
|
||||
branchChoisBox.getSelectionModel().select(0);
|
||||
}
|
||||
|
||||
applyColor();
|
||||
|
||||
//initialize courseTable
|
||||
|
@ -695,6 +710,18 @@ public class MainWindowController {
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
branchChoisBox.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() {
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends Number> ov, Number value, Number new_value) {
|
||||
if (branchChoisBox.getItems().get((int) new_value).toString() == "beta") {
|
||||
setUseBeta(true);
|
||||
} else {
|
||||
setUseBeta(false);
|
||||
}
|
||||
saveSettings();
|
||||
}
|
||||
});
|
||||
|
||||
LOGGER.info("initializing Actions done!");
|
||||
}
|
||||
|
@ -834,7 +861,7 @@ public class MainWindowController {
|
|||
|
||||
@FXML
|
||||
void updateBtnAction(ActionEvent event) {
|
||||
updateController = new UpdateController(this, buildNumber);
|
||||
updateController = new UpdateController(this, buildNumber, useBeta);
|
||||
Thread updateThread = new Thread(updateController);
|
||||
updateThread.setName("Updater");
|
||||
updateThread.start();
|
||||
|
@ -1310,7 +1337,7 @@ public class MainWindowController {
|
|||
if(isAutoUpdate()){
|
||||
try {
|
||||
LOGGER.info("AutoUpdate: looking for updates on startup ...");
|
||||
updateController = new UpdateController(this, buildNumber);
|
||||
updateController = new UpdateController(this, buildNumber, useBeta);
|
||||
Thread updateThread = new Thread(updateController);
|
||||
updateThread.setName("Updater");
|
||||
updateThread.start();
|
||||
|
@ -1547,6 +1574,7 @@ public class MainWindowController {
|
|||
props.setProperty("fullscreen", String.valueOf(isFullscreen()));
|
||||
props.setProperty("cloudSync", String.valueOf(isCloudSync()));
|
||||
props.setProperty("autoUpdate", String.valueOf(isAutoUpdate()));
|
||||
props.setProperty("useBeta", String.valueOf(isUseBeta()));
|
||||
if (getCloudService() == null) {
|
||||
props.setProperty("cloudService", "");
|
||||
} else {
|
||||
|
@ -1624,7 +1652,13 @@ public class MainWindowController {
|
|||
LOGGER.error("cloud not load autoUpdate", e);
|
||||
setAutoUpdate(false);
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
setUseBeta(Boolean.parseBoolean(props.getProperty("useBeta")));
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("cloud not load autoUpdate", e);
|
||||
setUseBeta(false);
|
||||
}
|
||||
|
||||
try {
|
||||
setCloudService(props.getProperty("cloudService"));
|
||||
|
@ -1844,6 +1878,14 @@ public class MainWindowController {
|
|||
this.autoUpdate = autoUpdate;
|
||||
}
|
||||
|
||||
public boolean isUseBeta() {
|
||||
return useBeta;
|
||||
}
|
||||
|
||||
public void setUseBeta(boolean useBeta) {
|
||||
this.useBeta = useBeta;
|
||||
}
|
||||
|
||||
public String getGameExecutePath() {
|
||||
return gameExecutePath;
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ import datatypes.SmmdbApiDataType;
|
|||
|
||||
public class SmmdbApiQuery {
|
||||
|
||||
private String URL = "http://smmdb.ddns.net/api/getcourses?format=json";
|
||||
private String URL = "https://smmdb.ddns.net/api/getcourses?format=json";
|
||||
private static final Logger LOGGER = LogManager.getLogger(SmmdbApiQuery.class.getName());
|
||||
|
||||
public SmmdbApiQuery() {
|
||||
|
|
|
@ -48,16 +48,20 @@ public class UpdateController implements Runnable{
|
|||
private String apiOutput;
|
||||
private String updateBuildNumber; //tag_name from Github
|
||||
private String browserDownloadUrl; //update download link
|
||||
private String githubApi = "https://api.github.com/repos/Seil0/cemu_UI/releases/latest";
|
||||
private String githubApiRelease = "https://api.github.com/repos/Seil0/cemu_UI/releases/latest";
|
||||
private String githubApiBeta = "https://api.github.com/repos/Seil0/cemu_UI/releases";
|
||||
private URL githubApiUrl;
|
||||
private boolean useBeta;
|
||||
private static final Logger LOGGER = LogManager.getLogger(UpdateController.class.getName());
|
||||
|
||||
/**
|
||||
* updater for cemu_UI based on Project HomeFlix
|
||||
* checks for Updates and download it in case there is one
|
||||
*/
|
||||
public UpdateController(MainWindowController mwc, String buildNumber){
|
||||
mainWindowController=mwc;
|
||||
this.buildNumber=buildNumber;
|
||||
public UpdateController(MainWindowController mwc, String buildNumber, boolean useBeta){
|
||||
mainWindowController = mwc;
|
||||
this.buildNumber = buildNumber;
|
||||
this.useBeta = useBeta;
|
||||
}
|
||||
|
||||
public void run(){
|
||||
|
@ -67,7 +71,14 @@ public class UpdateController implements Runnable{
|
|||
});
|
||||
|
||||
try {
|
||||
URL githubApiUrl = new URL(githubApi);
|
||||
|
||||
if (useBeta) {
|
||||
githubApiUrl = new URL(githubApiBeta);
|
||||
} else {
|
||||
githubApiUrl = new URL(githubApiRelease);
|
||||
}
|
||||
|
||||
// URL githubApiUrl = new URL(githubApiRelease);
|
||||
BufferedReader ina = new BufferedReader(new InputStreamReader(githubApiUrl.openStream()));
|
||||
apiOutput = ina.readLine();
|
||||
ina.close();
|
||||
|
@ -77,16 +88,32 @@ public class UpdateController implements Runnable{
|
|||
});
|
||||
}
|
||||
|
||||
JsonObject object = Json.parse(apiOutput).asObject();
|
||||
JsonArray objectAssets = Json.parse(apiOutput).asObject().get("assets").asArray();
|
||||
|
||||
updateBuildNumber = object.getString("tag_name", "");
|
||||
// updateName = object.getString("name", "");
|
||||
// updateChanges = object.getString("body", "");
|
||||
for (JsonValue asset : objectAssets) {
|
||||
browserDownloadUrl = asset.asObject().getString("browser_download_url", "");
|
||||
|
||||
}
|
||||
if (useBeta) {
|
||||
JsonArray objectArray = Json.parse("{\"items\": " + apiOutput + "}").asObject().get("items").asArray();
|
||||
JsonValue object = objectArray.get(0);
|
||||
JsonArray objectAssets = object.asObject().get("assets").asArray();
|
||||
|
||||
updateBuildNumber = object.asObject().getString("tag_name", "");
|
||||
// updateName = object.asObject().getString("name", "");
|
||||
// updateChanges = object.asObject().getString("body", "");
|
||||
|
||||
for (JsonValue asset : objectAssets) {
|
||||
browserDownloadUrl = asset.asObject().getString("browser_download_url", "");
|
||||
}
|
||||
|
||||
} else {
|
||||
JsonObject object = Json.parse(apiOutput).asObject();
|
||||
JsonArray objectAssets = Json.parse(apiOutput).asObject().get("assets").asArray();
|
||||
|
||||
updateBuildNumber = object.getString("tag_name", "");
|
||||
// updateName = object.getString("name", "");
|
||||
// updateChanges = object.getString("body", "");
|
||||
for (JsonValue asset : objectAssets) {
|
||||
browserDownloadUrl = asset.asObject().getString("browser_download_url", "");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
LOGGER.info("Build: "+buildNumber+", Update: "+updateBuildNumber);
|
||||
|
||||
//Compares the program BuildNumber with the current BuildNumber if program BuildNumber < current BuildNumber then perform a update
|
||||
|
|
Loading…
Reference in New Issue