66import javafx .fxml .FXML ;
77import javafx .scene .control .CheckBox ;
88import javafx .scene .control .ChoiceBox ;
9+ import javafx .scene .control .Label ;
910import javafx .scene .control .TextField ;
1011
11- import java .io .BufferedReader ;
12- import java .io .IOException ;
13- import java .io .InputStreamReader ;
12+ import java .io .*;
13+ import java .net .URISyntaxException ;
1414import java .util .ArrayList ;
1515import java .util .Arrays ;
16+ import java .util .Properties ;
1617
1718public class Controller {
1819
20+
1921 @ FXML private ChoiceBox deviceTypeChoiceBox ;
2022 @ FXML private ChoiceBox deviceModelChoiceBox ;
2123 @ FXML private TextField ecidField ;
2224 @ FXML private TextField boardConfigField ;
2325 @ FXML private TextField apnonceField ;
26+ @ FXML private TextField versionField ;
2427 @ FXML private CheckBox apnonceCheckBox ;
28+ @ FXML private CheckBox versionCheckBox ;
29+ @ FXML private Label versionLabel ;
2530 private boolean boardConfig = false ;
2631
2732 @ SuppressWarnings ("unchecked" )
@@ -41,15 +46,19 @@ public void initialize() {
4146 switch (v ) {
4247 case "iPhone" :
4348 deviceModelChoiceBox .setItems (iPhones );
49+ versionLabel .setText ("iOS Version" );
4450 break ;
4551 case "iPod(not supported yet)" :
4652 deviceModelChoiceBox .setItems (iPods );
53+ versionLabel .setText ("iOS Version" );
4754 break ;
4855 case "iPad(not supported yet)" :
4956 deviceModelChoiceBox .setItems (iPads );
57+ versionLabel .setText ("iOS Version" );
5058 break ;
5159 case "AppleTV(not supported yet)" :
5260 deviceModelChoiceBox .setItems (AppleTVs );
61+ versionLabel .setText ("tvOS Version" );
5362 break ;
5463 }
5564 });
@@ -60,13 +69,36 @@ public void initialize() {
6069 boardConfigField .setDisable (false );
6170 } else {
6271 boardConfig = false ;
72+ boardConfigField .setText ("" );
6373 boardConfigField .setDisable (true );
6474 }
6575 });
76+ File file ;
77+ try {
78+ file = new File (getClass ().getResource ("options.properties" ).toURI ());
79+ if (file .exists ()) {
80+ Properties prop = new Properties ();
81+ try (InputStream input = new FileInputStream (file )) {
82+ prop .load (input );
83+ ecidField .setText (prop .getProperty ("ecid" ));
84+ deviceTypeChoiceBox .setValue (prop .getProperty ("deviceType" ));
85+ deviceModelChoiceBox .setValue (prop .getProperty ("deviceModel" ));
86+ if (!prop .getProperty ("boardConfig" ).equals ("none" )) {
87+ boardConfigField .setText (prop .getProperty ("boardConfig" ));
88+ }
89+ } catch (IOException e ) {
90+ e .printStackTrace ();
91+ }
92+ }
93+ } catch (URISyntaxException e ) {
94+ e .printStackTrace ();
95+ } catch (NullPointerException e ) {
96+ System .out .println ("No options file" );
97+ }
6698 }
6799
68100 private void run (String device ) {
69- ArrayList <String > args = new ArrayList <String >(Arrays .asList (getClass ().getResource ("tsschecker" ).getPath (), "-d" , device , "-i" , "11.4" , "- s" , "-e" , ecidField .getText ()));
101+ ArrayList <String > args = new ArrayList <String >(Arrays .asList (getClass ().getResource ("tsschecker" ).getPath (), "-d" , device , "-s" , "-e" , ecidField .getText ()));
70102 if (boardConfig ) {
71103 args .add ("--boardconfig" );
72104 args .add (boardConfigField .getText ());
@@ -75,6 +107,12 @@ private void run(String device) {
75107 args .add ("--apnonce" );
76108 args .add (apnonceField .getText ());
77109 }
110+ if (versionCheckBox .isSelected ()) {
111+ args .add ("-l" );
112+ } else {
113+ args .add ("-i" );
114+ args .add (versionField .getText ());
115+ }
78116 Process proc = null ;
79117 try {
80118 proc = new ProcessBuilder (args ).start ();
@@ -105,6 +143,33 @@ public void apnonceCheckBoxHandler() {
105143 }
106144 }
107145
146+ public void versionCheckBoxHandler () {
147+ if (versionCheckBox .isSelected ()) {
148+ versionField .setDisable (true );
149+ } else {
150+ versionField .setDisable (false );
151+ }
152+ }
153+
154+ public void saveOptions () {
155+ Properties prop = new Properties ();
156+ File file = new File (getClass ().getResource ("" ).toString ().substring (5 ), "options.properties" );
157+ try (OutputStream output = new FileOutputStream (file )) {
158+ prop .setProperty ("ecid" , ecidField .getText ());
159+ prop .setProperty ("deviceType" , (String ) deviceTypeChoiceBox .getValue ());
160+ prop .setProperty ("deviceModel" , (String ) deviceModelChoiceBox .getValue ());
161+ if (boardConfig ) {
162+ prop .setProperty ("boardConfig" , boardConfigField .getText ());
163+ } else {
164+ prop .setProperty ("boardConfig" , "none" );
165+ }
166+ prop .store (output , null );
167+ } catch (IOException e ) {
168+ e .printStackTrace ();
169+ }
170+
171+ }
172+
108173
109174 public void go () {
110175 if (ecidField .getText ().equals ("" ) || deviceModelChoiceBox .getValue ().equals ("" ) || (boardConfig && boardConfigField .getText ().equals ("" )) || (apnonceCheckBox .isSelected () && apnonceField .getText ().equals ("" ))) {
0 commit comments