diff --git a/src/main/java/com/airsquared/blobsaver/Background.java b/src/main/java/com/airsquared/blobsaver/Background.java index d1e9185b..54df0478 100644 --- a/src/main/java/com/airsquared/blobsaver/Background.java +++ b/src/main/java/com/airsquared/blobsaver/Background.java @@ -128,14 +128,14 @@ static void startBackground(boolean runOnlyOnce) { // add the application tray icon to the system tray. try { tray.add(trayIcon); - log("in tray"); + System.out.println("in tray"); } catch (AWTException e) { e.printStackTrace(); } } if (runOnlyOnce) { if (!presetsToSave.isEmpty()) { - log("there are some presets to save"); + System.out.println("there are some presets to save"); presetsToSave.forEach(Background::saveBackgroundBlobs); } inBackground = false; @@ -162,17 +162,17 @@ static void startBackground(boolean runOnlyOnce) { } executor.scheduleAtFixedRate(() -> { if (!presetsToSave.isEmpty()) { - log("there are some presets to save"); + System.out.println("there are some presets to save"); presetsToSave.forEach(Background::saveBackgroundBlobs); } - log("done w execution of executor"); + System.out.println("done with executor"); }, 0, timeAmount, timeUnit); executor.scheduleAtFixedRate(() -> checkForUpdates(false), 4, 4, TimeUnit.DAYS); } } private static void saveBackgroundBlobs(int preset) { - log("attempting to save for preset " + preset); + System.out.println("attempting to save for preset " + preset); Preferences presetPrefs = Preferences.userRoot().node("airsquared/blobsaver/preset" + preset); String identifier; if ("none".equals(presetPrefs.get("Device Model", ""))) { @@ -180,7 +180,6 @@ private static void saveBackgroundBlobs(int preset) { } else { identifier = textToIdentifier(presetPrefs.get("Device Model", "")); } - log("identifier:" + identifier); List> signedFirmwares; try { signedFirmwares = getAllSignedFirmwares(identifier); @@ -259,7 +258,7 @@ private static void saveBackgroundBlobs(int preset) { }); Notification.Notifier.INSTANCE.notify(notification); - log("displayed message"); + System.out.println("displayed message"); } else if (containsIgnoreCase(tsscheckerLog, "Could not resolve host")) { Notification notification = new Notification("Saving blobs failed", "Check your internet connection. If it is working, click here to report this error.", Notification.ERROR_ICON); @@ -293,7 +292,7 @@ private static void saveBackgroundBlobs(int preset) { }); Notification.Notifier.INSTANCE.notify(notification); } - log("it worked"); + System.out.println("Success"); } } @@ -313,10 +312,6 @@ static void stopBackground(boolean showAlert) { alert.showAndWait(); }); } - log("stopped background"); - } - - private static void log(String msg) { - System.out.println(msg); + System.out.println("Stopped background"); } } \ No newline at end of file diff --git a/src/main/java/com/airsquared/blobsaver/Controller.java b/src/main/java/com/airsquared/blobsaver/Controller.java index c8691adb..6848aa2f 100644 --- a/src/main/java/com/airsquared/blobsaver/Controller.java +++ b/src/main/java/com/airsquared/blobsaver/Controller.java @@ -98,8 +98,8 @@ public class Controller { private boolean editingPresets = false; private boolean choosingRunInBackground = false; - static DropShadow errorBorder = new DropShadow(); - private static DropShadow borderGlow = new DropShadow(); + static DropShadow errorBorder = new DropShadow(9.5, 0f, 0f, Color.RED); + private static DropShadow borderGlow = new DropShadow(9.5, 0f, 0f, Color.DARKCYAN); static Controller INSTANCE; @@ -117,19 +117,6 @@ static void afterStageShowing() { @FXML public void initialize() { INSTANCE = this; - // create effects - borderGlow.setOffsetY(0f); - borderGlow.setOffsetX(0f); - borderGlow.setColor(Color.DARKCYAN); - borderGlow.setWidth(20); - borderGlow.setHeight(20); - errorBorder.setOffsetY(0f); - errorBorder.setOffsetX(0f); - errorBorder.setColor(Color.RED); - errorBorder.setWidth(20); - errorBorder.setHeight(20); - - deviceTypeChoiceBox.setItems(FXCollections.observableArrayList(Devices.getDeviceTypes())); deviceTypeChoiceBox.getSelectionModel().selectedItemProperty().addListener((x, y, newValue) -> { deviceTypeChoiceBox.setEffect(null); @@ -170,20 +157,8 @@ public void initialize() { presetButtons = new ArrayList<>(Arrays.asList(preset1Button, preset2Button, preset3Button, preset4Button, preset5Button, preset6Button, preset7Button, preset8Button, preset9Button, preset10Button)); presetButtons.forEach(btn -> btn.setOnAction(this::presetButtonHandler)); - // the following is to set the path to save blobs to the correct location - String path = Main.jarDirectory.getAbsolutePath(); - if (path.endsWith("blobsaver.app/Contents/Java")) { - path = path.replaceAll("blobsaver\\.app/Contents/Java", ""); - } - if (path.contains("\\Program Files") || path.contains("/Applications")) { - path = System.getProperty("user.home"); - } - if (path.endsWith(System.getProperty("file.separator"))) { - path = path + "Blobs"; - } else { - path = path + System.getProperty("file.separator") + "Blobs"; - } - pathField.setText(path); + + pathField.setText(new File(System.getProperty("user.home"), "Blobs").getAbsolutePath()); if (PlatformUtil.isMac()) { @@ -250,7 +225,6 @@ public void versionCheckBoxHandler() { versionField.setText(""); } else { versionField.setEffect(borderGlow); - versionField.setDisable(false); } } @@ -367,12 +341,12 @@ private void presetButtonHandler(ActionEvent evt) { if (presetsToSaveFor.isEmpty()) { appPrefs.putBoolean("Background setup", false); } - log("removed " + preset + " from list"); + System.out.println("removed " + preset + " from list"); backgroundSettingsButton.fire(); } else { presetsToSaveFor.add(Integer.toString(preset)); appPrefs.putBoolean("Background setup", true); - log("added preset" + preset + " to list"); + System.out.println("added preset" + preset + " to list"); Alert alert = new Alert(Alert.AlertType.INFORMATION, "If it doesn't work, please remove it, fix the error, and add it back"); alert.setTitle("Testing preset " + preset); alert.setHeaderText("Testing preset"); @@ -657,7 +631,7 @@ private void useMacOSMenuBar() { // needs to be run with Platform.runLater(), otherwise the application menu doesn't show up Platform.runLater(() -> tk.setGlobalMenuBar(macOSMenuBar)); - log("using macOS menu bar"); + System.out.println("using macOS menu bar"); } public void backgroundSettingsHandler() { @@ -733,11 +707,9 @@ public void chooseTimeToRunHandler() { alert.getDialogPane().setContent(hBox); alert.showAndWait(); if ((alert.getResult() != null) && !ButtonType.CANCEL.equals(alert.getResult()) && !"".equals(textField.getText()) && (choiceBox.getValue() != null)) { - log("info given"); appPrefs.putInt("Time to run", Integer.parseInt(textField.getText())); appPrefs.put("Time unit for background", choiceBox.getValue()); } else { - log("alert menu canceled"); backgroundSettingsButton.fire(); //goes back to main menu return; } @@ -797,8 +769,6 @@ public void resetAppHandler() { prefs.clear(); prefs.removeNode(); prefs.flush(); - File blobsaver_bin = new File(System.getProperty("user.home"), ".blobsaver_bin"); - deleteFolder(blobsaver_bin); Alert applicationCloseAlert = new Alert(Alert.AlertType.INFORMATION, "The application data and files have been removed. If you are running Windows, you still will need to run the uninstall .exe. Otherwise, you can just delete the .app or .jar file.\nThe application will now exit.", ButtonType.OK); applicationCloseAlert.showAndWait(); Platform.exit(); @@ -807,22 +777,6 @@ public void resetAppHandler() { } } - @SuppressWarnings("ResultOfMethodCallIgnored") - private static void deleteFolder(File folder) { - if (folder.exists()) { - File[] files = folder.listFiles(); - if (files != null) { - Arrays.asList(files).forEach(file -> { - if (file.isDirectory()) { - deleteFolder(file); - } else { - file.delete(); - } - }); - } - } - } - public void debugLogHandler() { if (DebugWindow.isShowing()) { DebugWindow.hide(); @@ -907,8 +861,6 @@ public void readInfo() { public void donate() { openURL("https://www.paypal.me/airsqrd"); } - private static void log(String msg) { System.out.println(msg); } - @SuppressWarnings("Duplicates") public void goButtonHandler() { boolean doReturn = false; @@ -928,22 +880,20 @@ public void goButtonHandler() { doReturn = doReturn || isTextFieldInvalid(!versionCheckBox.isSelected(), versionField); doReturn = doReturn || isTextFieldInvalid(betaCheckBox, buildIDField); doReturn = doReturn || isTextFieldInvalid(betaCheckBox, ipswField); - if (doReturn) { - return; - } + if (doReturn) return; + String deviceModel = (String) deviceModelChoiceBox.getValue(); if ("".equals(deviceModel)) { String identifierText = identifierField.getText(); try { if (identifierText.startsWith("iPad") || identifierText.startsWith("iPod") || identifierText.startsWith("iPhone") || identifierText.startsWith("AppleTV")) { TSSChecker.run(identifierText); - } else { - identifierField.setEffect(errorBorder); - newUnreportableError("\"" + identifierText + "\" is not a valid identifier"); + return; } - } catch (StringIndexOutOfBoundsException e) { - newUnreportableError("\"" + identifierText + "\" is not a valid identifier"); + } catch (StringIndexOutOfBoundsException ignored) { } + identifierField.setEffect(errorBorder); + newUnreportableError("\"" + identifierText + "\" is not a valid identifier"); } else { TSSChecker.run(textToIdentifier(deviceModel)); } diff --git a/src/main/java/com/airsquared/blobsaver/Devices.java b/src/main/java/com/airsquared/blobsaver/Devices.java index 6e4c9625..b973ebcf 100644 --- a/src/main/java/com/airsquared/blobsaver/Devices.java +++ b/src/main/java/com/airsquared/blobsaver/Devices.java @@ -26,7 +26,7 @@ import java.util.Map; import java.util.Properties; -class Devices { +public class Devices { private static final ObservableList iPhones = FXCollections.observableArrayList("iPhone 3G[S]", "iPhone 4 (GSM)", "iPhone 4 (GSM 2012)", "iPhone 4 (CDMA)", "iPhone 4[S]", "iPhone 5 (GSM)", "iPhone 5 (Global)", @@ -91,7 +91,7 @@ static ObservableList getAppleTVs() { return AppleTVs; } - static ObservableList getDeviceTypes() { + public static ObservableList getDeviceTypes() { return deviceTypes; } diff --git a/src/main/java/com/airsquared/blobsaver/Main.java b/src/main/java/com/airsquared/blobsaver/Main.java index 970740e8..2da966fc 100644 --- a/src/main/java/com/airsquared/blobsaver/Main.java +++ b/src/main/java/com/airsquared/blobsaver/Main.java @@ -95,17 +95,13 @@ static void showStage() { if (PlatformUtil.isMac()) { DockVisibility.show(); } - System.out.println(1); try { primaryStage.show(); } catch (Throwable t) { t.printStackTrace(); } - System.out.println(2); primaryStage.centerOnScreen(); - System.out.println(3); primaryStage.requestFocus(); - System.out.println(4); } static void hideStage() { @@ -153,7 +149,13 @@ public void init() { @SuppressWarnings("unchecked") public void start(Stage primaryStage) throws IOException, ReflectiveOperationException { Main.primaryStage = primaryStage; - Parent root = FXMLLoader.load(getClass().getResource("blobsaver.fxml")); + Parent root = null; + try { + root = FXMLLoader.load(getClass().getResource("blobsaver.fxml")); + } catch (Exception e) { + e.printStackTrace(); + System.exit(-1); + } primaryStage.setTitle("blobsaver " + Main.appVersion); primaryStage.setScene(new Scene(root)); primaryStage.getScene().getStylesheets().add(getClass().getResource("app.css").toExternalForm()); diff --git a/src/main/resources/com/airsquared/blobsaver/blobsaver.fxml b/src/main/resources/com/airsquared/blobsaver/blobsaver.fxml index c4970dce..147836cc 100644 --- a/src/main/resources/com/airsquared/blobsaver/blobsaver.fxml +++ b/src/main/resources/com/airsquared/blobsaver/blobsaver.fxml @@ -18,6 +18,7 @@ ~ along with blobsaver. If not, see . --> + @@ -119,6 +120,9 @@ + + +