Skip to content

Commit d62e67b

Browse files
committed
Add menu bar, Improve saving presets, Ignore versions so you aren't prompted to update everytime you open the app
1 parent d010b22 commit d62e67b

File tree

4 files changed

+120
-44
lines changed

4 files changed

+120
-44
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ If you have an antivirus, select "Always Allow" for anything related to tsscheck
1717
Please send feedback via [Github Issue](https://github.com/airsquared/blobsaver/issues/new) or [Reddit PM](https://www.reddit.com//message/compose?to=01110101_00101111&subject=Blobsaver+Feedback) if you encounter any bugs/problems or have a feature request.
1818

1919
## TODO:
20-
- Verify blobs
2120
- Question mark buttons to tell you what each thing does
2221
- Package into .app/.exe [maybe this](https://github.com/Jorl17/jar2app)
2322
- Automatically save blobs for all signed versions

src/main/java/blobsaver/Controller.java

Lines changed: 87 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import javafx.scene.control.*;
1313
import javafx.scene.control.Button;
1414
import javafx.scene.control.Label;
15+
import javafx.scene.control.ScrollPane;
1516
import javafx.scene.control.TextField;
1617
import javafx.scene.effect.DropShadow;
1718
import 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;

src/main/java/blobsaver/Main.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ public void start(Stage primaryStage) throws Exception {
2222
Parent root = FXMLLoader.load(getClass().getResource("blobsaver.fxml"));
2323
primaryStage.setTitle("SHSH Blob Saver " + appVersion);
2424
if (PlatformUtil.isWindows()) {
25-
primaryStage.setScene(new Scene(root, 520, 570));
25+
primaryStage.setScene(new Scene(root, 520, 610));
2626
} else {
27-
primaryStage.setScene(new Scene(root, 500, 550));
27+
primaryStage.setScene(new Scene(root, 500, 580));
2828
}
2929
primaryStage.getScene().getStylesheets().add(getClass().getResource("app.css").toExternalForm());
3030
primaryStage.show();

src/main/resources/blobsaver/blobsaver.fxml

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,18 @@
77
minWidth="-Infinity"
88
prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8"
99
fx:controller="blobsaver.Controller">
10+
<MenuBar>
11+
<Menu mnemonicParsing="false" text="Options">
12+
<MenuItem mnemonicParsing="false" onAction="#checkBlobs" text="Check for valid Blobs"/>
13+
<MenuItem mnemonicParsing="false" onAction="#checkForUpdates" text="Check for Updates"/>
14+
</Menu>
15+
<Menu mnemonicParsing="false" text="Help">
16+
<MenuItem mnemonicParsing="false" onAction="#newGithubIssue"
17+
text="Send Feedback(Github Issue)"/>
18+
<MenuItem mnemonicParsing="false" onAction="#sendRedditPM" text="Send Feedback(Reddit PM)"/>
19+
<MenuItem mnemonicParsing="false" onAction="#aboutMenuHandler" text="About"/>
20+
</Menu>
21+
</MenuBar>
1022
<Label text="ECID:">
1123
<VBox.margin>
1224
<Insets left="10.0" top="10.0"/>
@@ -138,63 +150,66 @@
138150
</AnchorPane>
139151
<HBox prefHeight="100.0" prefWidth="200.0">
140152
<VBox.margin>
141-
<Insets top="10.0"/>
153+
<Insets left="10.0" top="10.0"/>
142154
</VBox.margin>
143155
<Button fx:id="goButton" mnemonicParsing="false" onAction="#go" text="Go">
144156
<HBox.margin>
145-
<Insets left="10.0" right="5.0"/>
157+
<Insets right="5.0"/>
146158
</HBox.margin>
147159
</Button>
148-
<Button mnemonicParsing="false" onAction="#savePresetHandler" text="Save">
160+
<ToggleButton fx:id="savePresetButton" mnemonicParsing="false" onAction="#savePresetHandler"
161+
text="Save">
149162
<HBox.margin>
150163
<Insets left="5.0" right="5.0"/>
151164
</HBox.margin>
152-
</Button>
153-
<ScrollPane fitToHeight="true" prefHeight="50.0" prefWidth="385.0"
154-
style="-fx-background-color: transparent;">
165+
</ToggleButton>
166+
<ScrollPane fitToHeight="true" maxWidth="385.0" prefHeight="50.0" prefWidth="385.0"
167+
style="-fx-background-color: transparent;" fx:id="scrollPane">
155168
<HBox fillHeight="false" maxHeight="10.0">
156-
<Button fx:id="preset1Button" mnemonicParsing="false" text="Load Preset 1" id="preset1"/>
157-
<Button fx:id="preset2Button" mnemonicParsing="false" text="Load Preset 2" id="preset2">
169+
<Button id="preset1" fx:id="preset1Button" mnemonicParsing="false"
170+
text="Load Preset 1"/>
171+
<Button id="preset2" fx:id="preset2Button" mnemonicParsing="false" text="Load Preset 2">
158172
<HBox.margin>
159173
<Insets left="5.0"/>
160174
</HBox.margin>
161175
</Button>
162-
<Button fx:id="preset3Button" mnemonicParsing="false" text="Load Preset 3" id="preset3">
176+
<Button id="preset3" fx:id="preset3Button" mnemonicParsing="false" text="Load Preset 3">
163177
<HBox.margin>
164178
<Insets left="5.0"/>
165179
</HBox.margin>
166180
</Button>
167-
<Button fx:id="preset4Button" mnemonicParsing="false" text="Load Preset 4" id="preset4">
181+
<Button id="preset4" fx:id="preset4Button" mnemonicParsing="false" text="Load Preset 4">
168182
<HBox.margin>
169183
<Insets left="5.0"/>
170184
</HBox.margin>
171185
</Button>
172-
<Button fx:id="preset5Button" mnemonicParsing="false" text="Load Preset 5" id="preset5">
186+
<Button id="preset5" fx:id="preset5Button" mnemonicParsing="false" text="Load Preset 5">
173187
<HBox.margin>
174188
<Insets left="5.0"/>
175189
</HBox.margin>
176190
</Button>
177-
<Button fx:id="preset6Button" mnemonicParsing="false" text="Load Preset 6" id="preset6">
191+
<Button id="preset6" fx:id="preset6Button" mnemonicParsing="false" text="Load Preset 6">
178192
<HBox.margin>
179193
<Insets left="5.0"/>
180194
</HBox.margin>
181195
</Button>
182-
<Button fx:id="preset7Button" mnemonicParsing="false" text="Load Preset 7" id="preset7">
196+
<Button id="preset7" fx:id="preset7Button" mnemonicParsing="false" text="Load Preset 7">
183197
<HBox.margin>
184198
<Insets left="5.0"/>
185199
</HBox.margin>
186200
</Button>
187-
<Button fx:id="preset8Button" mnemonicParsing="false" text="Load Preset 8" id="preset8">
201+
<Button id="preset8" fx:id="preset8Button" mnemonicParsing="false" text="Load Preset 8">
188202
<HBox.margin>
189203
<Insets left="5.0"/>
190204
</HBox.margin>
191205
</Button>
192-
<Button fx:id="preset9Button" mnemonicParsing="false" text="Load Preset 9" id="preset9">
206+
<Button id="preset9" fx:id="preset9Button" mnemonicParsing="false" text="Load Preset 9">
193207
<HBox.margin>
194208
<Insets left="5.0"/>
195209
</HBox.margin>
196210
</Button>
197-
<Button fx:id="preset10Button" mnemonicParsing="false" text="Load Preset 10" id="preset10">
211+
<Button id="preset10" fx:id="preset10Button" mnemonicParsing="false"
212+
text="Load Preset 10">
198213
<HBox.margin>
199214
<Insets left="5.0"/>
200215
</HBox.margin>

0 commit comments

Comments
 (0)