Skip to content

Commit a722623

Browse files
committed
Minor code cleanup
1 parent bffd354 commit a722623

File tree

9 files changed

+25
-40
lines changed

9 files changed

+25
-40
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ Carthage/Build
8989
# Gradle
9090
.idea/**/gradle.xml
9191
.idea/**/libraries
92+
.idea/**/jarRepositories.xml
9293

9394
# CMake
9495
cmake-build-debug/

.idea/compiler.xml

Lines changed: 1 addition & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules/blobsaver.main.iml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules/blobsaver.test.iml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/java/com/airsquared/blobsaver/Background.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,9 @@ static void startBackground(boolean runOnlyOnce) {
148148
case "Hours":
149149
timeUnit = TimeUnit.HOURS;
150150
break;
151-
case "Days":
152-
timeUnit = TimeUnit.DAYS;
153-
break;
154151
case "Weeks":
155-
timeUnit = TimeUnit.DAYS;
156-
timeAmount = timeAmount * 7;
157-
break;
152+
timeAmount *= 7;
153+
case "Days":
158154
default:
159155
timeUnit = TimeUnit.DAYS;
160156
break;

src/main/java/com/airsquared/blobsaver/Controller.java

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public class Controller {
5656

5757
@FXML private MenuBar menuBar;
5858

59-
@FXML private ChoiceBox deviceTypeChoiceBox, deviceModelChoiceBox;
59+
@FXML private ChoiceBox<String> deviceTypeChoiceBox, deviceModelChoiceBox;
6060

6161
@FXML TextField ecidField, boardConfigField, apnonceField, versionField, identifierField,
6262
pathField, ipswField, buildIDField;
@@ -80,8 +80,8 @@ public class Controller {
8080
private boolean editingPresets = false;
8181
private boolean choosingRunInBackground = false;
8282

83-
static DropShadow errorBorder = new DropShadow(9.5, 0f, 0f, Color.RED);
84-
private static DropShadow borderGlow = new DropShadow(9.5, 0f, 0f, Color.DARKCYAN);
83+
static final DropShadow errorBorder = new DropShadow(9.5, 0f, 0f, Color.RED);
84+
static final DropShadow borderGlow = new DropShadow(9.5, 0f, 0f, Color.DARKCYAN);
8585

8686
static Controller INSTANCE;
8787

@@ -95,14 +95,13 @@ static void afterStageShowing() {
9595
checkForUpdates(false);
9696
}
9797

98-
@SuppressWarnings("unchecked")
9998
@FXML
10099
public void initialize() {
101100
INSTANCE = this;
102101

103102
deviceTypeChoiceBox.getSelectionModel().selectedItemProperty().addListener((x, y, newValue) -> {
104103
deviceTypeChoiceBox.setEffect(null);
105-
switch ((String) (newValue == null ? "" : newValue)) {
104+
switch (newValue == null ? "" : newValue) {
106105
case "iPhone":
107106
deviceModelChoiceBox.setItems(Devices.getiPhones());
108107
versionLabel.setText("iOS Version");
@@ -127,10 +126,10 @@ public void initialize() {
127126
deviceTypeChoiceBox.setValue("iPhone");
128127
deviceModelChoiceBox.getSelectionModel().selectedItemProperty().addListener((x, y, newValue) -> {
129128
deviceModelChoiceBox.setEffect(null);
130-
if (Shared.isEmptyOrNull((String) newValue)) {
129+
if (Shared.isEmptyOrNull(newValue)) {
131130
return;
132131
}
133-
String identifier = Devices.getDeviceModelIdentifiersMap().get(newValue.toString());
132+
String identifier = Devices.getDeviceModelIdentifiersMap().get(newValue);
134133
requireBoardConfig(identifier);
135134
requireApnonce(identifier);
136135
});
@@ -236,7 +235,6 @@ public void versionCheckBoxHandler() {
236235
}
237236
}
238237

239-
@SuppressWarnings("unchecked")
240238
public void identifierCheckBoxHandler() {
241239
if (identifierCheckBox.isSelected()) {
242240
identifierField.setDisable(false);
@@ -295,7 +293,6 @@ public void filePickerHandler() {
295293
}
296294
}
297295

298-
@SuppressWarnings("unchecked")
299296
private void loadPreset(int preset) {
300297
Preferences prefs = Preferences.userRoot().node("airsquared/blobsaver/preset" + preset);
301298
if (!prefs.getBoolean("Exists", false)) {
@@ -370,7 +367,7 @@ public void presetButtonHandler(ActionEvent evt) {
370367
@SuppressWarnings("Duplicates")
371368
private void savePreset(int preset) {
372369
boolean doReturn = false;
373-
if (!identifierCheckBox.isSelected() && Shared.isEmptyOrNull((String) deviceModelChoiceBox.getValue())) {
370+
if (!identifierCheckBox.isSelected() && Shared.isEmptyOrNull(deviceModelChoiceBox.getValue())) {
374371
deviceModelChoiceBox.setEffect(errorBorder);
375372
doReturn = true;
376373
}
@@ -404,8 +401,8 @@ private void savePreset(int preset) {
404401
presetPrefs.put("Device Model", "none");
405402
presetPrefs.put("Device Identifier", identifierField.getText());
406403
} else {
407-
presetPrefs.put("Device Type", (String) deviceTypeChoiceBox.getValue());
408-
presetPrefs.put("Device Model", (String) deviceModelChoiceBox.getValue());
404+
presetPrefs.put("Device Type", deviceTypeChoiceBox.getValue());
405+
presetPrefs.put("Device Model", deviceModelChoiceBox.getValue());
409406
}
410407
if (getBoardConfig) {
411408
presetPrefs.put("Board Config", boardConfigField.getText());
@@ -796,7 +793,6 @@ public void showWiki() {
796793
openURL("https://github.com/airsquared/blobsaver/wiki");
797794
}
798795

799-
@SuppressWarnings("unchecked")
800796
public void readInfo() {
801797
if (!PlatformUtil.isMac() && !PlatformUtil.isWindows()) {
802798
Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
@@ -895,11 +891,11 @@ public void readApnonce() {
895891
@SuppressWarnings("Duplicates")
896892
public void goButtonHandler() {
897893
boolean doReturn = false;
898-
if (!identifierCheckBox.isSelected() && Shared.isEmptyOrNull((String) deviceTypeChoiceBox.getValue())) {
894+
if (!identifierCheckBox.isSelected() && Shared.isEmptyOrNull(deviceTypeChoiceBox.getValue())) {
899895
deviceTypeChoiceBox.setEffect(errorBorder);
900896
doReturn = true;
901897
}
902-
if (!identifierCheckBox.isSelected() && Shared.isEmptyOrNull((String) deviceModelChoiceBox.getValue())) {
898+
if (!identifierCheckBox.isSelected() && Shared.isEmptyOrNull(deviceModelChoiceBox.getValue())) {
903899
deviceModelChoiceBox.setEffect(errorBorder);
904900
doReturn = true;
905901
}
@@ -913,7 +909,7 @@ public void goButtonHandler() {
913909
doReturn = doReturn || isTextFieldInvalid(betaCheckBox, ipswField);
914910
if (doReturn) return;
915911

916-
String deviceModel = (String) deviceModelChoiceBox.getValue();
912+
String deviceModel = deviceModelChoiceBox.getValue();
917913
if (Shared.isEmptyOrNull(deviceModel)) {
918914
String identifierText = identifierField.getText();
919915
try {

src/main/java/com/airsquared/blobsaver/Libimobiledevice.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -180,17 +180,10 @@ public static class Libirecovery {
180180
@SuppressWarnings({"unused", "SpellCheckingInspection"})
181181
@Structure.FieldOrder({"cpid", "cprv", "cpfm", "scep", "bdid", "ecid", "ibfl", "srnm", "imei", "srtg", "serial_string", "ap_nonce", "ap_nonce_size", "sep_nonce", "sep_nonce_size"})
182182
public static class irecv_device_info extends Structure {
183-
public int cpid;
184-
public int cprv;
185-
public int cpfm;
186-
public int scep;
187-
public int bdid;
183+
public int cpid, cprv, cpfm, scep, bdid;
188184
public long ecid;
189185
public int ibfl;
190-
public String srnm;
191-
public String imei;
192-
public String srtg;
193-
public String serial_string;
186+
public String srnm, imei, srtg, serial_string;
194187
public Pointer ap_nonce;
195188
public int ap_nonce_size;
196189
public Pointer sep_nonce;

src/main/java/com/airsquared/blobsaver/TSSChecker.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
* TODO: fix this class to separate GUI logic
4242
*/
4343
class TSSChecker {
44+
4445
static void run(String device) {
4546
Controller.INSTANCE.showRunningAlert();
4647
new Thread(() -> runImpl(device)).start();
@@ -228,7 +229,7 @@ && containsIgnoreCase(tsscheckerLog, "checking tss status failed")) {
228229
alert.showAndWait();
229230
reportError(alert, tsscheckerLog);
230231
} else if (containsIgnoreCase(tsscheckerLog, "can't save shsh at")) {
231-
newUnreportableError("\'" + savePath + "\' is not a valid path\n\nIf this was done to test whether the preset works in the background, please cancel that preset, fix the error, and try again.");
232+
newUnreportableError("'" + savePath + "' is not a valid path\n\nIf this was done to test whether the preset works in the background, please cancel that preset, fix the error, and try again.");
232233
controller.pathField.setEffect(errorBorder);
233234
} else if (containsIgnoreCase(tsscheckerLog, "IS NOT being signed")) {
234235
newUnreportableError("iOS/tvOS " + version + " is not being signed for device " + device);

0 commit comments

Comments
 (0)