From a147c1b26c6e457822ecbd31859f578d8797cca0 Mon Sep 17 00:00:00 2001 From: 0xboobface <0xboobface@gmail.com> Date: Fri, 7 Sep 2018 14:31:18 +0200 Subject: [PATCH] Add check for JavaFX on start On startup check if the application is running on the OpenJDK JVM. If that is the case, check that JavaFX is available (because OpenJDK comes without JavaFX, it has to be installed separately). If it is not available, log an error what to do and exit. --- src/main/java/ctbrec/HttpClient.java | 8 +- src/main/java/ctbrec/ModelParser.java | 2 +- .../java/ctbrec/ui/CtbrecApplication.java | 268 +++++++++++++++++ .../java/ctbrec/ui/DesktopIntergation.java | 62 ++++ src/main/java/ctbrec/ui/DonateTabFx.java | 2 +- src/main/java/ctbrec/ui/Launcher.java | 269 +----------------- .../java/ctbrec/ui/RecordedModelsTab.java | 2 +- src/main/java/ctbrec/ui/ThumbCell.java | 4 +- src/main/java/ctbrec/ui/UpdateTab.java | 4 +- 9 files changed, 353 insertions(+), 268 deletions(-) create mode 100644 src/main/java/ctbrec/ui/CtbrecApplication.java create mode 100644 src/main/java/ctbrec/ui/DesktopIntergation.java diff --git a/src/main/java/ctbrec/HttpClient.java b/src/main/java/ctbrec/HttpClient.java index ec805bfb..e5e8d4ad 100644 --- a/src/main/java/ctbrec/HttpClient.java +++ b/src/main/java/ctbrec/HttpClient.java @@ -9,8 +9,8 @@ import org.slf4j.LoggerFactory; import ctbrec.Settings.ProxyType; import ctbrec.ui.CookieJarImpl; +import ctbrec.ui.CtbrecApplication; import ctbrec.ui.HtmlParser; -import ctbrec.ui.Launcher; import okhttp3.ConnectionPool; import okhttp3.Cookie; import okhttp3.FormBody; @@ -121,7 +121,7 @@ public class HttpClient { public boolean login() throws IOException { try { Request login = new Request.Builder() - .url(Launcher.BASE_URI + "/auth/login/") + .url(CtbrecApplication.BASE_URI + "/auth/login/") .build(); Response response = client.newCall(login).execute(); String content = response.body().string(); @@ -135,8 +135,8 @@ public class HttpClient { .add("csrfmiddlewaretoken", token) .build(); login = new Request.Builder() - .url(Launcher.BASE_URI + "/auth/login/") - .header("Referer", Launcher.BASE_URI + "/auth/login/") + .url(CtbrecApplication.BASE_URI + "/auth/login/") + .header("Referer", CtbrecApplication.BASE_URI + "/auth/login/") .post(body) .build(); diff --git a/src/main/java/ctbrec/ModelParser.java b/src/main/java/ctbrec/ModelParser.java index e6f20b3e..75b566ee 100644 --- a/src/main/java/ctbrec/ModelParser.java +++ b/src/main/java/ctbrec/ModelParser.java @@ -1,6 +1,6 @@ package ctbrec; -import static ctbrec.ui.Launcher.BASE_URI; +import static ctbrec.ui.CtbrecApplication.BASE_URI; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/ctbrec/ui/CtbrecApplication.java b/src/main/java/ctbrec/ui/CtbrecApplication.java new file mode 100644 index 00000000..00028fd3 --- /dev/null +++ b/src/main/java/ctbrec/ui/CtbrecApplication.java @@ -0,0 +1,268 @@ +package ctbrec.ui; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.lang.reflect.Type; +import java.util.List; +import java.util.Objects; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.squareup.moshi.JsonAdapter; +import com.squareup.moshi.Moshi; +import com.squareup.moshi.Types; + +import ctbrec.Config; +import ctbrec.HttpClient; +import ctbrec.Version; +import ctbrec.recorder.LocalRecorder; +import ctbrec.recorder.Recorder; +import ctbrec.recorder.RemoteRecorder; +import javafx.application.Application; +import javafx.application.HostServices; +import javafx.application.Platform; +import javafx.beans.value.ChangeListener; +import javafx.beans.value.ObservableValue; +import javafx.scene.Scene; +import javafx.scene.control.Alert; +import javafx.scene.control.Tab; +import javafx.scene.control.TabPane; +import javafx.scene.control.TabPane.TabClosingPolicy; +import javafx.scene.image.Image; +import javafx.stage.Stage; +import okhttp3.Request; +import okhttp3.Response; + +public class CtbrecApplication extends Application { + + static final transient Logger LOG = LoggerFactory.getLogger(CtbrecApplication.class); + public static final String BASE_URI = "https://chaturbate.com"; + + private Config config; + private Recorder recorder; + private HttpClient client; + static HostServices hostServices; + private SettingsTab settingsTab; + private TabPane tabPane = new TabPane(); + + @Override + public void start(Stage primaryStage) throws Exception { + loadConfig(); + hostServices = getHostServices(); + client = HttpClient.getInstance(); + createRecorder(); + doInitialLogin(); + createGui(primaryStage); + checkForUpdates(); + } + + private void createGui(Stage primaryStage) throws IOException { + LOG.debug("Creating GUI"); + primaryStage.setTitle("CTB Recorder " + getVersion()); + InputStream icon = getClass().getResourceAsStream("/icon.png"); + primaryStage.getIcons().add(new Image(icon)); + + tabPane = new TabPane(); + tabPane.getSelectionModel().selectedItemProperty().addListener(new ChangeListener() { + @Override + public void changed(ObservableValue ov, Tab from, Tab to) { + if(from != null && from instanceof TabSelectionListener) { + ((TabSelectionListener) from).deselected(); + } + if(to != null && to instanceof TabSelectionListener) { + ((TabSelectionListener) to).selected(); + } + } + }); + tabPane.setTabClosingPolicy(TabClosingPolicy.SELECTED_TAB); + tabPane.getTabs().add(createTab("Featured", BASE_URI + "/")); + tabPane.getTabs().add(createTab("Female", BASE_URI + "/female-cams/")); + tabPane.getTabs().add(createTab("Male", BASE_URI + "/male-cams/")); + tabPane.getTabs().add(createTab("Couples", BASE_URI + "/couple-cams/")); + tabPane.getTabs().add(createTab("Trans", BASE_URI + "/trans-cams/")); + FollowedTab tab = new FollowedTab("Followed", BASE_URI + "/followed-cams/"); + tab.setRecorder(recorder); + tabPane.getTabs().add(tab); + RecordedModelsTab modelsTab = new RecordedModelsTab("Recording", recorder); + tabPane.getTabs().add(modelsTab); + RecordingsTab recordingsTab = new RecordingsTab("Recordings", recorder, config); + tabPane.getTabs().add(recordingsTab); + settingsTab = new SettingsTab(); + tabPane.getTabs().add(settingsTab); + tabPane.getTabs().add(new DonateTabFx()); + + int windowWidth = Config.getInstance().getSettings().windowWidth; + int windowHeight = Config.getInstance().getSettings().windowHeight; + primaryStage.setScene(new Scene(tabPane, windowWidth, windowHeight)); + primaryStage.getScene().widthProperty().addListener((observable, oldVal, newVal) -> Config.getInstance().getSettings().windowWidth = newVal.intValue()); + primaryStage.getScene().heightProperty().addListener((observable, oldVal, newVal) -> Config.getInstance().getSettings().windowHeight = newVal.intValue()); + primaryStage.setMaximized(Config.getInstance().getSettings().windowMaximized); + primaryStage.maximizedProperty().addListener((observable, oldVal, newVal) -> Config.getInstance().getSettings().windowMaximized = newVal.booleanValue()); + primaryStage.setX(Config.getInstance().getSettings().windowX); + primaryStage.setY(Config.getInstance().getSettings().windowY); + primaryStage.xProperty().addListener((observable, oldVal, newVal) -> Config.getInstance().getSettings().windowX = newVal.intValue()); + primaryStage.yProperty().addListener((observable, oldVal, newVal) -> Config.getInstance().getSettings().windowY = newVal.intValue()); + primaryStage.show(); + primaryStage.setOnCloseRequest((e) -> { + e.consume(); + Alert shutdownInfo = new AutosizeAlert(Alert.AlertType.INFORMATION); + shutdownInfo.setTitle("Shutdown"); + shutdownInfo.setContentText("Shutting down. Please wait a few seconds..."); + shutdownInfo.show(); + + new Thread() { + @Override + public void run() { + settingsTab.saveConfig(); + recorder.shutdown(); + client.shutdown(); + try { + Config.getInstance().save(); + LOG.info("Shutdown complete. Goodbye!"); + Platform.exit(); + // This is needed, because OkHttp?! seems to block the shutdown with its writer threads. They are not daemon threads :( + System.exit(0); + } catch (IOException e1) { + Platform.runLater(() -> { + Alert alert = new AutosizeAlert(Alert.AlertType.ERROR); + alert.setTitle("Error saving settings"); + alert.setContentText("Couldn't save settings: " + e1.getLocalizedMessage()); + alert.showAndWait(); + System.exit(1); + }); + } + } + }.start(); + }); + } + + private void doInitialLogin() { + if(config.getSettings().username != null && !config.getSettings().username.isEmpty()) { + new Thread() { + @Override + public void run() { + if(!Objects.equals(System.getenv("CTBREC_DEV"), "1")) { + try { + client.login(); + } catch (IOException e1) { + LOG.warn("Initial login failed" , e1); + } + } + }; + }.start(); + } + } + + private void createRecorder() { + if(config.getSettings().localRecording) { + recorder = new LocalRecorder(config); + } else { + recorder = new RemoteRecorder(config, client); + } + } + + private void loadConfig() { + try { + Config.init(); + } catch (Exception e) { + Alert alert = new AutosizeAlert(Alert.AlertType.ERROR); + alert.setTitle("Whoopsie"); + alert.setContentText("Couldn't load settings."); + alert.showAndWait(); + System.exit(1); + } + config = Config.getInstance(); + } + + Tab createTab(String title, String url) { + ThumbOverviewTab tab = new ThumbOverviewTab(title, url, false); + tab.setRecorder(recorder); + return tab; + } + + public static void main(String[] args) { + launch(args); + } + + private void checkForUpdates() { + Thread updateCheck = new Thread(() -> { + try { + String url = "https://api.github.com/repos/0xboobface/ctbrec/releases"; + Request request = new Request.Builder().url(url).build(); + Response response = client.execute(request); + if(response.isSuccessful()) { + Moshi moshi = new Moshi.Builder().build(); + Type type = Types.newParameterizedType(List.class, Release.class); + JsonAdapter> adapter = moshi.adapter(type); + List releases = adapter.fromJson(response.body().source()); + Release latest = releases.get(0); + Version latestVersion = latest.getVersion(); + Version ctbrecVersion = getVersion(); + if(latestVersion.compareTo(ctbrecVersion) > 0) { + LOG.debug("Update available {} < {}", ctbrecVersion, latestVersion); + Platform.runLater(() -> tabPane.getTabs().add(new UpdateTab(latest))); + } else { + LOG.debug("ctbrec is up-to-date {}", ctbrecVersion); + } + } + response.close(); + } catch (IOException e) { + LOG.warn("Update check failed {}", e.getMessage()); + } + + }); + updateCheck.setName("Update Check"); + updateCheck.setDaemon(true); + updateCheck.start(); + } + + private Version getVersion() throws IOException { + if(Objects.equals(System.getenv("CTBREC_DEV"), "1")) { + return Version.of("0.0.0-DEV"); + } else { + try(InputStream is = getClass().getClassLoader().getResourceAsStream("version")) { + BufferedReader reader = new BufferedReader(new InputStreamReader(is)); + String versionString = reader.readLine(); + Version version = Version.of(versionString); + return version; + } + } + } + + static class Release { + private String name; + private String tag_name; + private String html_url; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getTagName() { + return tag_name; + } + + public void setTagName(String tagName) { + this.tag_name = tagName; + } + + public String getHtmlUrl() { + return html_url; + } + + public void setHtmlUrl(String htmlUrl) { + this.html_url = htmlUrl; + } + + public Version getVersion() { + return Version.of(tag_name); + } + } +} diff --git a/src/main/java/ctbrec/ui/DesktopIntergation.java b/src/main/java/ctbrec/ui/DesktopIntergation.java new file mode 100644 index 00000000..b3c7d5f9 --- /dev/null +++ b/src/main/java/ctbrec/ui/DesktopIntergation.java @@ -0,0 +1,62 @@ +package ctbrec.ui; + +import java.awt.Desktop; +import java.io.IOException; +import java.net.URI; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javafx.geometry.Insets; +import javafx.scene.control.Alert; +import javafx.scene.control.Label; +import javafx.scene.control.TextField; +import javafx.scene.layout.BorderPane; + +public class DesktopIntergation { + + private static final transient Logger LOG = LoggerFactory.getLogger(DesktopIntergation.class); + + public static void open(String uri) { + try { + CtbrecApplication.hostServices.showDocument(uri); + return; + } catch (Exception e) { + LOG.debug("Couldn't open URL with host services {}", uri); + } + + // opening with HostServices failed, now try Desktop + try { + Desktop.getDesktop().browse(new URI(uri)); + return; + } catch (Exception e) { + LOG.debug("Couldn't open URL with Desktop {}", uri); + } + + // try external helpers + String[] externalHelpers = {"kde-open5", "kde-open", "gnome-open", "xdg-open"}; + Runtime rt = Runtime.getRuntime(); + for (String helper : externalHelpers) { + try { + rt.exec(helper + " " + uri); + return; + } catch (IOException e) { + LOG.debug("Couldn't open URL with {} {}", helper, uri); + } + } + + // all attempts failed, show a dialog with URL at least + Alert shutdownInfo = new AutosizeAlert(Alert.AlertType.ERROR); + shutdownInfo.setTitle("Open URL"); + shutdownInfo.setContentText("Couldn't open URL"); + BorderPane pane = new BorderPane(); + pane.setTop(new Label()); + TextField urlField = new TextField(uri); + urlField.setPadding(new Insets(10)); + urlField.setEditable(false); + pane.setCenter(urlField); + shutdownInfo.getDialogPane().setExpandableContent(pane); + shutdownInfo.getDialogPane().setExpanded(true); + shutdownInfo.show(); + } +} diff --git a/src/main/java/ctbrec/ui/DonateTabFx.java b/src/main/java/ctbrec/ui/DonateTabFx.java index c5e27370..728f0e57 100644 --- a/src/main/java/ctbrec/ui/DonateTabFx.java +++ b/src/main/java/ctbrec/ui/DonateTabFx.java @@ -43,7 +43,7 @@ public class DonateTabFx extends Tab { ImageView coffeeImage = new ImageView(getClass().getResource("/html/buymeacoffee-fancy.png").toString()); Button coffeeButton = new Button("Buy me a coffee"); - coffeeButton.setOnMouseClicked((e) -> { Launcher.open("https://www.buymeacoffee.com/0xboobface"); }); + coffeeButton.setOnMouseClicked((e) -> { DesktopIntergation.open("https://www.buymeacoffee.com/0xboobface"); }); VBox buyCoffeeBox = new VBox(5); buyCoffeeBox.setAlignment(Pos.TOP_CENTER); buyCoffeeBox.getChildren().addAll(coffeeImage, coffeeButton); diff --git a/src/main/java/ctbrec/ui/Launcher.java b/src/main/java/ctbrec/ui/Launcher.java index 506818ce..65643326 100644 --- a/src/main/java/ctbrec/ui/Launcher.java +++ b/src/main/java/ctbrec/ui/Launcher.java @@ -1,272 +1,27 @@ package ctbrec.ui; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.lang.reflect.Type; -import java.util.List; -import java.util.Objects; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.squareup.moshi.JsonAdapter; -import com.squareup.moshi.Moshi; -import com.squareup.moshi.Types; - -import ctbrec.Config; -import ctbrec.HttpClient; -import ctbrec.Version; -import ctbrec.recorder.LocalRecorder; -import ctbrec.recorder.Recorder; -import ctbrec.recorder.RemoteRecorder; -import javafx.application.Application; -import javafx.application.HostServices; -import javafx.application.Platform; -import javafx.beans.value.ChangeListener; -import javafx.beans.value.ObservableValue; -import javafx.scene.Scene; -import javafx.scene.control.Alert; -import javafx.scene.control.Tab; -import javafx.scene.control.TabPane; -import javafx.scene.control.TabPane.TabClosingPolicy; -import javafx.scene.image.Image; -import javafx.stage.Stage; -import okhttp3.Request; -import okhttp3.Response; - -public class Launcher extends Application { +public class Launcher { private static final transient Logger LOG = LoggerFactory.getLogger(Launcher.class); - public static final String BASE_URI = "https://chaturbate.com"; - - private Config config; - private Recorder recorder; - private HttpClient client; - private static HostServices hostServices; - private SettingsTab settingsTab; - private TabPane tabPane = new TabPane(); - - @Override - public void start(Stage primaryStage) throws Exception { - loadConfig(); - hostServices = getHostServices(); - client = HttpClient.getInstance(); - createRecorder(); - doInitialLogin(); - createGui(primaryStage); - checkForUpdates(); - } - - private void createGui(Stage primaryStage) throws IOException { - LOG.debug("Creating GUI"); - primaryStage.setTitle("CTB Recorder " + getVersion()); - InputStream icon = getClass().getResourceAsStream("/icon.png"); - primaryStage.getIcons().add(new Image(icon)); - - tabPane = new TabPane(); - tabPane.getSelectionModel().selectedItemProperty().addListener(new ChangeListener() { - @Override - public void changed(ObservableValue ov, Tab from, Tab to) { - if(from != null && from instanceof TabSelectionListener) { - ((TabSelectionListener) from).deselected(); - } - if(to != null && to instanceof TabSelectionListener) { - ((TabSelectionListener) to).selected(); - } - } - }); - tabPane.setTabClosingPolicy(TabClosingPolicy.SELECTED_TAB); - tabPane.getTabs().add(createTab("Featured", BASE_URI + "/")); - tabPane.getTabs().add(createTab("Female", BASE_URI + "/female-cams/")); - tabPane.getTabs().add(createTab("Male", BASE_URI + "/male-cams/")); - tabPane.getTabs().add(createTab("Couples", BASE_URI + "/couple-cams/")); - tabPane.getTabs().add(createTab("Trans", BASE_URI + "/trans-cams/")); - FollowedTab tab = new FollowedTab("Followed", BASE_URI + "/followed-cams/"); - tab.setRecorder(recorder); - tabPane.getTabs().add(tab); - RecordedModelsTab modelsTab = new RecordedModelsTab("Recording", recorder); - tabPane.getTabs().add(modelsTab); - RecordingsTab recordingsTab = new RecordingsTab("Recordings", recorder, config); - tabPane.getTabs().add(recordingsTab); - settingsTab = new SettingsTab(); - tabPane.getTabs().add(settingsTab); - tabPane.getTabs().add(new DonateTabFx()); - - int windowWidth = Config.getInstance().getSettings().windowWidth; - int windowHeight = Config.getInstance().getSettings().windowHeight; - primaryStage.setScene(new Scene(tabPane, windowWidth, windowHeight)); - primaryStage.getScene().widthProperty().addListener((observable, oldVal, newVal) -> Config.getInstance().getSettings().windowWidth = newVal.intValue()); - primaryStage.getScene().heightProperty().addListener((observable, oldVal, newVal) -> Config.getInstance().getSettings().windowHeight = newVal.intValue()); - primaryStage.setMaximized(Config.getInstance().getSettings().windowMaximized); - primaryStage.maximizedProperty().addListener((observable, oldVal, newVal) -> Config.getInstance().getSettings().windowMaximized = newVal.booleanValue()); - primaryStage.setX(Config.getInstance().getSettings().windowX); - primaryStage.setY(Config.getInstance().getSettings().windowY); - primaryStage.xProperty().addListener((observable, oldVal, newVal) -> Config.getInstance().getSettings().windowX = newVal.intValue()); - primaryStage.yProperty().addListener((observable, oldVal, newVal) -> Config.getInstance().getSettings().windowY = newVal.intValue()); - primaryStage.show(); - primaryStage.setOnCloseRequest((e) -> { - e.consume(); - Alert shutdownInfo = new AutosizeAlert(Alert.AlertType.INFORMATION); - shutdownInfo.setTitle("Shutdown"); - shutdownInfo.setContentText("Shutting down. Please wait a few seconds..."); - shutdownInfo.show(); - - new Thread() { - @Override - public void run() { - settingsTab.saveConfig(); - recorder.shutdown(); - client.shutdown(); - try { - Config.getInstance().save(); - LOG.info("Shutdown complete. Goodbye!"); - Platform.exit(); - // This is needed, because OkHttp?! seems to block the shutdown with its writer threads. They are not daemon threads :( - System.exit(0); - } catch (IOException e1) { - Platform.runLater(() -> { - Alert alert = new AutosizeAlert(Alert.AlertType.ERROR); - alert.setTitle("Error saving settings"); - alert.setContentText("Couldn't save settings: " + e1.getLocalizedMessage()); - alert.showAndWait(); - System.exit(1); - }); - } - } - }.start(); - }); - } - - private void doInitialLogin() { - if(config.getSettings().username != null && !config.getSettings().username.isEmpty()) { - new Thread() { - @Override - public void run() { - if(!Objects.equals(System.getenv("CTBREC_DEV"), "1")) { - try { - client.login(); - } catch (IOException e1) { - LOG.warn("Initial login failed" , e1); - } - } - }; - }.start(); - } - } - - private void createRecorder() { - if(config.getSettings().localRecording) { - recorder = new LocalRecorder(config); - } else { - recorder = new RemoteRecorder(config, client); - } - } - - private void loadConfig() { - try { - Config.init(); - } catch (Exception e) { - Alert alert = new AutosizeAlert(Alert.AlertType.ERROR); - alert.setTitle("Whoopsie"); - alert.setContentText("Couldn't load settings."); - alert.showAndWait(); - System.exit(1); - } - config = Config.getInstance(); - } - - Tab createTab(String title, String url) { - ThumbOverviewTab tab = new ThumbOverviewTab(title, url, false); - tab.setRecorder(recorder); - return tab; - } - - public static void open(String uri) { - hostServices.showDocument(uri); - } public static void main(String[] args) { - launch(args); - } - - private void checkForUpdates() { - Thread updateCheck = new Thread(() -> { + String jvmName = System.getProperty("java.vm.name"); + if (jvmName.startsWith("OpenJDK")) { + // check for OpenJFX try { - String url = "https://api.github.com/repos/0xboobface/ctbrec/releases"; - Request request = new Request.Builder().url(url).build(); - Response response = client.execute(request); - if(response.isSuccessful()) { - Moshi moshi = new Moshi.Builder().build(); - Type type = Types.newParameterizedType(List.class, Release.class); - JsonAdapter> adapter = moshi.adapter(type); - List releases = adapter.fromJson(response.body().source()); - Release latest = releases.get(0); - Version latestVersion = latest.getVersion(); - Version ctbrecVersion = getVersion(); - if(latestVersion.compareTo(ctbrecVersion) > 0) { - LOG.debug("Update available {} < {}", ctbrecVersion, latestVersion); - Platform.runLater(() -> tabPane.getTabs().add(new UpdateTab(latest))); - } else { - LOG.debug("ctbrec is up-to-date {}", ctbrecVersion); - } - } - response.close(); - } catch (IOException e) { - LOG.warn("Update check failed {}", e.getMessage()); + Class.forName("javafx.application.Application"); + CtbrecApplication.main(args); + } catch (ClassNotFoundException e) { + LOG.error("You are running ctbrec with OpenJDK, but OpenJFX can not be found.\n" + + "Please either install OpenJFX or use the Oracle JRE, which you can download at\n" + + "http://www.oracle.com/technetwork/java/javase/downloads/index.html"); + System.exit(1); } - - }); - updateCheck.setName("Update Check"); - updateCheck.setDaemon(true); - updateCheck.start(); - } - - private Version getVersion() throws IOException { - if(Objects.equals(System.getenv("CTBREC_DEV"), "1")) { - return Version.of("0.0.0-DEV"); } else { - try(InputStream is = getClass().getClassLoader().getResourceAsStream("version")) { - BufferedReader reader = new BufferedReader(new InputStreamReader(is)); - String versionString = reader.readLine(); - Version version = Version.of(versionString); - return version; - } - } - } - - static class Release { - private String name; - private String tag_name; - private String html_url; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getTagName() { - return tag_name; - } - - public void setTagName(String tagName) { - this.tag_name = tagName; - } - - public String getHtmlUrl() { - return html_url; - } - - public void setHtmlUrl(String htmlUrl) { - this.html_url = htmlUrl; - } - - public Version getVersion() { - return Version.of(tag_name); + CtbrecApplication.main(args); } } } diff --git a/src/main/java/ctbrec/ui/RecordedModelsTab.java b/src/main/java/ctbrec/ui/RecordedModelsTab.java index aa3d0415..daf1c2c9 100644 --- a/src/main/java/ctbrec/ui/RecordedModelsTab.java +++ b/src/main/java/ctbrec/ui/RecordedModelsTab.java @@ -216,7 +216,7 @@ public class RecordedModelsTab extends Tab implements TabSelectionListener { }); MenuItem openInBrowser = new MenuItem("Open in Browser"); - openInBrowser.setOnAction((e) -> Launcher.open(table.getSelectionModel().getSelectedItem().getUrl())); + openInBrowser.setOnAction((e) -> DesktopIntergation.open(table.getSelectionModel().getSelectedItem().getUrl())); MenuItem openInPlayer = new MenuItem("Open in Player"); openInPlayer.setOnAction((e) -> Player.play(table.getSelectionModel().getSelectedItem().getUrl())); MenuItem switchStreamSource = new MenuItem("Switch resolution"); diff --git a/src/main/java/ctbrec/ui/ThumbCell.java b/src/main/java/ctbrec/ui/ThumbCell.java index 92f152aa..2f9287ae 100644 --- a/src/main/java/ctbrec/ui/ThumbCell.java +++ b/src/main/java/ctbrec/ui/ThumbCell.java @@ -420,9 +420,9 @@ public class ThumbCell extends StackPane { String url = null; if(follow) { - url = Launcher.BASE_URI + "/follow/follow/" + model.getName() + "/"; + url = CtbrecApplication.BASE_URI + "/follow/follow/" + model.getName() + "/"; } else { - url = Launcher.BASE_URI + "/follow/unfollow/" + model.getName() + "/"; + url = CtbrecApplication.BASE_URI + "/follow/unfollow/" + model.getName() + "/"; } RequestBody body = RequestBody.create(null, new byte[0]); diff --git a/src/main/java/ctbrec/ui/UpdateTab.java b/src/main/java/ctbrec/ui/UpdateTab.java index 9cf7c155..7ceecbe0 100644 --- a/src/main/java/ctbrec/ui/UpdateTab.java +++ b/src/main/java/ctbrec/ui/UpdateTab.java @@ -3,7 +3,7 @@ package ctbrec.ui; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import ctbrec.ui.Launcher.Release; +import ctbrec.ui.CtbrecApplication.Release; import javafx.geometry.Pos; import javafx.scene.control.Button; import javafx.scene.control.Label; @@ -23,7 +23,7 @@ public class UpdateTab extends Tab { VBox vbox = new VBox(10); vbox.getChildren().add(new Label("New Version available " + latest.getVersion())); Button button = new Button("Download"); - button.setOnAction((e) -> Launcher.open(latest.getHtmlUrl())); + button.setOnAction((e) -> DesktopIntergation.open(latest.getHtmlUrl())); vbox.getChildren().add(button); vbox.setAlignment(Pos.CENTER);