Skip to content

Commit b3f7a7f

Browse files
authored
Merge pull request #243 from ajayyy/improvements
Lower inputs, better visuals, 5 star rating bars
2 parents 358366f + a930f42 commit b3f7a7f

File tree

8 files changed

+125
-30
lines changed

8 files changed

+125
-30
lines changed

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ android {
88
applicationId "ca.lakeeffect.scoutingapp"
99
minSdkVersion 14
1010
targetSdkVersion 27
11-
versionCode 32
12-
versionName "Deep Space - 2.2.0"
11+
versionCode 33
12+
versionName "Deep Space - 2.3.0"
1313
}
1414
buildTypes {
1515
release {

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

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@
77
import android.graphics.Paint;
88
import android.graphics.Rect;
99
import android.support.v4.content.res.ResourcesCompat;
10+
import android.util.TypedValue;
1011
import android.view.MotionEvent;
1112
import android.view.SurfaceHolder;
1213
import android.view.SurfaceView;
1314
import android.view.View;
1415

1516
public class Field implements View.OnTouchListener {
1617

18+
FieldUIPage fieldUIPage;
1719

1820
SurfaceView surface;
1921
Bitmap fieldRed, fieldBlue;
@@ -37,14 +39,11 @@ public class Field implements View.OnTouchListener {
3739
makeRect(664, 206),
3840
makeRect(744, 206),
3941
makeRect(824, 206),
40-
makeRect(584, 225),
41-
makeRect(584, 305),
42+
makeRect(584, 267),
4243
makeRect(664, 328),
4344
makeRect(744, 328),
4445
makeRect(824, 328)
4546
};
46-
47-
4847

4948
//the normal paint for the boxes
5049
Paint normal = new Paint();
@@ -62,7 +61,11 @@ public class Field implements View.OnTouchListener {
6261
//code in surfacecreated can only be called once
6362
boolean alreadyCreated = false;
6463

65-
public Field(SurfaceView s, Bitmap fieldRed, Bitmap fieldBlue) {
64+
Rect backgroundRect;
65+
Paint backgroundPaint;
66+
67+
public Field(final FieldUIPage fieldUIPage, SurfaceView s, Bitmap fieldRed, Bitmap fieldBlue) {
68+
this.fieldUIPage = fieldUIPage;
6669
surface = s;
6770
this.fieldRed = fieldRed;
6871
this.fieldBlue = fieldBlue;
@@ -77,13 +80,26 @@ public Field(SurfaceView s, Bitmap fieldRed, Bitmap fieldBlue) {
7780
surface.getHolder().addCallback(new SurfaceHolder.Callback() {
7881
@Override
7982
public void surfaceCreated(SurfaceHolder holder) {
80-
8183
if(alreadyCreated){
8284
redraw();
8385
return;
8486
}
8587
alreadyCreated = true;
8688

89+
backgroundRect = new Rect(0, 0, surface.getWidth(), surface.getHeight());
90+
91+
//get theme background color
92+
backgroundPaint = new Paint();
93+
if (fieldUIPage.autoPage) {
94+
TypedValue typedValue = new TypedValue();
95+
Field.this.fieldUIPage.getContext().getTheme().resolveAttribute(R.attr.colorAuto, typedValue, true);
96+
backgroundPaint.setColor(typedValue.data);
97+
} else {
98+
TypedValue typedValue = new TypedValue();
99+
Field.this.fieldUIPage.getContext().getTheme().resolveAttribute(android.R.attr.colorBackground, typedValue, true);
100+
backgroundPaint.setColor(typedValue.data);
101+
}
102+
87103
boolean scaleByHeight = false;
88104

89105
//scaled with height
@@ -144,6 +160,7 @@ public void surfaceDestroyed(SurfaceHolder holder) {
144160

145161
}
146162
});
163+
147164
}
148165

149166
// called by the FieldUIPage class when the deselect button is hit
@@ -256,19 +273,19 @@ public void drawImage(Canvas c, int selected) {
256273
field = fieldBlue;
257274
}
258275

276+
//clear screen
277+
c.drawRect(backgroundRect, backgroundPaint);
278+
259279
c.drawBitmap(field, 0, 0, null);
260280

261281
for (Rect rect : fieldPlacements) {
262-
263282
Rect scaledRect = scaleRect(rect, c);
264283

265284
if(java.util.Arrays.asList(fieldPlacements).indexOf(rect) == selected){
266285
c.drawRect(scaledRect.left, scaledRect.top, scaledRect.right, scaledRect.bottom, highlited);
267286
}else {
268287
c.drawRect(scaledRect.left, scaledRect.top, scaledRect.right, scaledRect.bottom, normal);
269288
}
270-
271-
272289
}
273290
}
274291

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public View onCreateView(LayoutInflater inflator, ViewGroup container, Bundle sa
7373
surface = view.findViewById(R.id.fieldCanvas);
7474
Bitmap fieldRed = BitmapFactory.decodeResource(getResources(), R.drawable.fieldred);
7575
Bitmap fieldBlue = BitmapFactory.decodeResource(getResources(), R.drawable.fieldblue);
76-
field = new Field(surface, fieldRed, fieldBlue);
76+
field = new Field(this, surface, fieldRed, fieldBlue);
7777
surface.setOnTouchListener(field);
7878

7979
pickupHatch = view.findViewById(R.id.pickupHatch);
@@ -117,9 +117,8 @@ public void onClick(final View v) {
117117
} else if (autoPage && System.currentTimeMillis() - firstPress > 15000 && v != undo) {
118118
//it has been 15 seconds, they should be done auto by now
119119
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?")
120+
.setTitle("YOU ARE ON THE SANDSTORM PAGE! It has been 15 seconds since your last press!")
121+
.setMessage("Are you sure you would like to put an event? SANDSTORM should be done by now!")
123122
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
124123
public void onClick(DialogInterface dialog, int which) {
125124
firstPress = -1;
@@ -266,8 +265,8 @@ public String[] getData() {
266265
int[] closeRocket = new int[4];
267266
int[] fullRocket = new int[4];
268267

269-
int[] cargoShipLocations = {12, 13, 14, 15, 16, 17, 18, 19};
270-
int[] sideCargoShipLocations = {12, 13, 14, 17, 18, 19};
268+
int[] cargoShipLocations = {12, 13, 14, 15, 16, 17, 18};
269+
int[] sideCargoShipLocations = {12, 13, 14, 16, 17, 18};
271270
int[] levelOneRocketLocations = {4, 5, 10, 11};
272271
int[] levelTwoRocketLocations = {2, 3, 8, 9};
273272
int[] levelThreeRocketLocations = {0, 1, 6, 7};

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@
5656

5757
public class MainActivity extends AppCompatActivity {
5858

59-
//TODO: Redo text sizes
60-
6159
List<Counter> counters = new ArrayList<>();
6260
List<CheckBox> checkboxes = new ArrayList<>();
6361
List<RadioGroup> radiogroups = new ArrayList<>();
@@ -373,6 +371,16 @@ public void run() {
373371
return null;
374372
}
375373

374+
//if the confidence rating is visible and it is <= 0
375+
if (((RatingBar) pagerAdapter.postgamePage.getView().findViewById(R.id.dataConfidence)).getRating() <= 0) {
376+
runOnUiThread(new Thread() {
377+
public void run() {
378+
new Toast(MainActivity.this).makeText(MainActivity.this, "You didn't rate the confidence in your data!", Toast.LENGTH_LONG).show();
379+
}
380+
});
381+
return null;
382+
}
383+
376384
if (((Spinner) pagerAdapter.pregamePage.getView().findViewById(R.id.autoStartLocation)).getSelectedItem().toString().equals("Choose One")) {
377385
runOnUiThread(new Thread() {
378386
public void run() {

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

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
android:layout_height="wrap_content"
1414
android:id="@+id/endgameTableLayout"
1515
android:layout_margin="10dp"
16-
android:rowCount="3"
16+
android:rowCount="5"
1717
android:columnCount="5">
1818

1919
<TextView
@@ -24,7 +24,7 @@
2424
android:text="Climb: "
2525
android:paddingTop="10dp"
2626
android:paddingBottom="10dp"
27-
android:textSize="@dimen/text_medium"/>
27+
android:textSize="@dimen/text_large"/>
2828

2929
<Spinner
3030
android:id="@+id/endgameClimbType"
@@ -46,9 +46,9 @@
4646

4747
<TextView
4848
android:text="Robots Carried:"
49-
android:layout_width="210dp"
49+
android:layout_width="260dp"
5050
android:layout_height="wrap_content"
51-
android:textSize="@dimen/text_medium"
51+
android:textSize="@dimen/text_large"
5252
android:layout_row="2"
5353
android:layout_column="0"
5454
android:layout_gravity="center_vertical"/>
@@ -62,6 +62,42 @@
6262
android:layout_column="1"
6363
android:layout_columnSpan="4"/>
6464

65+
<TextView
66+
android:text="Confidence:"
67+
android:layout_width="wrap_content"
68+
android:layout_height="wrap_content"
69+
android:textSize="@dimen/text_large"
70+
android:layout_row="3"
71+
android:layout_column="0"
72+
android:layout_gravity="center_vertical"
73+
android:paddingRight="20dp"/>
74+
75+
<LinearLayout
76+
android:layout_row="3"
77+
android:layout_column="1"
78+
android:layout_columnSpan="2">
79+
<!--This is a workaround to make #109 work as seen in https://stackoverflow.com/a/39653856/1985387-->
80+
<RatingBar
81+
android:layout_width="wrap_content"
82+
android:layout_height="wrap_content"
83+
android:id="@+id/dataConfidence"
84+
android:numStars="5"
85+
android:stepSize="0.5"
86+
android:isIndicator="false"/>
87+
88+
</LinearLayout>
89+
90+
<TextView
91+
android:text="Your confidence in the data you colllected this match."
92+
android:layout_width="wrap_content"
93+
android:layout_height="wrap_content"
94+
android:layout_row="4"
95+
android:textSize="@dimen/text_small"
96+
android:layout_column="0"
97+
android:layout_columnSpan="3"
98+
android:layout_gravity="center_vertical"
99+
android:paddingRight="20dp"/>
100+
65101
</GridLayout>
66102

67103

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
android:layout_width="wrap_content"
6868
android:layout_height="wrap_content"
6969
android:id="@+id/driveRating"
70-
android:numStars="4"
70+
android:numStars="5"
7171
android:stepSize="0.5"
7272
android:isIndicator="false"/>
7373
</LinearLayout>
@@ -91,7 +91,7 @@
9191
android:layout_width="wrap_content"
9292
android:layout_height="wrap_content"
9393
android:id="@+id/intakeRating"
94-
android:numStars="4"
94+
android:numStars="5"
9595
android:stepSize="0.5"
9696
android:isIndicator="false"/>
9797

@@ -116,7 +116,7 @@
116116
android:layout_width="wrap_content"
117117
android:layout_height="wrap_content"
118118
android:id="@+id/defenceRating"
119-
android:numStars="4"
119+
android:numStars="5"
120120
android:stepSize="0.5"
121121
android:isIndicator="false"/>
122122

app/src/main/res/layout/postgame_page.xml

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
android:layout_height="wrap_content"
1414
android:id="@+id/endgameTableLayout"
1515
android:layout_margin="10dp"
16-
android:rowCount="3"
16+
android:rowCount="5"
1717
android:columnCount="5">
1818

1919
<TextView
@@ -62,6 +62,41 @@
6262
android:layout_column="1"
6363
android:layout_columnSpan="4"/>
6464

65+
<TextView
66+
android:text="Confidence:"
67+
android:layout_width="wrap_content"
68+
android:layout_height="wrap_content"
69+
android:textSize="@dimen/text_medium"
70+
android:layout_row="3"
71+
android:layout_column="0"
72+
android:layout_gravity="center_vertical"
73+
android:paddingRight="20dp"/>
74+
75+
<LinearLayout
76+
android:layout_row="3"
77+
android:layout_column="1"
78+
android:layout_columnSpan="2">
79+
<!--This is a workaround to make #109 work as seen in https://stackoverflow.com/a/39653856/1985387-->
80+
<RatingBar
81+
android:layout_width="wrap_content"
82+
android:layout_height="wrap_content"
83+
android:id="@+id/dataConfidence"
84+
android:numStars="5"
85+
android:stepSize="0.5"
86+
android:isIndicator="false"/>
87+
88+
</LinearLayout>
89+
90+
<TextView
91+
android:text="Your confidence in the data you colllected this match."
92+
android:layout_width="wrap_content"
93+
android:layout_height="wrap_content"
94+
android:layout_row="4"
95+
android:layout_column="0"
96+
android:layout_columnSpan="3"
97+
android:layout_gravity="center_vertical"
98+
android:paddingRight="20dp"/>
99+
65100
</GridLayout>
66101

67102

app/src/main/res/layout/qualitative_page.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
android:layout_width="wrap_content"
6868
android:layout_height="wrap_content"
6969
android:id="@+id/driveRating"
70-
android:numStars="4"
70+
android:numStars="5"
7171
android:stepSize="0.5"
7272
android:isIndicator="false"/>
7373
</LinearLayout>
@@ -91,7 +91,7 @@
9191
android:layout_width="wrap_content"
9292
android:layout_height="wrap_content"
9393
android:id="@+id/intakeRating"
94-
android:numStars="4"
94+
android:numStars="5"
9595
android:stepSize="0.5"
9696
android:isIndicator="false"/>
9797

@@ -116,7 +116,7 @@
116116
android:layout_width="wrap_content"
117117
android:layout_height="wrap_content"
118118
android:id="@+id/defenceRating"
119-
android:numStars="4"
119+
android:numStars="5"
120120
android:stepSize="0.5"
121121
android:isIndicator="false"/>
122122

0 commit comments

Comments
 (0)