Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions app/src/main/assets/input_data/Accuracy.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Id,Description
100,100%
90,90%
80,80%
70,70%
60,60%
50,50%
25,25%
10,10%
0,0%
4 changes: 4 additions & 0 deletions app/src/main/assets/input_data/ClimbLevels.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Id,Description
1,L3
2,L2
3,L1
7 changes: 7 additions & 0 deletions app/src/main/assets/input_data/ClimbPositions.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Id,Description
1,Left End
2,Left Upright
3,Center
4,Right End
5,Right Upright
6,Back
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import com.team3663.scouting_app.config.Globals;
import com.team3663.scouting_app.databinding.AppLaunchBinding;
import com.team3663.scouting_app.utility.CPR_Network;
import com.team3663.scouting_app.utility.dataFile.*;
import com.team3663.scouting_app.dataFile.*;

import java.util.List;
import java.util.Objects;
Expand Down Expand Up @@ -148,7 +148,7 @@ protected void onCreate(Bundle in_savedInstanceState) {
// Output: void
// =============================================================================================
private void initSettings() {
// Define a Image Button to open up the Settings
// Define an Image Button to open up the Settings
appLaunchBinding.imgButSettings.setImageResource(R.drawable.settings_icon);
appLaunchBinding.imgButSettings.setVisibility(View.INVISIBLE);
appLaunchBinding.imgButSettings.setClickable(false);
Expand Down Expand Up @@ -231,7 +231,7 @@ private void initDataFiles() {
Globals.output_df = Globals.base_df.createDirectory(Constants.Data.PUBLIC_OUTPUT_DIR);
}
} else {
// The base dir is there but we should check the two sub directories are there.
// The base dir is there, but we should check the two subdirectories are there.
Globals.input_df = Globals.base_df.findFile(Constants.Data.PUBLIC_INPUT_DIR);
if (Globals.input_df == null)
Globals.input_df = Globals.base_df.createDirectory(Constants.Data.PUBLIC_INPUT_DIR);
Expand All @@ -241,6 +241,9 @@ private void initDataFiles() {
}

// Instantiate the Global variables or reset their context
if (Globals.AccuracyList == null) Globals.AccuracyList = new AccuracyFile(this); else Globals.AccuracyList.setContext(this);
if (Globals.ClimbLevelList == null) Globals.ClimbLevelList = new ClimbLevelFile(this); else Globals.ClimbLevelList.setContext(this);
if (Globals.ClimbPositionList == null) Globals.ClimbPositionList = new ClimbPositionFile(this); else Globals.ClimbPositionList.setContext(this);
if (Globals.ColorList == null) Globals.ColorList = new ColorsFile(this); else Globals.ColorList.setContext(this);
if (Globals.CommentList == null) Globals.CommentList = new CommentsFile(this); else Globals.CommentList.setContext(this);
if (Globals.CompetitionList == null) Globals.CompetitionList = new CompetitionsFile(this); else Globals.CompetitionList.setContext(this);
Expand Down Expand Up @@ -269,21 +272,21 @@ private void loadDataFiles() {
public void run() {
appLaunchBinding.progressBarOverall.setMax(Globals.CompetitionList.getNumberOfFiles());
appLaunchBinding.progressBarOverall.setProgress(0);
appLaunchBinding.textStatusOverall.setText(getString(R.string.applaunch_loading));
appLaunchBinding.textStatusOverall.setText(getString(R.string.applaunch_loading_prefix));
appLaunchBinding.textPercentOverall.setText(getString(R.string.applaunch_percent, 0));

// Load all of the data with a BRIEF delay between. :)
// Load all the data with a BRIEF delay between. :)
_DataFile.LoadAllDataFiles(appLaunchBinding.textStatusFile, appLaunchBinding.progressBarFile, appLaunchBinding.textPercentFile, appLaunchBinding.progressBarOverall, appLaunchBinding.textPercentOverall);

// After loading all of the data, we need to build the set of "next events"
// After loading all the data, we need to build the set of "next events"
Globals.EventList.buildNextEvents();

// Setting the Visibility attribute can't be set from a non-UI thread (like withing a TimerTask
// that runs on a separate thread. So we need to make a Runner that will execute on the UI thread
// that runs on a separate thread). So we need to make a Runner that will execute on the UI thread
// to set these.
AppLaunch.this.runOnUiThread(() -> {
// Sleep a tiny bit to help the UI not glitch (otherwise this block of code doesn't
// do what it's trying to do (things don't become visible, etc).
// Sleep a tiny bit to help the UI not glitch. Otherwise, this block of code doesn't
// do what it's trying to do (things don't become visible, etc.).
try {
Thread.sleep(Constants.AppLaunch.SPLASH_SCREEN_DELAY);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class PostMatch extends AppCompatActivity {
//Creating an array list for the Comments
ArrayList<Integer> CommentList = new ArrayList<>();
ArrayList<String> CommentArray = Globals.CommentList.getDescriptionList();
ArrayList<String> Accuracy = Globals.AccuracyTypeList.getDescriptionList();
ArrayList<String> Accuracy = Globals.AccuracyList.getDescriptionList();
ArrayList<String> ClimbLevel = Globals.ClimbLevelList.getDescriptionList();
ArrayList<String> ClimbPosition = Globals.ClimbPositionList.getDescriptionList();

Expand Down Expand Up @@ -160,7 +160,7 @@ private void initAccuracy() {
// Set starting selection
int start_Pos = 0;
for (int i = 0; i < Accuracy.size(); i++) {
if (Accuracy.get(i).equals(Globals.AccuracyTypeList.getAccuracyDescription(Globals.CurrentAccuracy))) {
if (Accuracy.get(i).equals(Globals.AccuracyList.getAccuracyDescription(Globals.CurrentAccuracy))) {
start_Pos = i;
break;
}
Expand All @@ -173,7 +173,7 @@ private void initAccuracy() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {

int newAccuracy = Globals.AccuracyTypeList.getAccuracyValue(postMatchBinding.spinnerAccuracy.getSelectedItem().toString());
int newAccuracy = Globals.AccuracyList.getAccuracyId(postMatchBinding.spinnerAccuracy.getSelectedItem().toString());

if (!Objects.equals(newAccuracy, Globals.CurrentAccuracy)) {
Globals.CurrentAccuracy = newAccuracy;
Expand Down Expand Up @@ -215,22 +215,22 @@ private void initClimbLevel() {
new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
String newClimbLevel = Globals.ClimbLevelList.getClimbLevelValue(postMatchBinding.spinnerClimbLevel.getSelectedItem().toString());
int newClimbLevel = Globals.ClimbLevelList.getClimbLevelId(postMatchBinding.spinnerClimbLevel.getSelectedItem().toString());

if (!newClimbLevel.equals(Globals.CurrentClimbLevel)) {
if (newClimbLevel != Globals.CurrentClimbLevel) {
Globals.CurrentClimbLevel = newClimbLevel;
}

Achievements.data_match_ClimbSuccessTele = Globals.CurrentClimbLevel;
Achievements.data_match_ClimbSuccessTele = Globals.ClimbLevelList.getClimbLevelDescription(Globals.CurrentClimbLevel);
}

@Override
public void onNothingSelected(AdapterView<?> adapterView) {
Globals.CurrentClimbLevel = "-1";
Globals.CurrentClimbLevel = Constants.PostMatch.CLIMB_LEVEL_NOT_SELECTED;
}
});
} else {
Globals.CurrentClimbLevel = "None";
Globals.CurrentClimbLevel = Constants.PostMatch.CLIMB_LEVEL_NOT_SELECTED;
ArrayAdapter<String> adp_ClimbLevel = new ArrayAdapter<>(this, R.layout.cpr_spinner_empty, Constants.PostMatch.NO_CLIMB);
postMatchBinding.spinnerClimbLevel.setAdapter(adp_ClimbLevel);
postMatchBinding.spinnerClimbLevel.setBackgroundColor(getColor(R.color.light_grey));
Expand Down Expand Up @@ -265,20 +265,20 @@ private void initClimbPosition() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {

String newClimbPosition = Globals.ClimbPositionList.getClimbPositionValue(postMatchBinding.spinnerClimbPosition.getSelectedItem().toString());
int newClimbPosition = Globals.ClimbPositionList.getClimbPositionId(postMatchBinding.spinnerClimbPosition.getSelectedItem().toString());

if (!Objects.equals(newClimbPosition, Globals.CurrentClimbPosition)) {
if (newClimbPosition != Globals.CurrentClimbPosition) {
Globals.CurrentClimbPosition = newClimbPosition;
}
}

@Override
public void onNothingSelected(AdapterView<?> adapterView) {
Globals.CurrentClimbPosition = "-1";
Globals.CurrentClimbPosition = Constants.PostMatch.CLIMB_POSITION_NOT_SELECTED;
}
});
} else {
Globals.CurrentClimbPosition = "None";
Globals.CurrentClimbPosition = Constants.PostMatch.CLIMB_POSITION_NOT_SELECTED;
ArrayAdapter<String> adp_ClimbPosition = new ArrayAdapter<>(this, R.layout.cpr_spinner_empty, Constants.PostMatch.NO_CLIMB);
postMatchBinding.spinnerClimbPosition.setAdapter(adp_ClimbPosition);
postMatchBinding.spinnerClimbPosition.setBackgroundColor(getColor(R.color.light_grey));
Expand Down Expand Up @@ -374,7 +374,18 @@ private void initSubmit() {
Intent GoToPreMatch = new Intent(PostMatch.this, PreMatch.class);
startActivity(GoToPreMatch);
} else {
// Log all of the data from this page
// If any spinner data is left blank -> abort
if (Constants.PostMatch.ACCURACY_NOT_SELECTED == Globals.CurrentAccuracy ||
(postMatchBinding.spinnerClimbLevel.isEnabled() && Constants.PostMatch.CLIMB_LEVEL_NOT_SELECTED == Globals.CurrentClimbLevel) ||
(postMatchBinding.spinnerClimbPosition.isEnabled() && Constants.PostMatch.CLIMB_POSITION_NOT_SELECTED == Globals.CurrentClimbPosition) ||
Objects.equals(Globals.stealFuelValue, "-1") ||
Objects.equals(Globals.affectedByDefenseValue, "-1")) {

Toast.makeText(this, R.string.post_missing_data, Toast.LENGTH_SHORT).show();
return;
}

// Log all the data from this page
StringBuilder comment_sep_ID = new StringBuilder();
for (Integer comment_dropID : CommentList) {
String comment = CommentArray.get(comment_dropID);
Expand All @@ -383,29 +394,14 @@ private void initSubmit() {
if (comment_sep_ID.length() > 0) comment_sep_ID = new StringBuilder(comment_sep_ID.substring(1));
Globals.EventLogger.LogData(Constants.Logger.LOGKEY_COMMENTS, comment_sep_ID.toString());

// If any spinner data is left blank
if ((Constants.PostMatch.ACCURACY_NOT_SELECTED == Globals.CurrentAccuracy) ||
Constants.PostMatch.CLIMB_LEVEL_NOT_SELECTED.equals(Globals.CurrentClimbLevel) ||
Constants.PostMatch.CLIMB_POSITION_NOT_SELECTED.equals(Globals.CurrentClimbPosition)) {
// Log all the spinner data
Globals.EventLogger.LogData(Constants.Logger.LOGKEY_ACCURACY, String.valueOf(Globals.CurrentAccuracy));
Globals.EventLogger.LogData(Constants.Logger.LOGKEY_CLIMB_LEVEL, String.valueOf(Globals.CurrentClimbLevel));
Globals.EventLogger.LogData(Constants.Logger.LOGKEY_CLIMB_POSITION, String.valueOf(Globals.CurrentClimbPosition));

Toast.makeText(this, R.string.post_missing_data, Toast.LENGTH_SHORT).show();
return;
} else {
// Log all the spinner data
Globals.EventLogger.LogData(Constants.Logger.LOGKEY_ACCURACY, String.valueOf(Globals.CurrentAccuracy));
Globals.EventLogger.LogData(Constants.Logger.LOGKEY_CLIMB_LEVEL, String.valueOf(Globals.CurrentClimbLevel));
Globals.EventLogger.LogData(Constants.Logger.LOGKEY_CLIMB_POSITION, String.valueOf(Globals.CurrentClimbPosition));
}

// If any radio button is left blank
if (Objects.equals(Globals.stealFuelValue, "-1") || Objects.equals(Globals.affectedByDefenseValue, "-1")) {
Toast.makeText(this, R.string.post_missing_data, Toast.LENGTH_SHORT).show();
return;
} else {
// Log all the spinner data
Globals.EventLogger.LogData(Constants.Logger.LOGKEY_STEAL_FUEL,String.valueOf(Globals.stealFuelValue));
Globals.EventLogger.LogData(Constants.Logger.LOGKEY_AFFECTED_BY_DEFENSE, String.valueOf(Globals.affectedByDefenseValue));
}
// Log all the spinner data
Globals.EventLogger.LogData(Constants.Logger.LOGKEY_STEAL_FUEL,String.valueOf(Globals.stealFuelValue));
Globals.EventLogger.LogData(Constants.Logger.LOGKEY_AFFECTED_BY_DEFENSE, String.valueOf(Globals.affectedByDefenseValue));

Intent GoToSubmitData = new Intent(PostMatch.this, SubmitData.class);
startActivity(GoToSubmitData);
Expand All @@ -421,7 +417,6 @@ private void initSubmit() {
.startsWith(Constants.Achievements.EVENT_TYPE_FINAL)) Achievements.data_FinalType++;

finish();

});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class Constants {
public static class Logger {
Expand Down Expand Up @@ -82,10 +80,10 @@ public static class Match {
}

public static class PostMatch {
public static final String[] NO_CLIMB = new String[]{"No Climb"};
public static final int ACCURACY_NOT_SELECTED = -1;
public static final String CLIMB_LEVEL_NOT_SELECTED = "-1";
public static final String CLIMB_POSITION_NOT_SELECTED = "-1";
public static final int CLIMB_POSITION_NOT_SELECTED = -1;
public static final int CLIMB_LEVEL_NOT_SELECTED = -1;
public static final String[] NO_CLIMB = new String[]{"No Climb"};
public static final String STEAL_FUEL_NOT_SELECTED = "-1";
public static final String AFFECTED_BY_DEFENSE_NOT_SELECTED = "-1";
}
Expand All @@ -105,7 +103,6 @@ public static class Events {
public static final int ID_NOT_MOVING_START = 64;
public static final int ID_NOT_MOVING_END = 65;
public static final int ID_AUTO_START_GAME_PIECE = 0;
public static final int ID_AUTO_CLIMB = 6;
public static final int ID_TELE_CLIMB = 40;
public static final int ID_NO_EVENT = 999; // use to check if the eventID you're looking for doesn't exist
}
Expand Down
16 changes: 6 additions & 10 deletions app/src/main/java/com/team3663/scouting_app/config/Globals.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@

import androidx.documentfile.provider.DocumentFile;

import com.team3663.scouting_app.data.Accuracy;
import com.team3663.scouting_app.data.ClimbLevel;
import com.team3663.scouting_app.data.ClimbPosition;
import com.team3663.scouting_app.utility.CPR_Network;
import com.team3663.scouting_app.utility.Logger;
import com.team3663.scouting_app.utility.achievements.Achievements;
import com.team3663.scouting_app.utility.dataFile.*;
import com.team3663.scouting_app.dataFile.*;

import java.util.HashMap;

Expand All @@ -26,10 +23,9 @@ public class Globals {
@SuppressLint("StaticFieldLeak") public static MatchesFile MatchList;
@SuppressLint("StaticFieldLeak") public static EventGroupsFile EventGroupList;
@SuppressLint("StaticFieldLeak") public static EventsFile EventList;

public static Accuracy AccuracyTypeList = new Accuracy();
public static ClimbLevel ClimbLevelList = new ClimbLevel();
public static ClimbPosition ClimbPositionList = new ClimbPosition();
@SuppressLint("StaticFieldLeak") public static ClimbPositionFile ClimbPositionList;
@SuppressLint("StaticFieldLeak") public static ClimbLevelFile ClimbLevelList;
@SuppressLint("StaticFieldLeak") public static AccuracyFile AccuracyList;

public static int CurrentAccuracy = Constants.PostMatch.ACCURACY_NOT_SELECTED;
public static int CurrentCompetitionId = 0;
Expand All @@ -38,14 +34,14 @@ public class Globals {
public static int CurrentColorId;
public static int CurrentPrefTeamPos;
public static int CurrentFieldOrientationPos;
public static int CurrentClimbPosition = Constants.PostMatch.CLIMB_POSITION_NOT_SELECTED;
public static int CurrentClimbLevel = Constants.PostMatch.CLIMB_LEVEL_NOT_SELECTED;
public static String CurrentMatchPhase = Constants.Phases.NONE;
public static String CurrentScoutingTeam;
public static String CurrentOverrideTeamNum;
public static String CurrentOverrideAlliance;
public static String CurrentTeamToScout;
public static String CurrentMatchType = Constants.PreMatch.DEFAULT_MATCH_TYPE;
public static String CurrentClimbLevel = Constants.PostMatch.CLIMB_LEVEL_NOT_SELECTED;
public static String CurrentClimbPosition = Constants.PostMatch.CLIMB_POSITION_NOT_SELECTED;

public static String CheckBoxTextPadding = " ";

Expand Down
Loading