4848import java .util .stream .Collectors ;
4949
5050import static com .airsquared .blobsaver .Main .appPrefs ;
51- import static com .airsquared .blobsaver .Shared .checkForUpdates ;
52- import static com .airsquared .blobsaver .Shared .executeProgram ;
53- import static com .airsquared .blobsaver .Shared .githubIssue ;
54- import static com .airsquared .blobsaver .Shared .redditPM ;
55- import static com .airsquared .blobsaver .Shared .reportError ;
56- import static com .airsquared .blobsaver .Shared .resizeAlertButtons ;
51+ import static com .airsquared .blobsaver .Main .appVersion ;
52+ import static com .airsquared .blobsaver .Main .primaryStage ;
53+ import static com .airsquared .blobsaver .Shared .*;
5754
5855class Background {
5956
@@ -85,17 +82,10 @@ static void startBackground(boolean runOnlyOnce) {
8582 return ;
8683 }
8784 if (!runOnlyOnce && Platform .isFxApplicationThread ()) {
88- Main . primaryStage .hide ();
85+ primaryStage .hide ();
8986 Notification .Notifier .INSTANCE .setPopupLifetime (Duration .seconds (30 ));
9087 Notification .Notifier .INSTANCE .notifyInfo ("Background process has started" , "Check your system tray/status bar for\n the icon."
9188 + presetsToSaveNames .toString ().substring (1 , presetsToSaveNames .toString ().length () - 1 ));
92- } else if (!runOnlyOnce ) {
93- Platform .runLater (() -> {
94- Main .primaryStage .hide ();
95- Notification .Notifier .INSTANCE .setPopupLifetime (Duration .seconds (30 ));
96- Notification .Notifier .INSTANCE .notifyInfo ("Background process has started" , "Check your system tray/status bar for the icon.\n "
97- + presetsToSaveNames .toString ().substring (1 , presetsToSaveNames .toString ().length () - 1 ));
98- });
9989 }
10090 if (!runOnlyOnce ) {
10191 inBackground = true ;
@@ -110,12 +100,12 @@ static void startBackground(boolean runOnlyOnce) {
110100 }
111101
112102 //noinspection ConstantConditions
113- trayIcon = new TrayIcon (image , "blobsaver " + Main . appVersion );
103+ trayIcon = new TrayIcon (image , "blobsaver " + appVersion );
114104 trayIcon .setImageAutoSize (true );
115105
116106 MenuItem openItem = new MenuItem ("Open window" );
117107 openItem .addActionListener ((evt ) -> Platform .runLater (Background ::showStage ));
118- openItem .setFont (Font .decode (null ).deriveFont (java . awt . Font .BOLD )); // bold it
108+ openItem .setFont (Font .decode (null ).deriveFont (Font .BOLD )); // bold it
119109
120110 MenuItem exitItem = new MenuItem ("Quit" );
121111 exitItem .addActionListener (event -> {
@@ -132,7 +122,6 @@ static void startBackground(boolean runOnlyOnce) {
132122 popup .add (exitItem );
133123 trayIcon .setPopupMenu (popup );
134124
135-
136125 // add the application tray icon to the system tray.
137126 try {
138127 tray .add (trayIcon );
@@ -182,17 +171,17 @@ static void startBackground(boolean runOnlyOnce) {
182171 private static void saveBackgroundBlobs (int preset ) {
183172 log ("attempting to save for " + preset );
184173 Preferences presetPrefs = Preferences .userRoot ().node ("airsquared/blobsaver/preset" + preset );
185- // presetPrefs.put("Saved Versions", "[]"); // for testing
174+ // presetPrefs.put("Saved Versions", "[]"); // for testing
186175 String identifier ;
187- if (presetPrefs .get ("Device Model" , "" ). equals ( "none" )) {
176+ if ("none" . equals ( presetPrefs .get ("Device Model" , "" ))) {
188177 identifier = presetPrefs .get ("Device Identifier" , "" );
189178 } else {
190- identifier = Shared . textToIdentifier (presetPrefs .get ("Device Model" , "" ));
179+ identifier = textToIdentifier (presetPrefs .get ("Device Model" , "" ));
191180 }
192181 log ("identifier:" + identifier );
193182 String response ;
194183 try {
195- response = Shared . makeRequest (new URL ("https://api.ipsw.me/v4/device/" + identifier ));
184+ response = makeRequest (new URL ("https://api.ipsw.me/v4/device/" + identifier ));
196185 } catch (IOException e ) {
197186 Notification notification = new Notification ("Saving blobs failed" , "Check your internet connection.\n If it is working, click here to report this error." , Notification .ERROR_ICON );
198187 Notification .Notifier .INSTANCE .setPopupLifetime (Duration .minutes (1 ));
@@ -234,10 +223,10 @@ private static void saveBackgroundBlobs(int preset) {
234223 String ecid = presetPrefs .get ("ECID" , "" );
235224 String path = presetPrefs .get ("Path" , "" );
236225 String boardConfig = presetPrefs .get ("Board Config" , "" );
237- versionsToSave . forEach (( version ) -> {
226+ for ( String version : versionsToSave ) {
238227 File tsschecker ;
239228 try {
240- tsschecker = Shared . getTsschecker ();
229+ tsschecker = getTsschecker ();
241230 } catch (IOException e ) {
242231 Notification notification = new Notification ("Saving blobs failed" , "There was an error creating tsschecker. Click here to report this error." , Notification .ERROR_ICON );
243232 Notification .Notifier .INSTANCE .setPopupLifetime (Duration .minutes (1 ));
@@ -253,7 +242,7 @@ private static void saveBackgroundBlobs(int preset) {
253242 reportError (alert , e .getMessage ());
254243 });
255244 Notification .Notifier .INSTANCE .notify (notification );
256- return ;
245+ continue ;
257246 }
258247
259248 //noinspection ResultOfMethodCallIgnored
@@ -282,30 +271,29 @@ private static void saveBackgroundBlobs(int preset) {
282271 reportError (alert , e .getMessage ());
283272 });
284273 Notification .Notifier .INSTANCE .notify (notification );
285- return ;
274+ continue ;
286275 }
287276 String presetName ;
288- if (appPrefs .get ("Name Preset" + preset , "" ). equals ( "" )) {
277+ if ("" . equals ( appPrefs .get ("Name Preset" + preset , "" ))) {
289278 presetName = "Preset " + preset ;
290279 } else {
291280 presetName = appPrefs .get ("Name Preset" + preset , "" );
292281 }
293282 if (tsscheckerLog .contains ("Saved shsh blobs" )) {
294- Platform .runLater (() -> {
295- Notification notification = new Notification ("Successfully saved blobs for" , "iOS " + version + " (" + presetName + ") in\n " + path , Notification .SUCCESS_ICON );
296- Notification .Notifier .INSTANCE .setPopupLifetime (Duration .seconds (30 ));
297- Notification .Notifier .INSTANCE .setOnNotificationPressed ((event ) -> {
298- Notification .Notifier .INSTANCE .stop ();
299- showStage ();
300- Alert alert = new Alert (Alert .AlertType .INFORMATION , "Successfully saved blobs in\n " + path , ButtonType .OK );
301- alert .setTitle ("Success" );
302- alert .setHeaderText ("Success!" );
303- resizeAlertButtons (alert );
304- alert .showAndWait ();
305- alert .getDialogPane ().toFront ();
306- });
307- Notification .Notifier .INSTANCE .notify (notification );
283+ Notification notification = new Notification ("Successfully saved blobs for" , "iOS " + version + " (" + presetName + ") in\n " + path , Notification .SUCCESS_ICON );
284+ Notification .Notifier .INSTANCE .setPopupLifetime (Duration .seconds (30 ));
285+ Notification .Notifier .INSTANCE .setOnNotificationPressed ((event ) -> {
286+ Notification .Notifier .INSTANCE .stop ();
287+ showStage ();
288+ Alert alert = new Alert (Alert .AlertType .INFORMATION , "Successfully saved blobs in\n " + path , ButtonType .OK );
289+ alert .setTitle ("Success" );
290+ alert .setHeaderText ("Success!" );
291+ resizeAlertButtons (alert );
292+ alert .showAndWait ();
293+ alert .getDialogPane ().toFront ();
308294 });
295+ Notification .Notifier .INSTANCE .notify (notification );
296+
309297 log ("displayed message" );
310298
311299 } else if (tsscheckerLog .contains ("[Error] ERROR: TSS request failed: Could not resolve host:" )) {
@@ -324,7 +312,7 @@ private static void saveBackgroundBlobs(int preset) {
324312 });
325313 Notification .Notifier .INSTANCE .notify (notification );
326314 } else if (tsscheckerLog .contains ("iOS " + version + " for device " + identifier + " IS NOT being signed" )) {
327- return ;
315+ continue ;
328316 } else {
329317 Notification notification = new Notification ("Saving blobs failed" , "An unknown error occurred. Click here to report this error." , Notification .ERROR_ICON );
330318 Notification .Notifier .INSTANCE .setPopupLifetime (Duration .minutes (1 ));
@@ -343,13 +331,13 @@ private static void saveBackgroundBlobs(int preset) {
343331 savedVersions .add (version );
344332 presetPrefs .put ("Saved Versions" , new JSONArray (savedVersions ).toString ());
345333 log ("it worked" );
346- });
334+ }
347335 }
348336
349337 private static void showStage () {
350- Main . primaryStage .show ();
351- Main . primaryStage .toFront ();
352- Main . primaryStage .requestFocus ();
338+ primaryStage .show ();
339+ primaryStage .toFront ();
340+ primaryStage .requestFocus ();
353341 }
354342
355343 static void stopBackground (boolean showAlert ) {
0 commit comments