diff --git a/PlayWall/assets/de/tobias/playpad/assets/lang/_de.properties b/PlayWall/assets/de/tobias/playpad/assets/lang/_de.properties index 9e910af1277a0bc5d385bda80cadb9d85e0598e2..04503329016b89a0ca508c7e1caf597e0509334b 100644 --- a/PlayWall/assets/de/tobias/playpad/assets/lang/_de.properties +++ b/PlayWall/assets/de/tobias/playpad/assets/lang/_de.properties @@ -211,7 +211,6 @@ Error.Layout.Load=Es gab einen Fehler beim Laden des Layouts ({}) # UI - Dialog - Update UI.Dialog.Update.Cell={}: Installiert: {} - Neu: {} UI.Window.Settings.Updates.CurrentVersion={} (Build {}) -UI.Window.Settings.Updates.NewVersion={} (Build {}) # Error - Update - Downlaod Error.Update.Download=Es ist ein Fehler beim Herunterladen des Updates aufgetreten. Bitte versuchen Sie es sp�ter erneut. ({}) diff --git a/PlayWall/assets/de/tobias/playpad/assets/view/option/updateTab.fxml b/PlayWall/assets/de/tobias/playpad/assets/view/option/updateTab.fxml index 19b5d15c0b734339860ec8ccc0d3f24156fe5a39..e08fc46d9b20b2a92e3530069c2a18336ce06312 100644 --- a/PlayWall/assets/de/tobias/playpad/assets/view/option/updateTab.fxml +++ b/PlayWall/assets/de/tobias/playpad/assets/view/option/updateTab.fxml @@ -13,12 +13,6 @@ <Label fx:id="currentVersionLabel" layoutX="175.0" layoutY="14.0" text="5.0.1 (stable)" /> </children> </HBox> - <HBox layoutX="14.0" layoutY="36.0" spacing="14.0"> - <children> - <Label alignment="CENTER_RIGHT" layoutX="14.0" layoutY="36.0" prefWidth="150.0" text="%settings.update.label.new" /> - <Label fx:id="newVersionLabel" layoutX="175.0" layoutY="36.0" text="5.0.2 (stable)" /> - </children> - </HBox> <Separator prefWidth="200.0" /> <HBox spacing="14.0"> <children> diff --git a/PlayWall/src/de/tobias/playpad/PlayPadMain.java b/PlayWall/src/de/tobias/playpad/PlayPadMain.java index 9d54032cee0862f32a815d2d35b7cf7e6c72a5b7..a6232e848d8c1e6cbb825eef9520d4b5aa472196 100644 --- a/PlayWall/src/de/tobias/playpad/PlayPadMain.java +++ b/PlayWall/src/de/tobias/playpad/PlayPadMain.java @@ -5,6 +5,7 @@ import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.net.MalformedURLException; +import java.net.URISyntaxException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -324,25 +325,30 @@ public class PlayPadMain extends Application implements LocalizationDelegate, Pl mainViewController = new MainViewController(project, mainViewListeners, pluginManager); } + /** + * Handle Auto Update on profile reload + */ @Override - public void reloadSettings(Profile oldProfile, Profile currentProfile) { + public void reloadSettings(Profile oldProfile, Profile newProfile) { // Update PlayWall - if (currentProfile.getProfileSettings().isAutoUpdate()) { + if (newProfile.getProfileSettings().isAutoUpdate()) { Worker.runLater(() -> { - UpdateRegistery.lookupUpdates(); - if (!UpdateRegistery.getAvailableUpdates().isEmpty()) { - Platform.runLater(() -> - { - Alert alert = new Alert(AlertType.CONFIRMATION); - alert.setHeaderText(Localization.getString(Strings.UI_Dialog_AutoUpdate_Header)); - alert.setContentText(Localization.getString(Strings.UI_Dialog_AutoUpdate_Content)); - alert.showAndWait().filter(item -> item == ButtonType.OK).ifPresent(result -> + try { + UpdateRegistery.lookupUpdates(newProfile.getProfileSettings().getUpdateChannel()); + if (!UpdateRegistery.getAvailableUpdates().isEmpty()) { + Platform.runLater(() -> { - UpdateTabViewController.update(null); + Alert alert = new Alert(AlertType.CONFIRMATION); + alert.setHeaderText(Localization.getString(Strings.UI_Dialog_AutoUpdate_Header)); + alert.setContentText(Localization.getString(Strings.UI_Dialog_AutoUpdate_Content)); + alert.showAndWait().filter(item -> item == ButtonType.OK).ifPresent(result -> + { + UpdateTabViewController.update(null); + }); }); - }); - } + } + } catch (IOException | URISyntaxException e) {} }); } } diff --git a/PlayWall/src/de/tobias/playpad/PlayPadUpdater.java b/PlayWall/src/de/tobias/playpad/PlayPadUpdater.java index 2752b6847292a3ec0ec84256e2fffa99de1b384d..fa3d66a15807d4d178b1ba4f8a89d09c309ace16 100644 --- a/PlayWall/src/de/tobias/playpad/PlayPadUpdater.java +++ b/PlayWall/src/de/tobias/playpad/PlayPadUpdater.java @@ -9,6 +9,7 @@ import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; import de.tobias.playpad.update.Updatable; +import de.tobias.playpad.update.UpdateChannel; import de.tobias.utils.application.App; import de.tobias.utils.application.ApplicationUtils; import de.tobias.utils.util.SystemUtils; @@ -31,47 +32,36 @@ public class PlayPadUpdater implements Updatable { @Override public int getNewBuild() { - if (newBuild == 0) { - checkUpdate(); - } return newBuild; } @Override public String getNewVersion() { - if (newVersion == null) { - checkUpdate(); - } return newVersion; } @Override - public boolean checkUpdate() { + public void loadInformation(UpdateChannel channel) throws IOException, URISyntaxException { App app = ApplicationUtils.getMainApplication(); - try { - URL url = new URL(app.getInfo().getUpdateURL() + "/version.yml"); - FileConfiguration config = YamlConfiguration.loadConfiguration(url.openStream()); - newBuild = config.getInt("build"); - newVersion = config.getString("version"); - - if (SystemUtils.isExe()) { - remotePath = new URL(config.getString("pathExe")); - } else { - remotePath = new URL(config.getString("pathJar")); - } - - return getCurrentBuild() < getNewBuild(); - } catch (IOException | URISyntaxException e) { - e.printStackTrace(); + URL url = new URL(app.getInfo().getUpdateURL() + "/" + channel + "/version.yml"); + FileConfiguration config = YamlConfiguration.loadConfiguration(url.openStream()); + newBuild = config.getInt("build"); + newVersion = config.getString("version"); + + if (SystemUtils.isExe() && channel == UpdateChannel.STABLE) { // EXE only for stable release + remotePath = new URL(config.getString("pathExe")); + } else { + remotePath = new URL(config.getString("pathJar")); } - return false; + } + + @Override + public boolean isUpdateAvailable() { + return getCurrentBuild() < getNewBuild(); } @Override public URL getDownloadPath() { - if (remotePath == null) { - checkUpdate(); - } return remotePath; } diff --git a/PlayWall/src/de/tobias/playpad/Strings.java b/PlayWall/src/de/tobias/playpad/Strings.java index 12c51ae815631e375741f16f0198952f759efefc..541ce90562766394013c93d71e52c38b888e7bb5 100644 --- a/PlayWall/src/de/tobias/playpad/Strings.java +++ b/PlayWall/src/de/tobias/playpad/Strings.java @@ -204,7 +204,6 @@ public class Strings { // UI - Dialog - Update public static final String UI_Dialog_Update_Cell = "UI.Dialog.Update.Cell"; public static final String UI_Window_Settings_Updates_CurrentVersion = "UI.Window.Settings.Updates.CurrentVersion"; - public static final String UI_Window_Settings_Updates_NewVersion = "UI.Window.Settings.Updates.NewVersion"; // Error - Update - Downlaod public static final String Error_Update_Download = "Error.Update.Download"; diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/UpdateTabViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/UpdateTabViewController.java index 6861119a6fce149b137ba2dd33c66673ec4ffb6c..86c522c2df63bde8cb56ddffccf969d1ea23055b 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/UpdateTabViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/UpdateTabViewController.java @@ -4,6 +4,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.MalformedURLException; +import java.net.URISyntaxException; import java.net.URL; import java.net.URLConnection; import java.nio.file.Files; @@ -16,12 +17,14 @@ import de.tobias.playpad.PlayPadMain; import de.tobias.playpad.PlayPadPlugin; import de.tobias.playpad.Strings; import de.tobias.playpad.settings.Profile; +import de.tobias.playpad.settings.ProfileSettings; import de.tobias.playpad.update.Updatable; import de.tobias.playpad.update.UpdateChannel; import de.tobias.playpad.update.UpdateRegistery; import de.tobias.playpad.viewcontroller.SettingsTabViewController; import de.tobias.playpad.viewcontroller.cell.UpdateCell; import de.tobias.playpad.viewcontroller.dialog.UpdaterDialog; +import de.tobias.utils.application.ApplicationInfo; import de.tobias.utils.application.ApplicationUtils; import de.tobias.utils.application.NativeLauncher; import de.tobias.utils.application.container.PathType; @@ -52,7 +55,6 @@ public class UpdateTabViewController extends SettingsTabViewController { private static final String UPDATER_EXE = "Updater.exe"; @FXML private Label currentVersionLabel; - @FXML private Label newVersionLabel; @FXML private CheckBox automaticSearchCheckBox; @FXML private Button manualSearchButton; @@ -69,21 +71,15 @@ public class UpdateTabViewController extends SettingsTabViewController { public UpdateTabViewController() { super("updateTab", "de/tobias/playpad/assets/view/option/", PlayPadMain.getUiResourceBundle()); + ProfileSettings profileSettings = Profile.currentProfile().getProfileSettings(); + updateChannelComboBox.setValue(profileSettings.getUpdateChannel()); openUpdateList.getItems().setAll(UpdateRegistery.getAvailableUpdates()); updateButton.setDisable(openUpdateList.getItems().isEmpty()); - Worker.runLater(() -> - { - Updatable updater = PlayPadMain.getUpdater(); - updater.checkUpdate(); - Platform.runLater(() -> - { - currentVersionLabel.setText(Localization.getString(Strings.UI_Window_Settings_Updates_CurrentVersion, - updater.getCurrentVersion(), updater.getCurrentBuild())); - newVersionLabel.setText(Localization.getString(Strings.UI_Window_Settings_Updates_CurrentVersion, updater.getNewVersion(), - updater.getNewBuild())); - }); - }); + ApplicationInfo info = ApplicationUtils.getApplication().getInfo(); + String currentVersionString = Localization.getString(Strings.UI_Window_Settings_Updates_CurrentVersion, info.getVersion(), + info.getBuild()); + currentVersionLabel.setText(currentVersionString); } @Override @@ -91,6 +87,11 @@ public class UpdateTabViewController extends SettingsTabViewController { openUpdateList.setCellFactory(list -> new UpdateCell()); updateChannelComboBox.getItems().setAll(UpdateChannel.values()); + updateChannelComboBox.valueProperty().addListener((a, b, c) -> + { + Profile.currentProfile().getProfileSettings().setUpdateChannel(c); + }); + progressIndecator = new ProgressIndicator(-1); progressIndecator.setMinSize(25, 25); @@ -104,12 +105,29 @@ public class UpdateTabViewController extends SettingsTabViewController { private void manualSearchHandler(ActionEvent event) { openUpdateList.getItems().clear(); - openUpdateList.setPlaceholder(progressIndecator); - UpdateRegistery.lookupUpdates(); - openUpdateList.setPlaceholder(placeholderLabel); + Profile profile = Profile.currentProfile(); + if (profile != null) { + openUpdateList.setPlaceholder(progressIndecator); - openUpdateList.getItems().setAll(UpdateRegistery.getAvailableUpdates()); - updateButton.setDisable(openUpdateList.getItems().isEmpty()); + Worker.runLater(() -> + { + // Search for updates + try { + UpdateRegistery.lookupUpdates(profile.getProfileSettings().getUpdateChannel()); + } catch (IOException | URISyntaxException e) { + e.printStackTrace(); + showErrorMessage(Localization.getString(Strings.Error_Update_Download, e.getLocalizedMessage())); + } + + Platform.runLater(() -> + { + openUpdateList.setPlaceholder(placeholderLabel); + openUpdateList.getItems().setAll(UpdateRegistery.getAvailableUpdates()); + updateButton.setDisable(openUpdateList.getItems().isEmpty()); + }); + }); + + } } @FXML @@ -121,74 +139,89 @@ public class UpdateTabViewController extends SettingsTabViewController { String parameter = UpdateRegistery .buildParamaterString(ApplicationUtils.getApplication().getPath(PathType.DOWNLOAD, DOWNLOAD_FOLDER).toString()); if (OS.getType() == OSType.Windows) { - try { - Path fileJar = Paths.get(UPDATER_JAR); - Path fileExe = Paths.get(UPDATER_EXE); - Path fileJarFolder = ApplicationUtils.getApplication().getPath(PathType.DOWNLOAD, UPDATER_JAR); - Path fileExeFolder = ApplicationUtils.getApplication().getPath(PathType.DOWNLOAD, UPDATER_EXE); - - if (Files.exists(fileJar)) { - startJarFile(parameter, fileJar); - } else if (Files.exists(fileExe)) { - startExeFile(parameter, fileExe); - - } else if (Files.exists(fileJarFolder)) { - startJarFile(parameter, fileJarFolder); - } else if (Files.exists(fileExeFolder)) { - startExeFile(parameter, fileExeFolder); - } else { - UpdaterDialog dialog = new UpdaterDialog(dialogOwner); - dialog.show(); - - Worker.runLater(() -> - { - String updaterURL = ApplicationUtils.getApplication().getInfo().getUserInfo().get(AppUserInfoStrings.UPDATER_PROGRAM) - + UPDATER_EXE; - Path path = ApplicationUtils.getApplication().getPath(PathType.DOWNLOAD, UPDATER_EXE); - try { - downloadUpdater(updaterURL, path); - startExeFile(parameter, path); - } catch (Exception e) { - e.printStackTrace(); - String errorMessage = Localization.getString(Strings.Error_Update_Download, e.getMessage()); - showErrorMessage(errorMessage, PlayPadPlugin.getImplementation().getIcon(), dialogOwner); - } - }); - } - } catch (Exception ex) { - ex.printStackTrace(); - } + windowsUpdate(dialogOwner, parameter); } else { - try { - Path fileJar = Paths.get(UPDATER_JAR); - Path fileJarFolder = ApplicationUtils.getApplication().getPath(PathType.DOWNLOAD, UPDATER_JAR); - - if (Files.exists(fileJar)) { - startJarFile(parameter, fileJar); - } else if (Files.exists(fileJarFolder)) { - startJarFile(parameter, fileJarFolder); - } else { - UpdaterDialog dialog = new UpdaterDialog(dialogOwner); - dialog.show(); - - Worker.runLater(() -> - { - String updaterURL = ApplicationUtils.getApplication().getInfo().getUserInfo().get(AppUserInfoStrings.UPDATER_PROGRAM) - + UPDATER_JAR; - Path path = ApplicationUtils.getApplication().getPath(PathType.DOWNLOAD, UPDATER_JAR); - try { - downloadUpdater(updaterURL, path); - startJarFile(parameter, path); - } catch (Exception e) { - e.printStackTrace(); - String errorMessage = Localization.getString(Strings.Error_Update_Download, e.getMessage()); - showErrorMessage(errorMessage, PlayPadPlugin.getImplementation().getIcon(), dialogOwner); - } - }); - } - } catch (Exception ex) { - ex.printStackTrace(); + macUpdate(dialogOwner, parameter); + } + } + + /** + * Perform Mac Update and if needed download the jar updater. + * + * @param dialogOwner + * Owner window + * @param parameter + */ + private static void macUpdate(Window dialogOwner, String parameter) { + try { + Path fileJar = Paths.get(UPDATER_JAR); + Path fileJarFolder = ApplicationUtils.getApplication().getPath(PathType.DOWNLOAD, UPDATER_JAR); + + if (Files.exists(fileJar)) { + startJarFile(parameter, fileJar); + } else if (Files.exists(fileJarFolder)) { + startJarFile(parameter, fileJarFolder); + } else { + UpdaterDialog dialog = new UpdaterDialog(dialogOwner); + dialog.show(); + + Worker.runLater(() -> + { + String updaterURL = ApplicationUtils.getApplication().getInfo().getUserInfo().get(AppUserInfoStrings.UPDATER_PROGRAM) + + UPDATER_JAR; + Path path = ApplicationUtils.getApplication().getPath(PathType.DOWNLOAD, UPDATER_JAR); + try { + downloadUpdater(updaterURL, path); + startJarFile(parameter, path); + } catch (Exception e) { + e.printStackTrace(); + String errorMessage = Localization.getString(Strings.Error_Update_Download, e.getMessage()); + showErrorMessage(errorMessage, PlayPadPlugin.getImplementation().getIcon(), dialogOwner); + } + }); + } + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + private static void windowsUpdate(Window dialogOwner, String parameter) { + try { + Path fileJar = Paths.get(UPDATER_JAR); + Path fileExe = Paths.get(UPDATER_EXE); + Path fileJarFolder = ApplicationUtils.getApplication().getPath(PathType.DOWNLOAD, UPDATER_JAR); + Path fileExeFolder = ApplicationUtils.getApplication().getPath(PathType.DOWNLOAD, UPDATER_EXE); + + if (Files.exists(fileJar)) { + startJarFile(parameter, fileJar); + } else if (Files.exists(fileExe)) { + startExeFile(parameter, fileExe); + + } else if (Files.exists(fileJarFolder)) { + startJarFile(parameter, fileJarFolder); + } else if (Files.exists(fileExeFolder)) { + startExeFile(parameter, fileExeFolder); + } else { + UpdaterDialog dialog = new UpdaterDialog(dialogOwner); + dialog.show(); + + Worker.runLater(() -> + { + ApplicationInfo info = ApplicationUtils.getApplication().getInfo(); + String updaterURL = info.getUserInfo().get(AppUserInfoStrings.UPDATER_PROGRAM) + UPDATER_EXE; + Path path = ApplicationUtils.getApplication().getPath(PathType.DOWNLOAD, UPDATER_EXE); + try { + downloadUpdater(updaterURL, path); + startExeFile(parameter, path); + } catch (Exception e) { + e.printStackTrace(); + String errorMessage = Localization.getString(Strings.Error_Update_Download, e.getMessage()); + showErrorMessage(errorMessage, PlayPadPlugin.getImplementation().getIcon(), dialogOwner); + } + }); } + } catch (Exception ex) { + ex.printStackTrace(); } } diff --git a/PlayWallCore/src/de/tobias/playpad/settings/Profile.java b/PlayWallCore/src/de/tobias/playpad/settings/Profile.java index db0b7ea64dccd1216bba78ddf58a5c80854589f1..7e55988c26d8adbfa59e1b5494c3766d760595dd 100644 --- a/PlayWallCore/src/de/tobias/playpad/settings/Profile.java +++ b/PlayWallCore/src/de/tobias/playpad/settings/Profile.java @@ -20,6 +20,10 @@ import de.tobias.utils.application.container.PathType; public class Profile { + private static final String PROFILE_SETTINGS_XML = "ProfileSettings.xml"; + private static final String MAPPING_XML = "Mapping.xml"; + private static final String LAYOUT_XML = "Layout.xml"; + public static final String profileNameEx = "\\w{1}[\\w\\s-_]{0,}"; private static List<ProfileListener> listeners = new ArrayList<>(); @@ -97,10 +101,9 @@ public class Profile { if (Files.exists(app.getPath(PathType.CONFIGURATION, ref.getFileName()))) { - ProfileSettings profileSettings = ProfileSettings - .load(app.getPath(PathType.CONFIGURATION, ref.getFileName(), "ProfileSettings.xml")); + ProfileSettings profileSettings = ProfileSettings.load(app.getPath(PathType.CONFIGURATION, ref.getFileName(), PROFILE_SETTINGS_XML)); HashMap<String, GlobalLayout> layouts = GlobalLayout - .loadGlobalLayout(app.getPath(PathType.CONFIGURATION, ref.getFileName(), "Layout.xml")); + .loadGlobalLayout(app.getPath(PathType.CONFIGURATION, ref.getFileName(), LAYOUT_XML)); profile.profileSettings = profileSettings; profile.layouts = layouts; @@ -116,7 +119,7 @@ public class Profile { }); // Mapping erst danach, weil das auf current Profile zugreifen muss - MappingList mappings = MappingList.load(app.getPath(PathType.CONFIGURATION, ref.getFileName(), "Mapping.xml"), profile); + MappingList mappings = MappingList.load(app.getPath(PathType.CONFIGURATION, ref.getFileName(), MAPPING_XML), profile); profile.mappings = mappings; setCurrentProfile(profile); @@ -141,9 +144,14 @@ public class Profile { if (Files.notExists(root)) Files.createDirectories(root); - profileSettings.save(app.getPath(PathType.CONFIGURATION, ref.getFileName(), "ProfileSettings.xml")); - mappings.save(app.getPath(PathType.CONFIGURATION, ref.getFileName(), "Mapping.xml")); - GlobalLayout.saveGlobal(layouts, app.getPath(PathType.CONFIGURATION, ref.getFileName(), "Layout.xml")); + profileSettings.save(getProfilePath(PROFILE_SETTINGS_XML)); + mappings.save(getProfilePath(MAPPING_XML)); + GlobalLayout.saveGlobal(layouts, getProfilePath(LAYOUT_XML)); + } + + private Path getProfilePath(String fileName) { + App app = ApplicationUtils.getApplication(); + return app.getPath(PathType.CONFIGURATION, ref.getFileName(), fileName); } @Override diff --git a/PlayWallCore/src/de/tobias/playpad/settings/ProfileSettings.java b/PlayWallCore/src/de/tobias/playpad/settings/ProfileSettings.java index 3cf852a167e03b5c83f619f2c63583c4fe51e0eb..78bc49db58cb5e8c6e833852a22ba3eed12fb7b2 100644 --- a/PlayWallCore/src/de/tobias/playpad/settings/ProfileSettings.java +++ b/PlayWallCore/src/de/tobias/playpad/settings/ProfileSettings.java @@ -20,6 +20,7 @@ import de.tobias.playpad.layout.LayoutRegistry; import de.tobias.playpad.pad.Fade; import de.tobias.playpad.pad.TimeMode; import de.tobias.playpad.pad.Warning; +import de.tobias.playpad.update.UpdateChannel; import de.tobias.utils.application.ApplicationUtils; import de.tobias.utils.application.container.PathType; import de.tobias.utils.settings.SettingsSerializable; @@ -73,8 +74,9 @@ public class ProfileSettings implements SettingsSerializable { // Folder @Storable private Path cachePath = ApplicationUtils.getApplication().getPath(PathType.CACHE); - // Update + // Update - TODO GlobalSettings @Storable private boolean autoUpdate = true; + @Storable private UpdateChannel updateChannel = UpdateChannel.STABLE; public boolean isLocked() { return lockedProperty.get(); @@ -179,6 +181,10 @@ public class ProfileSettings implements SettingsSerializable { return autoUpdate; } + public UpdateChannel getUpdateChannel() { + return updateChannel; + } + // Setter public void setMidiDeviceName(String midiDevice) { this.midiDevice = midiDevice; @@ -258,6 +264,10 @@ public class ProfileSettings implements SettingsSerializable { this.autoUpdate = autoUpdate; } + public void setUpdateChannel(UpdateChannel updateChannel) { + this.updateChannel = updateChannel; + } + // Properties public DoubleProperty volumeProperty() { return volumeProperty; @@ -266,6 +276,7 @@ public class ProfileSettings implements SettingsSerializable { private static final String LOCKED_ELEMENT = "Locked"; private static final String ITEM_ELEMENT = "Item"; private static final String AUTO_UPDATE_ELEMENT = "AutoUpdate"; + private static final String UPDATE_CHANNEL_ELEMENT = "UpdateChannel"; private static final String CACHE_PATH_ELEMENT = "Cache-Path"; private static final String VOLUME_ELEMENT = "Volume"; private static final String KEY_ATTRIBUTE = "key"; @@ -378,6 +389,10 @@ public class ProfileSettings implements SettingsSerializable { if (root.element(AUTO_UPDATE_ELEMENT) != null) { profileSettings.setAutoUpdate(Boolean.valueOf(root.element(AUTO_UPDATE_ELEMENT).getStringValue())); } + + if (root.element(UPDATE_CHANNEL_ELEMENT) != null) { + profileSettings.setUpdateChannel(UpdateChannel.valueOf(root.element(UPDATE_CHANNEL_ELEMENT).getStringValue())); + } } return profileSettings; } @@ -410,7 +425,7 @@ public class ProfileSettings implements SettingsSerializable { liveElement.addAttribute(LIVE_MODE_DRAG_ATTR, String.valueOf(liveModeDrag)); liveElement.addAttribute(LIVE_MODE_FILE_ATTR, String.valueOf(liveModeFile)); liveElement.addAttribute(LIVE_MODE_SETTINGS_ATTR, String.valueOf(liveModeSettings)); - + root.addElement(WINDOW_ALWAYS_ON_TOP_ELEMENT).addText(String.valueOf(windowAlwaysOnTop)); // Audio @@ -424,7 +439,10 @@ public class ProfileSettings implements SettingsSerializable { // Paths root.addElement(CACHE_PATH_ELEMENT).addText(cachePath.toString()); + + // Update root.addElement(AUTO_UPDATE_ELEMENT).addText(String.valueOf(autoUpdate)); + root.addElement(UPDATE_CHANNEL_ELEMENT).addText(updateChannel.name()); XMLWriter writer = new XMLWriter(Files.newOutputStream(path), OutputFormat.createPrettyPrint()); writer.write(document); diff --git a/PlayWallCore/src/de/tobias/playpad/update/Updatable.java b/PlayWallCore/src/de/tobias/playpad/update/Updatable.java index 82b9c8c8096f3d0f7fd0811f6654ce0c9d143d33..88c493aec8cd4b9741f2e46dadfb71df421aec90 100644 --- a/PlayWallCore/src/de/tobias/playpad/update/Updatable.java +++ b/PlayWallCore/src/de/tobias/playpad/update/Updatable.java @@ -1,5 +1,7 @@ package de.tobias.playpad.update; +import java.io.IOException; +import java.net.URISyntaxException; import java.net.URL; import java.nio.file.Path; @@ -13,7 +15,9 @@ public interface Updatable { public String getNewVersion(); - public boolean checkUpdate(); + public boolean isUpdateAvailable(); + + public void loadInformation(UpdateChannel channel) throws IOException, URISyntaxException; public URL getDownloadPath(); diff --git a/PlayWallCore/src/de/tobias/playpad/update/UpdateChannel.java b/PlayWallCore/src/de/tobias/playpad/update/UpdateChannel.java index 60ea93d2bc6a8643fbabe0b027eb6e8003dc4fcd..ca0367b83d6e1209be9076f625caafde2e759364 100644 --- a/PlayWallCore/src/de/tobias/playpad/update/UpdateChannel.java +++ b/PlayWallCore/src/de/tobias/playpad/update/UpdateChannel.java @@ -2,6 +2,17 @@ package de.tobias.playpad.update; public enum UpdateChannel { - STABLE, - BETA; + STABLE("stable"), + BETA("beta"); + + private String name; + + private UpdateChannel(String name) { + this.name = name; + } + + @Override + public String toString() { + return name; + } } diff --git a/PlayWallCore/src/de/tobias/playpad/update/UpdateRegistery.java b/PlayWallCore/src/de/tobias/playpad/update/UpdateRegistery.java index c3b8b974a0fcdd7479af589b07f1e948f540c35a..d49d153063469af73821d44a0b2232cd626e629b 100644 --- a/PlayWallCore/src/de/tobias/playpad/update/UpdateRegistery.java +++ b/PlayWallCore/src/de/tobias/playpad/update/UpdateRegistery.java @@ -1,5 +1,6 @@ package de.tobias.playpad.update; +import java.io.IOException; import java.net.URISyntaxException; import java.util.ArrayList; import java.util.List; @@ -22,10 +23,11 @@ public class UpdateRegistery { return availableUpdates; } - public static List<Updatable> lookupUpdates() { + public static List<Updatable> lookupUpdates(UpdateChannel channel) throws IOException, URISyntaxException { availableUpdates.clear(); for (Updatable updatable : UpdateRegistery.updatables) { - if (updatable.checkUpdate()) { + updatable.loadInformation(channel); + if (updatable.isUpdateAvailable()) { availableUpdates.add(updatable); } } @@ -38,6 +40,8 @@ public class UpdateRegistery { private static final String URL = "url"; private static final String EXECUTE_FILE = "executePath"; + + public static String buildParamaterString(String downloadPath) { JSONObject data = new JSONObject(); data.put(DOWNLOAD_PATH, downloadPath);