Skip to content

Commit f3fe7fc

Browse files
committed
Made UI better, Now tells user if missing a field
1 parent d090bae commit f3fe7fc

File tree

4 files changed

+229
-35
lines changed

4 files changed

+229
-35
lines changed

src/blobsaver/Controller.java

Lines changed: 110 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import javafx.event.ActionEvent;
77
import javafx.fxml.FXML;
88
import javafx.scene.control.*;
9+
import javafx.scene.effect.DropShadow;
10+
import javafx.scene.paint.Color;
911

1012
import java.io.*;
1113
import java.net.URISyntaxException;
@@ -18,42 +20,50 @@ public class Controller {
1820

1921
@FXML private ChoiceBox deviceTypeChoiceBox;
2022
@FXML private ChoiceBox deviceModelChoiceBox;
23+
2124
@FXML private TextField ecidField;
2225
@FXML private TextField boardConfigField;
2326
@FXML private TextField apnonceField;
2427
@FXML private TextField versionField;
2528
@FXML private TextField identifierField;
29+
2630
@FXML private CheckBox apnonceCheckBox;
2731
@FXML private CheckBox versionCheckBox;
2832
@FXML private CheckBox identifierCheckBox;
33+
2934
@FXML private Label versionLabel;
35+
3036
@FXML private Button preset1Button;
3137
@FXML private Button preset2Button;
3238
@FXML private Button preset3Button;
39+
@FXML private Button goButton;
40+
3341
private boolean boardConfig = false;
3442
private boolean editingPresets = false;
3543

44+
private DropShadow errorBorder = new DropShadow();
45+
3646
@SuppressWarnings("unchecked")
3747
@FXML
3848
public void initialize() {
39-
ObservableList iPhones = FXCollections.observableArrayList("iPhone 3G[S]", "iPhone 4 (GSM)",
49+
final ObservableList iPhones = FXCollections.observableArrayList("iPhone 3G[S]", "iPhone 4 (GSM)",
4050
"iPhone 4 (GSM 2012)", "iPhone 4 (CDMA)", "iPhone 4[S]", "iPhone 5 (GSM)", "iPhone 5 (Global)",
4151
"iPhone 5c (GSM)", "iPhone 5c (Global)", "iPhone 5s (GSM)", "iPhone 5s (Global)",
4252
"iPhone 6+ ", "iPhone 6", "iPhone 6s", "iPhone 6s+", "iPhone SE", "iPhone 7 (Global)(iPhone9,1)",
4353
"iPhone 7+ (Global)(iPhone9,2)", "iPhone 7 (GSM)(iPhone9,3)", "iPhone 7+ (GSM)(iPhone9,4)",
4454
"iPhone 8 (iPhone10,1)", "iPhone 8+ (iPhone10,2)", "iPhone X (iPhone10,3)", "iPhone 8 (iPhone10,4)",
4555
"iPhone 8+ (iPhone10,5)", "iPhone X (iPhone10,6)", "");
46-
ObservableList iPods = FXCollections.observableArrayList("iPod Touch 3", "iPod Touch 4", "iPod Touch 5", "iPod Touch 6", "");
47-
ObservableList iPads = FXCollections.observableArrayList("iPad 1", "iPad 2 (WiFi)", "iPad 2 (GSM)",
56+
final ObservableList iPods = FXCollections.observableArrayList("iPod Touch 3", "iPod Touch 4", "iPod Touch 5", "iPod Touch 6", "");
57+
final ObservableList iPads = FXCollections.observableArrayList("iPad 1", "iPad 2 (WiFi)", "iPad 2 (GSM)",
4858
"iPad 2 (CDMA)", "iPad 2 (Mid 2012)", "iPad Mini (Wifi)", "iPad Mini (GSM)", "iPad Mini (Global)",
4959
"iPad 3 (WiFi)", "iPad 3 (CDMA)", "iPad 3 (GSM)", "iPad 4 (WiFi)", "iPad 4 (GSM)", "iPad 4 (Global)",
5060
"iPad Air (Wifi)", "iPad Air (Cellular)", "iPad Air (China)", "iPad Mini 2 (WiFi)", "iPad Mini 2 (Cellular)",
5161
"iPad Mini 2 (China)", "iPad Mini 3 (WiFi)", "iPad Mini 3 (Cellular)", "iPad Mini 3 (China)",
5262
"iPad Mini 4 (Wifi)", "iPad Mini 4 (Cellular)", "iPad Air 2 (WiFi)", "iPad Air 2 (Cellular)",
5363
"iPad Pro 9.7 (Wifi)", "iPad Pro 9.7 (Cellular)", "iPad Pro 12.9 (WiFi)", "iPad Pro 12.9 (Cellular)",
5464
"iPad 5 (Wifi)", "iPad 5 (Cellular)", "iPad Pro 2 12.9 (WiFi)(iPad7,1)", "iPad Pro 2 12.9 (Cellular)(iPad7,2)",
55-
"iPad Pro 10.5 (WiFi)(iPad7,3)", "iPad 10.5 (Cellular)(iPad7,4)", "iPad 6 (WiFi)(iPad 7,5)", "iPad 6 (Cellular)(iPad7,6)");
56-
ObservableList AppleTVs = FXCollections.observableArrayList("Apple TV 2G", "Apple TV 3", "Apple TV 3 (2013)", "Apple TV 4 (2015)", "Apple TV 4K", "");
65+
"iPad Pro 10.5 (WiFi)(iPad7,3)", "iPad 10.5 (Cellular)(iPad7,4)", "iPad 6 (WiFi)(iPad 7,5)", "iPad 6 (Cellular)(iPad7,6)", "");
66+
final ObservableList AppleTVs = FXCollections.observableArrayList("Apple TV 2G", "Apple TV 3", "Apple TV 3 (2013)", "Apple TV 4 (2015)", "Apple TV 4K", "");
5767
deviceTypeChoiceBox.setItems(FXCollections.observableArrayList("iPhone", "iPod", "iPad", "AppleTV", ""));
5868

5969
deviceTypeChoiceBox.getSelectionModel().selectedItemProperty().addListener((ObservableValue observable, Object oldValue, Object newValue) -> {
@@ -80,9 +90,18 @@ public void initialize() {
8090
deviceModelChoiceBox.getSelectionModel().selectedItemProperty().addListener((ObservableValue observable, Object oldValue, Object newValue) -> {
8191
String v = (String) newValue;
8292
if (v.equals("iPhone 6s") || v.equals("iPhone 6s+") || v.equals("iPhone SE")) {
93+
int depth = 20;
94+
DropShadow borderGlow = new DropShadow();
95+
borderGlow.setOffsetY(0f);
96+
borderGlow.setOffsetX(0f);
97+
borderGlow.setColor(Color.DARKCYAN);
98+
borderGlow.setWidth(depth);
99+
borderGlow.setHeight(depth);
100+
boardConfigField.setEffect(borderGlow);
83101
boardConfig = true;
84102
boardConfigField.setDisable(false);
85103
} else {
104+
boardConfigField.setEffect(null);
86105
boardConfig = false;
87106
boardConfigField.setText("");
88107
boardConfigField.setDisable(true);
@@ -91,14 +110,31 @@ public void initialize() {
91110
identifierField.textProperty().addListener((observable, oldValue, newValue) -> {
92111
String v = newValue;
93112
if (v.equals("iPhone8,1") || v.equals("iPhone8,2") || v.equals("iPhone8,4")) {
113+
int depth = 20;
114+
DropShadow borderGlow = new DropShadow();
115+
borderGlow.setOffsetY(0f);
116+
borderGlow.setOffsetX(0f);
117+
borderGlow.setColor(Color.DARKCYAN);
118+
borderGlow.setWidth(depth);
119+
borderGlow.setHeight(depth);
120+
boardConfigField.setEffect(borderGlow);
94121
boardConfig = true;
95122
boardConfigField.setDisable(false);
96123
} else {
124+
boardConfigField.setEffect(null);
97125
boardConfig = false;
98126
boardConfigField.setText("");
99127
boardConfigField.setDisable(true);
100128
}
101129
});
130+
goButton.setDefaultButton(true);
131+
132+
133+
errorBorder.setOffsetY(0f);
134+
errorBorder.setOffsetX(0f);
135+
errorBorder.setColor(Color.RED);
136+
errorBorder.setWidth(20);
137+
errorBorder.setHeight(20);
102138
}
103139

104140
private void run(String device) {
@@ -142,7 +178,16 @@ private void run(String device) {
142178
public void apnonceCheckBoxHandler() {
143179
if (apnonceCheckBox.isSelected()) {
144180
apnonceField.setDisable(false);
181+
int depth = 20;
182+
DropShadow borderGlow = new DropShadow();
183+
borderGlow.setOffsetY(0f);
184+
borderGlow.setOffsetX(0f);
185+
borderGlow.setColor(Color.DARKCYAN);
186+
borderGlow.setWidth(depth);
187+
borderGlow.setHeight(depth);
188+
apnonceField.setEffect(borderGlow);
145189
} else {
190+
apnonceField.setEffect(null);
146191
apnonceField.setText("");
147192
apnonceField.setDisable(true);
148193
}
@@ -151,19 +196,39 @@ public void apnonceCheckBoxHandler() {
151196
public void versionCheckBoxHandler() {
152197
if (versionCheckBox.isSelected()) {
153198
versionField.setDisable(true);
199+
versionField.setEffect(null);
200+
versionField.setText("");
154201
} else {
202+
int depth = 20;
203+
DropShadow borderGlow = new DropShadow();
204+
borderGlow.setOffsetY(0f);
205+
borderGlow.setOffsetX(0f);
206+
borderGlow.setColor(Color.DARKCYAN);
207+
borderGlow.setWidth(depth);
208+
borderGlow.setHeight(depth);
209+
versionField.setEffect(borderGlow);
210+
155211
versionField.setDisable(false);
156212
}
157213
}
158214

159215
public void identifierCheckBoxHandler() {
160216
if (identifierCheckBox.isSelected()) {
161217
identifierField.setDisable(false);
218+
int depth = 20;
219+
DropShadow borderGlow = new DropShadow();
220+
borderGlow.setOffsetY(0f);
221+
borderGlow.setOffsetX(0f);
222+
borderGlow.setColor(Color.DARKCYAN);
223+
borderGlow.setWidth(depth);
224+
borderGlow.setHeight(depth);
225+
identifierField.setEffect(borderGlow);
162226
deviceTypeChoiceBox.setValue("");
163227
deviceModelChoiceBox.setValue("");
164228
deviceTypeChoiceBox.setDisable(true);
165229
deviceModelChoiceBox.setDisable(true);
166230
} else {
231+
identifierField.setEffect(null);
167232
identifierField.setText("");
168233
identifierField.setDisable(true);
169234
deviceTypeChoiceBox.setDisable(false);
@@ -229,10 +294,24 @@ private void saveOptions(int preset) {
229294
public void saveOptionsHandler() {
230295
editingPresets = !editingPresets;
231296
if (editingPresets) {
232-
preset1Button.setText("Save in Preset 1");
233-
preset2Button.setText("Save in Preset 2");
234-
preset3Button.setText("Save in Preset 3");
297+
int depth = 40;
298+
DropShadow borderGlow = new DropShadow();
299+
borderGlow.setOffsetY(0f);
300+
borderGlow.setOffsetX(0f);
301+
borderGlow.setColor(Color.CYAN);
302+
borderGlow.setWidth(depth);
303+
borderGlow.setHeight(depth);
304+
305+
preset1Button.setEffect(borderGlow);
306+
preset2Button.setEffect(borderGlow);
307+
preset3Button.setEffect(borderGlow);
308+
preset1Button.setText("Preset 1");
309+
preset2Button.setText("Preset 2");
310+
preset3Button.setText("Preset 3");
235311
} else {
312+
preset1Button.setEffect(null);
313+
preset2Button.setEffect(null);
314+
preset3Button.setEffect(null);
236315
preset1Button.setText("Load Preset 1");
237316
preset2Button.setText("Load Preset 2");
238317
preset3Button.setText("Load Preset 3");
@@ -242,8 +321,29 @@ public void saveOptionsHandler() {
242321

243322

244323
public void go() {
245-
if (ecidField.getText().equals("") || deviceModelChoiceBox.getValue().equals("") || (boardConfig && boardConfigField.getText().equals("")) || (apnonceCheckBox.isSelected() && apnonceField.getText().equals(""))) {
246-
return; // TODO: Print an error message
324+
boolean doReturn = false;
325+
if (ecidField.getText().equals("")) {
326+
ecidField.setEffect(errorBorder);
327+
doReturn = true;
328+
}
329+
if (!identifierCheckBox.isSelected() && ((deviceModelChoiceBox.getValue() == null) || (deviceModelChoiceBox.getValue() == ""))) {
330+
deviceModelChoiceBox.setEffect(errorBorder);
331+
doReturn = true;
332+
}
333+
if (identifierCheckBox.isSelected() && identifierField.getText().equals("")) {
334+
identifierField.setEffect(errorBorder);
335+
doReturn = true;
336+
}
337+
if (boardConfig && boardConfigField.getText().equals("")) {
338+
boardConfigField.setEffect(errorBorder);
339+
doReturn = true;
340+
}
341+
if (apnonceCheckBox.isSelected() && apnonceField.getText().equals("")) {
342+
apnonceField.setEffect(errorBorder);
343+
doReturn = true;
344+
}
345+
if (doReturn) {
346+
return;
247347
}
248348
String deviceModel = (String) deviceModelChoiceBox.getValue();
249349
switch (deviceModel) {

src/blobsaver/Main.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ public static void main(String[] args) {
1515
@Override
1616
public void start(Stage primaryStage) throws Exception {
1717
Parent root = FXMLLoader.load(getClass().getResource("blobsaver.fxml"));
18-
primaryStage.setTitle("SHSH Blob Saver 1.0 beta");
19-
primaryStage.setScene(new Scene(root, 500, 300));
18+
primaryStage.setTitle("SHSH Blob Saver 1.0 alpha");
19+
primaryStage.setScene(new Scene(root, 500, 420));
20+
primaryStage.getScene().getStylesheets().add(getClass().getResource("app.css").toExternalForm());
2021
primaryStage.show();
22+
primaryStage.setResizable(false);
2123
}
2224
}

src/blobsaver/app.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.label {
2+
-fx-font-size: 15;
3+
}

0 commit comments

Comments
 (0)