Skip to content

Commit d010b22

Browse files
committed
Support up to ten presets, Rename presets
1 parent 8a278b6 commit d010b22

File tree

5 files changed

+113
-65
lines changed

5 files changed

+113
-65
lines changed

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ If you have an antivirus, select "Always Allow" for anything related to tsscheck
66
![image](https://i.imgur.com/i74ba2a.png)
77

88
## Features
9-
- Store up to three devices with presets
9+
- Store up to ten devices with presets
1010
- Choose where to save blobs with file picker
1111
- Save blobs for beta versions
1212
- Automatically checks for updates and prompts if available
@@ -17,10 +17,11 @@ 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-
- More presets
21-
- Renaming presets
22-
- Try packaging into .app/.exe [maybe this](https://github.com/Jorl17/jar2app)
23-
- Daemon to do it automatically in the background (Possibility?)
20+
- Verify blobs
21+
- Question mark buttons to tell you what each thing does
22+
- Package into .app/.exe [maybe this](https://github.com/Jorl17/jar2app)
23+
- Automatically save blobs for all signed versions
24+
- Daemon to do it automatically in the background
2425
- Use libimobiledevice to read ECID directly from device (Possibility?)
2526

2627
## Built With

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ plugins {
33
id 'java'
44
}
55

6-
version '1.0.1'
6+
version '1.1alpha'
77

88
sourceCompatibility = 1.8
99

src/main/java/blobsaver/Controller.java

Lines changed: 47 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,15 @@ public class Controller {
5858
@FXML private Button preset1Button;
5959
@FXML private Button preset2Button;
6060
@FXML private Button preset3Button;
61+
@FXML private Button preset4Button;
62+
@FXML private Button preset5Button;
63+
@FXML private Button preset6Button;
64+
@FXML private Button preset7Button;
65+
@FXML private Button preset8Button;
66+
@FXML private Button preset9Button;
67+
@FXML private Button preset10Button;
68+
private ArrayList<Button> presetButtons;
69+
6170
@FXML private Button goButton;
6271
@FXML private Button plistPickerButton;
6372

@@ -72,6 +81,16 @@ public class Controller {
7281
private URI githubIssueURI;
7382
private URI redditPMURI;
7483

84+
static void setPresetButtonNames() {
85+
Preferences appPrefs = Preferences.userRoot().node("airsquared/blobsaver/prefs");
86+
for (int i = 1; i < 11; i++) {
87+
if (!appPrefs.get("Name Preset" + i, "").equals("")) {
88+
Button btn = (Button) Main.primaryStage.getScene().lookup("#preset" + i);
89+
btn.setText(appPrefs.get("Name Preset" + i, ""));
90+
}
91+
}
92+
}
93+
7594
@SuppressWarnings("unchecked")
7695
@FXML
7796
public void initialize() {
@@ -185,6 +204,9 @@ public void initialize() {
185204
errorBorder.setWidth(20);
186205
errorBorder.setHeight(20);
187206

207+
presetButtons = new ArrayList<>(Arrays.asList(preset1Button, preset2Button, preset3Button, preset4Button, preset5Button, preset6Button, preset7Button, preset8Button, preset9Button, preset10Button));
208+
presetButtons.forEach((Button btn) -> btn.setOnAction(this::presetButtonHandler));
209+
188210
try {
189211
githubIssueURI = new URI("https://github.com/airsquared/blobsaver/issues/new");
190212
redditPMURI = new URI("https://www.reddit.com//message/compose?to=01110101_00101111&subject=Blobsaver+Bug+Report");
@@ -595,10 +617,9 @@ private void loadPreset(int preset) {
595617

596618
}
597619

598-
public void presetButtonHandler(ActionEvent evt) {
620+
private void presetButtonHandler(ActionEvent evt) {
599621
Button btn = (Button) evt.getTarget();
600-
String text = btn.getText();
601-
int preset = Integer.valueOf(text.substring(text.length() - 1));
622+
int preset = Integer.valueOf(btn.getId().substring("preset".length()));
602623
if (editingPresets) {
603624
savePreset(preset);
604625
savePresetHandler();
@@ -628,49 +649,41 @@ private void savePreset(int preset) {
628649
if (doReturn) {
629650
return;
630651
}
631-
Preferences prefs = Preferences.userRoot().node("airsquared/blobsaver/preset" + preset);
632-
prefs.putBoolean("Exists", true);
633-
prefs.put("ECID", ecidField.getText());
634-
prefs.put("Path", pathField.getText());
652+
TextInputDialog textInputDialog = new TextInputDialog();
653+
textInputDialog.setTitle("Name Preset " + preset);
654+
textInputDialog.setHeaderText("Name Preset");
655+
textInputDialog.setContentText("Please enter a name for the preset:");
656+
textInputDialog.showAndWait();
657+
if (!textInputDialog.getResult().equals("") || !(textInputDialog.getResult() == null)) {
658+
Preferences appPrefs = Preferences.userRoot().node("airsquared/blobsaver/prefs");
659+
appPrefs.put("Name Preset" + preset, textInputDialog.getResult());
660+
}
661+
662+
Preferences presetPrefs = Preferences.userRoot().node("airsquared/blobsaver/preset" + preset);
663+
presetPrefs.putBoolean("Exists", true);
664+
presetPrefs.put("ECID", ecidField.getText());
665+
presetPrefs.put("Path", pathField.getText());
635666
if (identifierCheckBox.isSelected()) {
636-
prefs.put("Device Type", "none");
637-
prefs.put("Device Model", "none");
638-
prefs.put("Device Identifier", identifierField.getText());
667+
presetPrefs.put("Device Type", "none");
668+
presetPrefs.put("Device Model", "none");
669+
presetPrefs.put("Device Identifier", identifierField.getText());
639670
} else {
640-
prefs.put("Device Type", (String) deviceTypeChoiceBox.getValue());
641-
prefs.put("Device Model", (String) deviceModelChoiceBox.getValue());
671+
presetPrefs.put("Device Type", (String) deviceTypeChoiceBox.getValue());
672+
presetPrefs.put("Device Model", (String) deviceModelChoiceBox.getValue());
642673
}
643674
if (boardConfig) {
644-
prefs.put("Board Config", boardConfigField.getText());
675+
presetPrefs.put("Board Config", boardConfigField.getText());
645676
} else {
646-
prefs.put("Board Config", "none");
677+
presetPrefs.put("Board Config", "none");
647678
}
648679
}
649680

650681
public void savePresetHandler() {
651682
editingPresets = !editingPresets;
652683
if (editingPresets) {
653-
int depth = 40;
654-
DropShadow borderGlow = new DropShadow();
655-
borderGlow.setOffsetY(0f);
656-
borderGlow.setOffsetX(0f);
657-
borderGlow.setColor(Color.CYAN);
658-
borderGlow.setWidth(depth);
659-
borderGlow.setHeight(depth);
660-
661-
preset1Button.setEffect(borderGlow);
662-
preset2Button.setEffect(borderGlow);
663-
preset3Button.setEffect(borderGlow);
664-
preset1Button.setText("Preset 1");
665-
preset2Button.setText("Preset 2");
666-
preset3Button.setText("Preset 3");
684+
presetButtons.forEach((Button btn) -> btn.setText("Save in Preset " + btn.getId().substring("preset".length())));
667685
} else {
668-
preset1Button.setEffect(null);
669-
preset2Button.setEffect(null);
670-
preset3Button.setEffect(null);
671-
preset1Button.setText("Load Preset 1");
672-
preset2Button.setText("Load Preset 2");
673-
preset3Button.setText("Load Preset 3");
686+
presetButtons.forEach((Button btn) -> btn.setText("Load Preset " + btn.getId().substring("preset".length())));
674687
}
675688
}
676689

src/main/java/blobsaver/Main.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
public class Main extends Application {
1111

12-
static final String appVersion = "v1.0.1";
12+
static final String appVersion = "v1.1alpha";
1313
static Stage primaryStage;
1414

1515
public static void main(String[] args) {
@@ -18,16 +18,17 @@ public static void main(String[] args) {
1818

1919
@Override
2020
public void start(Stage primaryStage) throws Exception {
21+
Main.primaryStage = primaryStage;
2122
Parent root = FXMLLoader.load(getClass().getResource("blobsaver.fxml"));
2223
primaryStage.setTitle("SHSH Blob Saver " + appVersion);
2324
if (PlatformUtil.isWindows()) {
2425
primaryStage.setScene(new Scene(root, 520, 570));
2526
} else {
26-
primaryStage.setScene(new Scene(root, 500, 540));
27+
primaryStage.setScene(new Scene(root, 500, 550));
2728
}
2829
primaryStage.getScene().getStylesheets().add(getClass().getResource("app.css").toExternalForm());
2930
primaryStage.show();
3031
primaryStage.setResizable(false);
31-
Main.primaryStage = primaryStage;
32+
Controller.setPresetButtonNames();
3233
}
3334
}

src/main/resources/blobsaver/blobsaver.fxml

Lines changed: 55 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
<Insets bottom="5.0" left="10.0" right="10.0" top="5.0"/>
8282
</VBox.margin>
8383
<TextField fx:id="versionField" disable="true" promptText="Version"/>
84-
<TextField promptText="Build ID" disable="true" fx:id="buildIDField">
84+
<TextField fx:id="buildIDField" disable="true" promptText="Build ID">
8585
<HBox.margin>
8686
<Insets left="10.0"/>
8787
</HBox.margin>
@@ -99,8 +99,8 @@
9999
<TextField fx:id="buildManifestField" disable="true" promptText="Path to Build Manifest .plist"
100100
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0"
101101
AnchorPane.topAnchor="0.0"/>
102-
<Button layoutX="147.0" mnemonicParsing="false" text="..." AnchorPane.rightAnchor="0.0"
103-
onAction="#plistPickerHandler" fx:id="plistPickerButton" disable="true"/>
102+
<Button fx:id="plistPickerButton" disable="true" layoutX="147.0" mnemonicParsing="false"
103+
onAction="#plistPickerHandler" text="..." AnchorPane.rightAnchor="0.0"/>
104104
</AnchorPane>
105105
<Label text="Internal Name/Board Configuration:">
106106
<VBox.margin>
@@ -145,28 +145,61 @@
145145
<Insets left="10.0" right="5.0"/>
146146
</HBox.margin>
147147
</Button>
148-
<Button mnemonicParsing="false" onAction="#savePresetHandler" text="Save as preset">
148+
<Button mnemonicParsing="false" onAction="#savePresetHandler" text="Save">
149149
<HBox.margin>
150150
<Insets left="5.0" right="5.0"/>
151151
</HBox.margin>
152152
</Button>
153-
<Button fx:id="preset1Button" mnemonicParsing="false" onAction="#presetButtonHandler"
154-
text="Load Preset 1">
155-
<HBox.margin>
156-
<Insets right="5.0"/>
157-
</HBox.margin>
158-
</Button>
159-
<Button fx:id="preset2Button" mnemonicParsing="false" onAction="#presetButtonHandler"
160-
text="Load Preset 2">
161-
<HBox.margin>
162-
<Insets right="5.0"/>
163-
</HBox.margin>
164-
</Button>
165-
<Button fx:id="preset3Button" mnemonicParsing="false" onAction="#presetButtonHandler"
166-
text="Load Preset 3">
167-
<HBox.margin>
168-
<Insets right="5.0"/>
169-
</HBox.margin>
170-
</Button>
153+
<ScrollPane fitToHeight="true" prefHeight="50.0" prefWidth="385.0"
154+
style="-fx-background-color: transparent;">
155+
<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">
158+
<HBox.margin>
159+
<Insets left="5.0"/>
160+
</HBox.margin>
161+
</Button>
162+
<Button fx:id="preset3Button" mnemonicParsing="false" text="Load Preset 3" id="preset3">
163+
<HBox.margin>
164+
<Insets left="5.0"/>
165+
</HBox.margin>
166+
</Button>
167+
<Button fx:id="preset4Button" mnemonicParsing="false" text="Load Preset 4" id="preset4">
168+
<HBox.margin>
169+
<Insets left="5.0"/>
170+
</HBox.margin>
171+
</Button>
172+
<Button fx:id="preset5Button" mnemonicParsing="false" text="Load Preset 5" id="preset5">
173+
<HBox.margin>
174+
<Insets left="5.0"/>
175+
</HBox.margin>
176+
</Button>
177+
<Button fx:id="preset6Button" mnemonicParsing="false" text="Load Preset 6" id="preset6">
178+
<HBox.margin>
179+
<Insets left="5.0"/>
180+
</HBox.margin>
181+
</Button>
182+
<Button fx:id="preset7Button" mnemonicParsing="false" text="Load Preset 7" id="preset7">
183+
<HBox.margin>
184+
<Insets left="5.0"/>
185+
</HBox.margin>
186+
</Button>
187+
<Button fx:id="preset8Button" mnemonicParsing="false" text="Load Preset 8" id="preset8">
188+
<HBox.margin>
189+
<Insets left="5.0"/>
190+
</HBox.margin>
191+
</Button>
192+
<Button fx:id="preset9Button" mnemonicParsing="false" text="Load Preset 9" id="preset9">
193+
<HBox.margin>
194+
<Insets left="5.0"/>
195+
</HBox.margin>
196+
</Button>
197+
<Button fx:id="preset10Button" mnemonicParsing="false" text="Load Preset 10" id="preset10">
198+
<HBox.margin>
199+
<Insets left="5.0"/>
200+
</HBox.margin>
201+
</Button>
202+
</HBox>
203+
</ScrollPane>
171204
</HBox>
172205
</VBox>

0 commit comments

Comments
 (0)