Skip to content

Commit 0dd1050

Browse files
authored
Merge pull request #225 from ajayyy/improvements
Added features to prevent users from making mistakes
2 parents 708ea98 + 25da96b commit 0dd1050

File tree

13 files changed

+85
-37
lines changed

13 files changed

+85
-37
lines changed

app/src/main/java/ca/lakeeffect/scoutingapp/FieldUIPage.java

Lines changed: 48 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ public class FieldUIPage extends Fragment implements View.OnClickListener {
4949
//is this the auto page, if so a different background color will be shown
5050
boolean autoPage;
5151

52+
//only used if this is the auto page
53+
//if so, it will use this to determine if it is has been 15 seconds
54+
//if so, it will warn the user
55+
long firstPress = -1;
56+
5257
@Override
5358
public void onCreate(Bundle savedInstanceState) {
5459
super.onCreate(savedInstanceState);
@@ -106,7 +111,27 @@ public View onCreateView(LayoutInflater inflator, ViewGroup container, Bundle sa
106111
}
107112

108113
@Override
109-
public void onClick(View v) {
114+
public void onClick(final View v) {
115+
if (firstPress == -1 && autoPage && v != undo) {
116+
firstPress = System.currentTimeMillis();
117+
} else if (autoPage && System.currentTimeMillis() - firstPress > 15000 && v != undo) {
118+
//it has been 15 seconds, they should be done auto by now
119+
new AlertDialog.Builder(getContext())
120+
.setTitle("YOU ARE ON THE SANDSTORM PAGE! It has been 15 seconds since your last press! " +
121+
"SANDSTORM should be done by now!")
122+
.setMessage("Are you sure you would like to put an event?")
123+
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
124+
public void onClick(DialogInterface dialog, int which) {
125+
FieldUIPage.this.onClick(v);
126+
firstPress = -1;
127+
}
128+
})
129+
.setNegativeButton("No", null)
130+
.create()
131+
.show();
132+
return;
133+
}
134+
110135
if (v == undo) {
111136
if (events.size() > 0) {
112137
Event event = events.get(events.size() - 1);
@@ -125,6 +150,11 @@ public void onClick(View v) {
125150
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
126151
public void onClick(DialogInterface dialog, int which) {
127152
events.remove(events.size() - 1);
153+
154+
if (events.size() == 0 && autoPage) {
155+
//reset first press time, nothing has happened
156+
firstPress = -1;
157+
}
128158
}
129159
})
130160
.setNegativeButton("No", null)
@@ -221,14 +251,21 @@ public String[] getData() {
221251
StringBuilder labels = new StringBuilder();
222252
StringBuilder data = new StringBuilder();
223253

254+
String fieldPeriod = "TeleOp ";
255+
if (autoPage) {
256+
fieldPeriod = "Auto ";
257+
}
258+
224259
//hatchHit, hatchMiss, cargoHit, cargoMiss
225260
int[] cargoShip = new int[4];
261+
int[] sideCargoShip = new int[4];
226262
int[] levelOneRocket = new int[4];
227263
int[] levelTwoRocket = new int[4];
228264
int[] levelThreeRocket = new int[4];
229265
int[] fullRocket = new int[4];
230266

231267
int[] cargoShipLocations = {12, 13, 14, 15, 16, 17, 18, 19};
268+
int[] sideCargoShipLocations = {12, 13, 14, 17, 18, 19};
232269
int[] levelOneRocketLocations = {4, 5, 10, 11};
233270
int[] levelTwoRocketLocations = {2, 3, 8, 9};
234271
int[] levelThreeRocketLocations = {0, 1, 6, 7};
@@ -243,35 +280,33 @@ public String[] getData() {
243280
case 2:
244281
//eventType 2: dropHatch
245282
id = 0;
246-
System.out.println("2");
247283
break;
248284

249285
case 3:
250286
//eventType 3: failDropHatch
251287
id = 1;
252-
System.out.println("3");
253288
break;
254289

255290
case 6:
256291
//eventType 6: dropCargo
257-
System.out.println("6");
258292
id = 2;
259293
break;
260294

261295
case 7:
262296
//eventType 7: failDropCargo
263-
System.out.println("7");
264297
id = 3;
265298
break;
266299

267300
default:
268-
System.out.println(e.eventType);
269301
break;
270302
}
271303

272304
if (MainActivity.arrayContains(cargoShipLocations, location)) {
273305
cargoShip[id]++;
274306
}
307+
if (MainActivity.arrayContains(sideCargoShipLocations, location)) {
308+
sideCargoShip[id]++;
309+
}
275310
if (MainActivity.arrayContains(levelOneRocketLocations, location)) {
276311
levelOneRocket[id]++;
277312
fullRocket[id]++;
@@ -287,15 +322,17 @@ public String[] getData() {
287322
}
288323

289324
for (int i = 0; i < labelActions.length; i++) {
290-
labels.append("Cargo ship " + labelActions[i] + ",");
325+
labels.append(fieldPeriod + "Cargo Ship " + labelActions[i] + ",");
291326
data.append(cargoShip[i] + ",");
292-
labels.append("Level 1 rocket " + labelActions[i] + ",");
327+
labels.append(fieldPeriod + "Side Cargo Ship " + labelActions[i] + ",");
328+
data.append(sideCargoShip[i] + ",");
329+
labels.append(fieldPeriod + "Level 1 Rocket " + labelActions[i] + ",");
293330
data.append(levelOneRocket[i] + ",");
294-
labels.append("Level 2 rocket " + labelActions[i] + ",");
331+
labels.append(fieldPeriod + "Level 2 Rocket " + labelActions[i] + ",");
295332
data.append(levelTwoRocket[i] + ",");
296-
labels.append("Level 3 rocket " + labelActions[i] + ",");
333+
labels.append(fieldPeriod + "Level 3 Rocket " + labelActions[i] + ",");
297334
data.append(levelThreeRocket[i] + ",");
298-
labels.append("Full rocket " + labelActions[i] + ",");
335+
labels.append(fieldPeriod + "Full Rocket " + labelActions[i] + ",");
299336
data.append(fullRocket[i] + ",");
300337
}
301338

app/src/main/java/ca/lakeeffect/scoutingapp/MainActivity.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -449,23 +449,27 @@ public void run() {
449449

450450
PercentRelativeLayout layout;
451451

452-
//Auto page
453-
layout = pagerAdapter.pregamePage.getView().findViewById(R.id.autoPageLayout);
452+
//Pregame page
453+
layout = pagerAdapter.pregamePage.getView().findViewById(R.id.preGamePageLayout);
454454
enterLayout(layout);
455455

456-
// //Tele page
457-
// layout = (PercentRelativeLayout) pagerAdapter.teleopPage.getView().findViewById(R.id.telePageLayout);
458-
// enterLayout(layout);
459-
456+
//tele field
460457
String[] tele = pagerAdapter.teleopPage.getData();
461458

462459
labels.append(tele[0]);
463460
data.append(tele[1]);
464461

465-
//Endgame page
462+
//auto field
463+
String[] auto = pagerAdapter.autoPage.getData();
464+
465+
labels.append(auto[0]);
466+
data.append(auto[1]);
467+
468+
//Postgame page
466469
layout = pagerAdapter.postgamePage.getView().findViewById(R.id.postgamePageLayout);
467470
enterLayout(layout);
468471

472+
//Qualitative Page
469473
layout = pagerAdapter.qualitativePage.getView().findViewById(R.id.qualitativePageLayout);
470474
enterLayout(layout);
471475

@@ -832,7 +836,7 @@ public void reset(boolean incrementMatchNumber) {
832836
PercentRelativeLayout layout;
833837

834838
//Auto page
835-
layout = pagerAdapter.pregamePage.getView().findViewById(R.id.autoPageLayout);
839+
layout = pagerAdapter.pregamePage.getView().findViewById(R.id.preGamePageLayout);
836840
clearData(layout);
837841

838842
//Tele page
@@ -1182,7 +1186,6 @@ public void updateUserIDSpinner() {
11821186
}
11831187

11841188
userIDSpinner.setSelection(selectedIndex);
1185-
userID = selectedIndex;
11861189
}
11871190

11881191
//when the ok button on the alert is pressed

app/src/main/java/ca/lakeeffect/scoutingapp/PostgamePage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public void onCreate(Bundle savedInstanceState) {
3232
}
3333

3434
public View onCreateView(LayoutInflater inflator, ViewGroup container, Bundle savedInstanceState) {
35-
View view = inflator.inflate(R.layout.postgamepage, container, false);
35+
View view = inflator.inflate(R.layout.postgame_page, container, false);
3636

3737
climb = view.findViewById(R.id.endgameClimb);
3838
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this.getContext(), R.array.climb, R.layout.spinner);

app/src/main/java/ca/lakeeffect/scoutingapp/PregamePage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public void onCreate(Bundle savedInstanceState) {
2525
@Override
2626
public View onCreateView(LayoutInflater inflator, ViewGroup container, Bundle savedInstanceState) {
2727

28-
View view = inflator.inflate(R.layout.pregamepage, container, false);
28+
View view = inflator.inflate(R.layout.pregame_page, container, false);
2929

3030
view.setTag("page1");
3131

app/src/main/java/ca/lakeeffect/scoutingapp/QualitativePage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public void onCreate(Bundle savedInstanceState) {
2525

2626
@Override
2727
public View onCreateView(LayoutInflater inflator, ViewGroup container, Bundle savedInstanceState) {
28-
View view = inflator.inflate(R.layout.qualitativepage, container, false);
28+
View view = inflator.inflate(R.layout.qualitative_page, container, false);
2929

3030
final RatingBar defenceRating = view.findViewById(R.id.defenceRating);
3131
final TextView defenceText = view.findViewById(R.id.defenceText);

app/src/main/res/layout-sw600dp/field_ui_page.xml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
android:layout_width="wrap_content"
2323
android:layout_height="wrap_content"
2424
android:text="Hatch"
25-
android:textSize="@dimen/text_small"
25+
android:textSize="@dimen/text_medium"
2626
android:layout_weight="0"
2727
android:layout_gravity="center"
2828
android:id="@+id/hatchLabel"/>
@@ -33,6 +33,7 @@
3333
android:layout_weight="1"
3434
android:id="@+id/pickupHatch"
3535
android:backgroundTint="#ffff84"
36+
android:textSize="@dimen/text_small"
3637
android:textColor="@color/black"/>
3738
<Button
3839
android:layout_width="match_parent"
@@ -41,6 +42,7 @@
4142
android:layout_weight="1"
4243
android:id="@+id/failPickupHatch"
4344
android:backgroundTint="#ffff84"
45+
android:textSize="@dimen/text_small"
4446
android:textColor="@color/black"/>
4547
<Button
4648
android:layout_width="match_parent"
@@ -49,13 +51,15 @@
4951
android:layout_weight="1"
5052
android:id="@+id/failDropHatch"
5153
android:backgroundTint="#ffff84"
54+
android:textSize="@dimen/text_small"
5255
android:textColor="@color/black"/>
5356
<Button
5457
android:layout_width="match_parent"
5558
android:layout_height="match_parent"
5659
android:text="Failed dropoff"
5760
android:layout_weight="1"
5861
android:id="@+id/dropHatch"
62+
android:textSize="@dimen/text_small"
5963
android:backgroundTint="#ffff84"
6064
android:textColor="@color/black"/>
6165
</LinearLayout>
@@ -80,7 +84,7 @@
8084
android:layout_width="match_parent"
8185
android:layout_height="70dp"
8286
android:layout_gravity="center"
83-
android:layout_weight="2"
87+
android:textSize="@dimen/text_small"
8488
android:text="Undo" />
8589
</LinearLayout>
8690
<LinearLayout
@@ -93,7 +97,7 @@
9397
android:layout_width="wrap_content"
9498
android:layout_height="wrap_content"
9599
android:text="Cargo"
96-
android:textSize="@dimen/text_small"
100+
android:textSize="@dimen/text_medium"
97101
android:layout_weight="0"
98102
android:layout_gravity="center"
99103
android:id="@+id/cargoLabel"/>
@@ -104,6 +108,7 @@
104108
android:layout_weight="1"
105109
android:id="@+id/pickupCargo"
106110
android:backgroundTint="#ffd38e"
111+
android:textSize="@dimen/text_small"
107112
android:textColor="@color/black"/>
108113
<Button
109114
android:layout_width="match_parent"
@@ -112,6 +117,7 @@
112117
android:layout_weight="1"
113118
android:id="@+id/failPickupCargo"
114119
android:backgroundTint="#ffd38e"
120+
android:textSize="@dimen/text_small"
115121
android:textColor="@color/black"/>
116122
<Button
117123
android:layout_width="match_parent"
@@ -120,6 +126,7 @@
120126
android:layout_weight="1"
121127
android:id="@+id/failDropCargo"
122128
android:backgroundTint="#ffd38e"
129+
android:textSize="@dimen/text_small"
123130
android:textColor="@color/black"/>
124131
<Button
125132
android:layout_width="match_parent"
@@ -128,6 +135,7 @@
128135
android:layout_weight="1"
129136
android:id="@+id/dropCargo"
130137
android:backgroundTint="#ffd38e"
138+
android:textSize="@dimen/text_small"
131139
android:textColor="@color/black"/>
132140
</LinearLayout>
133141
</LinearLayout>
File renamed without changes.

app/src/main/res/layout/pregamepage.xml renamed to app/src/main/res/layout-sw600dp/pregame_page.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
android:orientation="vertical"
55
android:layout_width="match_parent"
66
android:layout_height="match_parent"
7-
android:id = "@+id/autoPageLayout">
7+
android:id = "@+id/preGamePageLayout">
88

99
<ScrollView
1010
android:layout_width="match_parent"
@@ -96,7 +96,7 @@
9696
android:layout_column="1"
9797
android:checked="false"
9898
android:text="Cargo"
99-
android:textSize="@dimen/text_small" />
99+
android:textSize="@dimen/text_medium" />
100100

101101
<CheckBox
102102
android:layout_width="wrap_content"
@@ -106,7 +106,7 @@
106106
android:id="@+id/startingObjectsHatch"
107107
android:layout_columnWeight="1"
108108
android:text="Hatch"
109-
android:textSize="@dimen/text_small"/>
109+
android:textSize="@dimen/text_medium"/>
110110

111111
</GridLayout>
112112

app/src/main/res/layout/qualitativepage.xml renamed to app/src/main/res/layout-sw600dp/qualitative_page.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
android:layout_row="3"
2323
android:layout_column="0"
2424
android:text="Defense"
25-
android:textSize="@dimen/text_small"
25+
android:textSize="@dimen/text_medium"
2626
android:layout_width="wrap_content"
2727
android:layout_height="wrap_content"
2828
android:paddingHorizontal="10dp"
@@ -38,7 +38,7 @@
3838
android:layout_height="wrap_content"
3939
android:paddingHorizontal="10dp"
4040
android:id="@+id/died"
41-
android:textSize="@dimen/text_small" />
41+
android:textSize="@dimen/text_medium" />
4242
<CheckBox
4343
android:layout_row="3"
4444
android:layout_column="2"
@@ -47,13 +47,13 @@
4747
android:layout_height="wrap_content"
4848
android:paddingHorizontal="10dp"
4949
android:id="@+id/tipped"
50-
android:textSize="@dimen/text_small" />
50+
android:textSize="@dimen/text_medium" />
5151

5252
<TextView
5353
android:text="Drive Ability:"
5454
android:layout_width="wrap_content"
5555
android:layout_height="wrap_content"
56-
android:textSize="@dimen/text_medium"
56+
android:textSize="@dimen/text_large"
5757
android:layout_row="4"
5858
android:layout_column="0"
5959
android:layout_gravity="center_vertical"/>
@@ -76,7 +76,7 @@
7676
android:text="Intake Ability:"
7777
android:layout_width="wrap_content"
7878
android:layout_height="wrap_content"
79-
android:textSize="@dimen/text_medium"
79+
android:textSize="@dimen/text_large"
8080
android:layout_row="5"
8181
android:layout_column="0"
8282
android:layout_gravity="center_vertical"
@@ -102,7 +102,7 @@
102102
android:id="@+id/defenceText"
103103
android:layout_width="wrap_content"
104104
android:layout_height="wrap_content"
105-
android:textSize="@dimen/text_medium"
105+
android:textSize="@dimen/text_large"
106106
android:layout_row="6"
107107
android:layout_column="0"
108108
android:layout_gravity="center_vertical"/>

0 commit comments

Comments
 (0)