Skip to content

Commit 0a2454a

Browse files
committed
Add file picker
1 parent fe092c1 commit 0a2454a

File tree

4 files changed

+27
-4
lines changed

4 files changed

+27
-4
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ A GUI for saving SHSH blobs using encounter's fork of tsschecker. Supports both
33

44
If you have an antivirus, select "Always Allow" for anything related to tsschecker or Java. An antivirus may cause blobsaver to crash. If that happens please send feedback.
55

6-
![image](https://i.imgur.com/8gF6a5J.png)
6+
![image](https://i.imgur.com/g8jiFZz.png)
77

88
## Features
99
- Store up to three devices with presets
10-
- Choose where to save blobs
10+
- Choose where to save blobs with file picker
1111
- Automatically checks for updates and prompts if available
1212
- Optionally specify device identifier instead of using device picker
1313
- Optionally specify apnonce

src/main/java/blobsaver/Controller.java

+18
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import javafx.scene.control.TextField;
1616
import javafx.scene.effect.DropShadow;
1717
import javafx.scene.paint.Color;
18+
import javafx.stage.DirectoryChooser;
1819
import javafx.stage.Modality;
1920
import org.json.JSONException;
2021
import org.json.JSONObject;
@@ -497,6 +498,23 @@ public void identifierCheckBoxHandler() {
497498
}
498499
}
499500

501+
public void filePickerHandler() {
502+
DirectoryChooser dirChooser = new DirectoryChooser();
503+
dirChooser.setTitle("Choose a folder to save Blobs in");
504+
File startIn = new File(pathField.getText());
505+
if (startIn.exists()) {
506+
dirChooser.setInitialDirectory(startIn);
507+
} else if (startIn.getParentFile().exists()) {
508+
dirChooser.setInitialDirectory(startIn.getParentFile());
509+
} else {
510+
dirChooser.setInitialDirectory(new File(System.getProperty("user.home")));
511+
}
512+
File result = dirChooser.showDialog(Main.primaryStage);
513+
if (result != null) {
514+
pathField.setText(result.toString());
515+
}
516+
}
517+
500518
@SuppressWarnings("unchecked")
501519
private void loadPreset(int preset) {
502520
Preferences prefs = Preferences.userRoot().node("airsquared/blobsaver/preset" + preset);

src/main/java/blobsaver/Main.java

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
public class Main extends Application {
1111

1212
static final String appVersion = "v1.0";
13+
static Stage primaryStage;
1314

1415
public static void main(String[] args) {
1516
launch(args);
@@ -27,5 +28,6 @@ public void start(Stage primaryStage) throws Exception {
2728
primaryStage.getScene().getStylesheets().add(getClass().getResource("app.css").toExternalForm());
2829
primaryStage.show();
2930
primaryStage.setResizable(false);
31+
Main.primaryStage = primaryStage;
3032
}
3133
}

src/main/resources/blobsaver/blobsaver.fxml

+5-2
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,14 @@
100100
<Insets bottom="5.0" left="10.0" top="5.0"/>
101101
</VBox.margin>
102102
</Label>
103-
<TextField fx:id="pathField">
103+
<AnchorPane>
104104
<VBox.margin>
105105
<Insets bottom="5.0" left="10.0" right="10.0"/>
106106
</VBox.margin>
107-
</TextField>
107+
<TextField fx:id="pathField" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
108+
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"/>
109+
<Button mnemonicParsing="false" text="..." AnchorPane.rightAnchor="0.0" onAction="#filePickerHandler"/>
110+
</AnchorPane>
108111
<HBox prefHeight="100.0" prefWidth="200.0">
109112
<VBox.margin>
110113
<Insets top="10.0"/>

0 commit comments

Comments
 (0)