Skip to content

Commit

Permalink
Save apnonces in presets
Browse files Browse the repository at this point in the history
  • Loading branch information
airsquared committed Feb 9, 2019
1 parent d9a4fbe commit caae074
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 28 deletions.
15 changes: 10 additions & 5 deletions src/main/java/com/airsquared/blobsaver/Background.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Executors;
Expand Down Expand Up @@ -223,6 +224,7 @@ private static void saveBackgroundBlobs(int preset) {
String ecid = presetPrefs.get("ECID", "");
String path = presetPrefs.get("Path", "");
String boardConfig = presetPrefs.get("Board Config", "");
String apnonce = presetPrefs.get("Apnonce", "");
for (String version : versionsToSave) {
File tsschecker;
try {
Expand All @@ -249,13 +251,16 @@ private static void saveBackgroundBlobs(int preset) {
new File(path).mkdirs();
String tsscheckerLog;
try {
ArrayList<String> args = new ArrayList<>();
Collections.addAll(args, tsschecker.getPath(), "--generator", "0x1111111111111111", "--nocache", "-d", identifier, "-s", "-e", ecid,
"--save-path", path, "-i", version);
if (!"none".equals(boardConfig) && !"".equals(boardConfig)) { // needs board config
tsscheckerLog = executeProgram(tsschecker.getPath(), "--generator", "0x1111111111111111", "--nocache", "-d", identifier, "-s", "-e", ecid,
"--save-path", path, "-i", version, "--boardconfig", boardConfig);
} else {
tsscheckerLog = executeProgram(tsschecker.getPath(), "--generator", "0x1111111111111111", "--nocache", "-d", identifier, "-s", "-e", ecid,
"--save-path", path, "-i", version);
Collections.addAll(args, "--boardconfig", boardConfig);
}
if (!"".equals(apnonce)) {
Collections.addAll(args, "--apnonce", apnonce);
}
tsscheckerLog = executeProgram(args.toArray(new String[0]));
} catch (IOException e) {
Notification notification = new Notification("Saving blobs failed", "There was an error starting tsschecker. Click here to report this error.", Notification.ERROR_ICON);
Notification.Notifier.INSTANCE.setPopupLifetime(Duration.minutes(1));
Expand Down
51 changes: 28 additions & 23 deletions src/main/java/com/airsquared/blobsaver/Controller.java
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,16 @@ private void loadPreset(int preset) {
if (!"none".equals(prefs.get("Board Config", ""))) {
boardConfigField.setText(prefs.get("Board Config", ""));
}
if (!"".equals(prefs.get("Apnonce", ""))) {
if (!apnonceCheckBox.isSelected()) {
apnonceCheckBox.fire();
}
apnonceField.setText(prefs.get("Apnonce", ""));
} else {
if (apnonceCheckBox.isSelected()) {
apnonceCheckBox.fire();
}
}
}

private void presetButtonHandler(ActionEvent evt) {
Expand Down Expand Up @@ -520,22 +530,14 @@ private void presetButtonHandler(ActionEvent evt) {
@SuppressWarnings("Duplicates")
private void savePreset(int preset) {
boolean doReturn = false;
if ("".equals(ecidField.getText())) {
ecidField.setEffect(errorBorder);
doReturn = true;
}
if (!identifierCheckBox.isSelected() && "".equals(deviceModelChoiceBox.getValue())) {
deviceModelChoiceBox.setEffect(errorBorder);
doReturn = true;
}
if (identifierCheckBox.isSelected() && "".equals(identifierField.getText())) {
identifierField.setEffect(errorBorder);
doReturn = true;
}
if (getBoardConfig && "".equals(boardConfigField.getText())) {
boardConfigField.setEffect(errorBorder);
doReturn = true;
}
doReturn = doReturn || isTextFieldInvalid(true, ecidField);
doReturn = doReturn || isTextFieldInvalid(identifierCheckBox, identifierField);
doReturn = doReturn || isTextFieldInvalid(getBoardConfig, boardConfigField);
doReturn = doReturn || isTextFieldInvalid(apnonceCheckBox, apnonceField);
if (doReturn) {
return;
}
Expand Down Expand Up @@ -570,6 +572,9 @@ private void savePreset(int preset) {
} else {
presetPrefs.put("Board Config", "none");
}
if (apnonceCheckBox.isSelected()) {
presetPrefs.put("Apnonce", apnonceField.getText());
}
}

public void savePresetHandler() {
Expand Down Expand Up @@ -1201,14 +1206,14 @@ public void goButtonHandler() {
deviceModelChoiceBox.setEffect(errorBorder);
doReturn = true;
}
doReturn = doReturn || isTextFieldValid(true, ecidField);
doReturn = doReturn || isTextFieldValid(identifierCheckBox, identifierField);
doReturn = doReturn || isTextFieldValid(getBoardConfig, boardConfigField);
doReturn = doReturn || isTextFieldValid(apnonceCheckBox, apnonceField);
doReturn = doReturn || isTextFieldValid(true, pathField);
doReturn = doReturn || isTextFieldValid(!versionCheckBox.isSelected(), versionField);
doReturn = doReturn || isTextFieldValid(betaCheckBox, buildIDField);
doReturn = doReturn || isTextFieldValid(betaCheckBox, ipswField);
doReturn = doReturn || isTextFieldInvalid(true, ecidField);
doReturn = doReturn || isTextFieldInvalid(identifierCheckBox, identifierField);
doReturn = doReturn || isTextFieldInvalid(getBoardConfig, boardConfigField);
doReturn = doReturn || isTextFieldInvalid(apnonceCheckBox, apnonceField);
doReturn = doReturn || isTextFieldInvalid(true, pathField);
doReturn = doReturn || isTextFieldInvalid(!versionCheckBox.isSelected(), versionField);
doReturn = doReturn || isTextFieldInvalid(betaCheckBox, buildIDField);
doReturn = doReturn || isTextFieldInvalid(betaCheckBox, ipswField);
if (doReturn) {
return;
}
Expand All @@ -1230,11 +1235,11 @@ public void goButtonHandler() {
}
}

private static boolean isTextFieldValid(CheckBox checkBox, TextField textField) {
return isTextFieldValid(checkBox.isSelected(), textField);
private static boolean isTextFieldInvalid(CheckBox checkBox, TextField textField) {
return isTextFieldInvalid(checkBox.isSelected(), textField);
}

private static boolean isTextFieldValid(boolean isTextFieldRequired, TextField textField) {
private static boolean isTextFieldInvalid(boolean isTextFieldRequired, TextField textField) {
if (isTextFieldRequired && "".equals(textField.getText())) {
textField.setEffect(errorBorder);
return true;
Expand Down

0 comments on commit caae074

Please sign in to comment.