1212import javafx .scene .control .*;
1313import javafx .scene .control .Button ;
1414import javafx .scene .control .Label ;
15+ import javafx .scene .control .ScrollPane ;
1516import javafx .scene .control .TextField ;
1617import javafx .scene .effect .DropShadow ;
1718import javafx .scene .paint .Color ;
@@ -55,6 +56,7 @@ public class Controller {
5556
5657 @ FXML private Label versionLabel ;
5758
59+ @ FXML private ToggleButton savePresetButton ;
5860 @ FXML private Button preset1Button ;
5961 @ FXML private Button preset2Button ;
6062 @ FXML private Button preset3Button ;
@@ -67,6 +69,8 @@ public class Controller {
6769 @ FXML private Button preset10Button ;
6870 private ArrayList <Button > presetButtons ;
6971
72+ @ FXML private ScrollPane scrollPane ;
73+
7074 @ FXML private Button goButton ;
7175 @ FXML private Button plistPickerButton ;
7276
@@ -86,7 +90,7 @@ static void setPresetButtonNames() {
8690 for (int i = 1 ; i < 11 ; i ++) {
8791 if (!appPrefs .get ("Name Preset" + i , "" ).equals ("" )) {
8892 Button btn = (Button ) Main .primaryStage .getScene ().lookup ("#preset" + i );
89- btn .setText (appPrefs .get ("Name Preset" + i , "" ));
93+ btn .setText ("Load " + appPrefs .get ("Name Preset" + i , "" ));
9094 }
9195 }
9296 }
@@ -236,7 +240,7 @@ public void initialize() {
236240 checkForUpdates ();
237241 }
238242
239- private void checkForUpdates () {
243+ public void checkForUpdates () {
240244 Service <Void > service = new Service <Void >() {
241245 @ Override
242246 protected Task <Void > createTask () {
@@ -257,32 +261,40 @@ protected Void call() throws Exception {
257261 } catch (IOException e ) {
258262 e .printStackTrace ();
259263 }
260- String version ;
264+ String newVersion ;
265+ String changelog ;
261266 try {
262- version = new JSONObject (response .toString ()).getString ("tag_name" );
267+ newVersion = new JSONObject (response .toString ()).getString ("tag_name" );
268+ changelog = new JSONObject (response .toString ()).getString ("body" );
269+ changelog = changelog .substring (changelog .indexOf ("Changelog" ));
263270 } catch (JSONException e ) {
264- version = Main .appVersion ;
271+ newVersion = Main .appVersion ;
272+ changelog = "" ;
265273 }
266- if (!version .equals (Main .appVersion )) {
274+ Preferences appPrefs = Preferences .userRoot ().node ("airsquared/blobsaver/prefs" );
275+ if (!newVersion .equals (Main .appVersion ) && !appPrefs .get ("Ignore Version" , "" ).equals (newVersion )) {
267276 final CountDownLatch latch = new CountDownLatch (1 );
268- String finalVersion = version ;
277+ final String finalNewVersion = newVersion ;
278+ final String finalChangelog = changelog ;
269279 Platform .runLater (() -> {
270280 try {
271281 ButtonType downloadNow = new ButtonType ("Download now" );
272-
273- Alert alert = new Alert (
274- Alert .AlertType .INFORMATION , "You have version " + Main .appVersion , downloadNow , ButtonType .CANCEL );
275- alert .setHeaderText ("New Update Available: " + finalVersion );
282+ ButtonType ignore = new ButtonType ("Ignore this update" );
283+ Alert alert = new Alert (Alert .AlertType .INFORMATION , "You have version " + Main .appVersion + "\n \n " + finalChangelog , downloadNow , ignore , ButtonType .CANCEL );
284+ alert .setHeaderText ("New Update Available: " + finalNewVersion );
285+ alert .setTitle ("New Update Available" );
286+ alert .initModality (Modality .NONE );
276287 Button dlButton = (Button ) alert .getDialogPane ().lookupButton (downloadNow );
277288 dlButton .setDefaultButton (true );
278- alert .initModality (Modality .NONE );
279289 alert .showAndWait ();
280- try {
281- if ( alert . getResult (). equals ( downloadNow ) && Desktop . getDesktop (). isSupported ( Desktop . Action . BROWSE )) {
290+ if ( alert . getResult (). equals ( downloadNow ) && Desktop . getDesktop (). isSupported ( Desktop . Action . BROWSE )) {
291+ try {
282292 Desktop .getDesktop ().browse (new URI ("https://github.com/airsquared/blobsaver/releases/latest" ));
293+ } catch (IOException | URISyntaxException ee ) {
294+ ee .printStackTrace ();
283295 }
284- } catch ( IOException | URISyntaxException ee ) {
285- ee . printStackTrace ( );
296+ } else if ( alert . getResult (). equals ( ignore ) ) {
297+ appPrefs . put ( "Ignore Version" , finalNewVersion );
286298 }
287299 } finally {
288300 latch .countDown ();
@@ -298,15 +310,31 @@ protected Void call() throws Exception {
298310 service .start ();
299311 }
300312
301- private void reportError ( Alert alert ) {
302- try {
303- if ( alert . getResult (). equals ( githubIssue ) && Desktop . getDesktop (). isSupported ( Desktop . Action . BROWSE )) {
313+ public void newGithubIssue ( ) {
314+ if ( Desktop . getDesktop (). isSupported ( Desktop . Action . BROWSE )) {
315+ try {
304316 Desktop .getDesktop ().browse (githubIssueURI );
305- } else if (alert .getResult ().equals (redditPM ) && Desktop .getDesktop ().isSupported (Desktop .Action .BROWSE )) {
317+ } catch (IOException e ) {
318+ e .printStackTrace ();
319+ }
320+ }
321+ }
322+
323+ public void sendRedditPM () {
324+ if (Desktop .getDesktop ().isSupported (Desktop .Action .BROWSE )) {
325+ try {
306326 Desktop .getDesktop ().browse (redditPMURI );
327+ } catch (IOException e ) {
328+ e .printStackTrace ();
307329 }
308- } catch (IOException ee ) {
309- ee .printStackTrace ();
330+ }
331+ }
332+
333+ private void reportError (Alert alert ) {
334+ if (alert .getResult ().equals (githubIssue )) {
335+ newGithubIssue ();
336+ } else if (alert .getResult ().equals (redditPM )) {
337+ sendRedditPM ();
310338 }
311339 }
312340
@@ -622,7 +650,7 @@ private void presetButtonHandler(ActionEvent evt) {
622650 int preset = Integer .valueOf (btn .getId ().substring ("preset" .length ()));
623651 if (editingPresets ) {
624652 savePreset (preset );
625- savePresetHandler ();
653+ savePresetButton . fire ();
626654 } else {
627655 loadPreset (preset );
628656 }
@@ -681,12 +709,46 @@ private void savePreset(int preset) {
681709 public void savePresetHandler () {
682710 editingPresets = !editingPresets ;
683711 if (editingPresets ) {
684- presetButtons .forEach ((Button btn ) -> btn .setText ("Save in Preset " + btn .getId ().substring ("preset" .length ())));
712+ goButton .setVisible (false );
713+ goButton .setManaged (false );
714+ savePresetButton .setText ("Cancel" );
715+ scrollPane .setMaxWidth (410.0 );
716+ scrollPane .setPrefWidth (410.0 );
717+ presetButtons .forEach ((Button btn ) -> btn .setText ("Save in " + btn .getText ().substring ("Load " .length ())));
685718 } else {
686- presetButtons .forEach ((Button btn ) -> btn .setText ("Load Preset " + btn .getId ().substring ("preset" .length ())));
719+ savePresetButton .setText ("Save" );
720+ scrollPane .setMaxWidth (385.0 );
721+ scrollPane .setPrefWidth (385.0 );
722+ goButton .setManaged (true );
723+ goButton .setVisible (true );
724+ presetButtons .forEach ((Button btn ) -> btn .setText ("Load " + btn .getText ().substring ("Save in " .length ())));
687725 }
688726 }
689727
728+ public void checkBlobs () {
729+ if (Desktop .getDesktop ().isSupported (Desktop .Action .BROWSE )) {
730+ try {
731+ Desktop .getDesktop ().browse (new URI ("https://tsssaver.1conan.com/check.php" ));
732+ } catch (IOException | URISyntaxException e ) {
733+ e .printStackTrace ();
734+ }
735+ }
736+ }
737+
738+ public void aboutMenuHandler () {
739+ ButtonType githubRepo = new ButtonType ("Github Repo" );
740+ Alert alert = new Alert (Alert .AlertType .INFORMATION , "About text here" , githubRepo , ButtonType .OK );
741+ alert .setTitle ("About" );
742+ alert .setHeaderText ("Blobsaver " + Main .appVersion );
743+ alert .showAndWait ();
744+ if (alert .getResult ().equals (githubRepo ) && Desktop .getDesktop ().isSupported (Desktop .Action .BROWSE )) {
745+ try {
746+ Desktop .getDesktop ().browse (new URI ("https://github.com/airsquared/blobsaver" ));
747+ } catch (IOException | URISyntaxException e ) {
748+ e .printStackTrace ();
749+ }
750+ }
751+ }
690752
691753 public void go () {
692754 boolean doReturn = false ;
0 commit comments