diff --git a/app/src/main/java/com/ridgebotics/ridgescout/types/input/checkboxType.java b/app/src/main/java/com/ridgebotics/ridgescout/types/input/checkboxType.java index a44e7a4..a7fa369 100644 --- a/app/src/main/java/com/ridgebotics/ridgescout/types/input/checkboxType.java +++ b/app/src/main/java/com/ridgebotics/ridgescout/types/input/checkboxType.java @@ -69,15 +69,11 @@ public class checkboxType extends inputType { public View createView(Context context, Function onUpdate){ checkBox = new CheckBox(context); + checkBox.setTextAppearance(com.google.android.material.R.style.TextAppearance_MaterialComponents_Headline6); checkBox.setText(name); setViewValue(default_value); - checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - onUpdate.apply(getViewValue()); - } - }); + checkBox.setOnCheckedChangeListener((buttonView, isChecked) -> onUpdate.apply(getViewValue())); return checkBox; @@ -112,7 +108,7 @@ public class checkboxType extends inputType { public void add_individual_view(LinearLayout parent, dataType data){ if(data.isNull()) return; CheckBox cb = new CheckBox(parent.getContext()); - cb.setTextAppearance(com.google.android.material.R.style.TextAppearance_MaterialComponents_Headline1); + cb.setTextAppearance(com.google.android.material.R.style.TextAppearance_MaterialComponents_Headline6); cb.setText(name); cb.setChecked((int) data.get() == 1); cb.setEnabled(false); diff --git a/app/src/main/java/com/ridgebotics/ridgescout/types/input/fieldposType.java b/app/src/main/java/com/ridgebotics/ridgescout/types/input/fieldposType.java index 51358da..316ec6a 100644 --- a/app/src/main/java/com/ridgebotics/ridgescout/types/input/fieldposType.java +++ b/app/src/main/java/com/ridgebotics/ridgescout/types/input/fieldposType.java @@ -87,6 +87,10 @@ public class fieldposType extends inputType { nullify(); return; } + if(((int[]) value)[0] == 255 && ((int[]) value)[1] == 255){ + nullify(); + return; + } isBlank = false; field.setVisibility(View.VISIBLE); diff --git a/app/src/main/java/com/ridgebotics/ridgescout/types/input/tallyType.java b/app/src/main/java/com/ridgebotics/ridgescout/types/input/tallyType.java index ba2aac6..68333d6 100644 --- a/app/src/main/java/com/ridgebotics/ridgescout/types/input/tallyType.java +++ b/app/src/main/java/com/ridgebotics/ridgescout/types/input/tallyType.java @@ -75,7 +75,6 @@ public class tallyType extends inputType { public void setViewValue(Object value) { if(tally == null) return; - System.out.println(value); if(intType.isNull((int)value)){ nullify(); return; diff --git a/app/src/main/java/com/ridgebotics/ridgescout/ui/ToggleTitleView.java b/app/src/main/java/com/ridgebotics/ridgescout/ui/ToggleTitleView.java index 9cda503..2d63f81 100644 --- a/app/src/main/java/com/ridgebotics/ridgescout/ui/ToggleTitleView.java +++ b/app/src/main/java/com/ridgebotics/ridgescout/ui/ToggleTitleView.java @@ -35,7 +35,6 @@ public class ToggleTitleView extends ConstraintLayout { OnToggleListener onToggleListener; - private static final int default_text_color = 0xffffffff; public void init(Context context){ LayoutInflater.from(context).inflate(R.layout.view_toggle_title, this, true); @@ -45,7 +44,10 @@ public class ToggleTitleView extends ConstraintLayout { toggle_title_description = findViewById(R.id.toggle_title_description); toggle_title_checkbox.setOnCheckedChangeListener((compoundButton, checked) -> { - if(checked) + // If checkbox has already updated + if(enabled == checked) return; + + if (checked) enable(); else disable(); @@ -83,6 +85,12 @@ public class ToggleTitleView extends ConstraintLayout { toggle_title_description.setVisibility(View.VISIBLE); setBackgroundColor(0x00000000); titleView.setTextAppearance(com.google.android.material.R.style.TextAppearance_MaterialComponents_Headline5); -// titleView.setTextAppearance(com.google.android.material.R.style.TextAppearance_MaterialComponents_Headline5); + } + + public void setEnabled(boolean enabled){ + if(enabled) + disable(); + else + enable(); } } diff --git a/app/src/main/java/com/ridgebotics/ridgescout/ui/data/TeamsFragment.java b/app/src/main/java/com/ridgebotics/ridgescout/ui/data/TeamsFragment.java index fc8a022..d1229af 100644 --- a/app/src/main/java/com/ridgebotics/ridgescout/ui/data/TeamsFragment.java +++ b/app/src/main/java/com/ridgebotics/ridgescout/ui/data/TeamsFragment.java @@ -44,22 +44,30 @@ public class TeamsFragment extends Fragment { team = tmpteam; } - private static final int background_color = 0x5000ff00; - private static final int unsaved_background_color = 0x2000ff00; public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { binding = FragmentDataTeamsBinding.inflate(inflater, container, false); - binding.teamsArea.removeAllViews(); - DataManager.reload_match_fields(); DataManager.reload_pit_fields(); - TableLayout table = new TableLayout(getContext()); - table.setStretchAllColumns(true); - binding.teamsArea.addView(table); + binding.dataTypeSpinner.setTitle("Data Mode"); + + List options = new ArrayList<>(); + options.add("Individual"); + options.add("Compiled"); + options.add("History"); + + binding.dataTypeSpinner.setOptions(options, 0); + + binding.dataTypeSpinner.setOnClickListener((item, index) -> { + settingsManager.setDataMode(index); + loadTeam(index); + }); + +// binding.teamsMainElem. loadTeam(settingsManager.getDataMode()); @@ -67,92 +75,57 @@ public class TeamsFragment extends Fragment { } public void loadTeam(int mode) { - binding.teamsArea.removeAllViews(); - LinearLayout ll = new LinearLayout(getContext()); - ll.setLayoutParams(new LinearLayout.LayoutParams( - ViewGroup.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.WRAP_CONTENT - )); - ll.setOrientation(LinearLayout.VERTICAL); - binding.teamsArea.addView(ll); +// LinearLayout ll = new LinearLayout(getContext()); +// ll.setLayoutParams(new LinearLayout.LayoutParams( +// ViewGroup.LayoutParams.MATCH_PARENT, +// ViewGroup.LayoutParams.WRAP_CONTENT +// )); +// ll.setOrientation(LinearLayout.VERTICAL); +// binding.teamsArea.addView(ll); - CustomSpinnerView dropdown = new CustomSpinnerView(getContext()); - dropdown.setTitle("Data Mode"); - List options = new ArrayList<>(); - options.add("Individual"); - options.add("Compiled"); - options.add("History"); + binding.teamName2.setText(String.valueOf(team.teamNumber)); - dropdown.setOptions(options, mode); + binding.teamDescription2.setText(team.getDescription()); - dropdown.setOnClickListener((item, index) -> { - System.out.println(index); - settingsManager.setDataMode(index); - loadTeam(index); - }); +// tv = new TextView(getContext()); +// tv.setLayoutParams(new FrameLayout.LayoutParams( +// ViewGroup.LayoutParams.MATCH_PARENT, +// ViewGroup.LayoutParams.WRAP_CONTENT +// )); +// tv.setGravity(Gravity.CENTER_HORIZONTAL); +// tv.setText(team.getDescription()); +// tv.setTextSize(16); +// ll.addView(tv); - ll.addView(dropdown); - - - - TextView tv = new TextView(getContext()); - tv.setLayoutParams(new FrameLayout.LayoutParams( - ViewGroup.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.WRAP_CONTENT - )); - tv.setGravity(Gravity.CENTER_HORIZONTAL); - tv.setText(String.valueOf(team.teamNumber)); - tv.setTextSize(28); - ll.addView(tv); - - tv = new TextView(getContext()); - tv.setLayoutParams(new FrameLayout.LayoutParams( - ViewGroup.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.WRAP_CONTENT - )); - tv.setGravity(Gravity.CENTER_HORIZONTAL); - tv.setText(team.teamName); - tv.setTextSize(28); - ll.addView(tv); - - tv = new TextView(getContext()); - tv.setLayoutParams(new FrameLayout.LayoutParams( - ViewGroup.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.WRAP_CONTENT - )); - tv.setGravity(Gravity.CENTER_HORIZONTAL); - tv.setText(team.getDescription()); - tv.setTextSize(16); - ll.addView(tv); - - add_pit_data(ll, team); - add_match_data(ll, team, mode); + add_pit_data(team); + add_match_data(team, mode); } - public void add_pit_data(LinearLayout ll, frcTeam team){ + public void add_pit_data(frcTeam team){ + binding.pitArea.removeAllViews(); final String filename = evcode+"-"+team.teamNumber+".pitscoutdata"; - ll.addView(new MaterialDivider(getContext())); +// ll.addView(new MaterialDivider(getContext())); - TextView tv = new TextView(getContext()); - tv.setLayoutParams(new FrameLayout.LayoutParams( - ViewGroup.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.WRAP_CONTENT - )); - tv.setGravity(Gravity.CENTER_HORIZONTAL); - tv.setPadding(0,10,0,10); - tv.setText("----- Pit data -----"); - tv.setTextSize(30); - ll.addView(tv); +// TextView tv = new TextView(getContext()); +// tv.setLayoutParams(new FrameLayout.LayoutParams( +// ViewGroup.LayoutParams.MATCH_PARENT, +// ViewGroup.LayoutParams.WRAP_CONTENT +// )); +// tv.setGravity(Gravity.CENTER_HORIZONTAL); +// tv.setPadding(0,10,0,10); +// tv.setText("----- Pit data -----"); +// tv.setTextSize(30); +// ll.addView(tv); - ll.addView(new MaterialDivider(getContext())); +// ll.addView(new MaterialDivider(getContext())); if(!fileEditor.fileExist(filename)){ - tv = new TextView(getContext()); + TextView tv = new TextView(getContext()); tv.setLayoutParams(new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT @@ -160,13 +133,13 @@ public class TeamsFragment extends Fragment { tv.setGravity(Gravity.CENTER_HORIZONTAL); tv.setText("No pit data has been collected!"); tv.setTextSize(23); - ll.addView(tv); + binding.pitArea.addView(tv); return; } ScoutingDataWriter.ParsedScoutingDataResult psda = ScoutingDataWriter.load(filename, pit_values, pit_transferValues); - tv = new TextView(getContext()); + TextView tv = new TextView(getContext()); tv.setLayoutParams(new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT @@ -175,7 +148,7 @@ public class TeamsFragment extends Fragment { tv.setGravity(Gravity.CENTER_HORIZONTAL); tv.setText("Pit scouting by " + psda.username); tv.setTextSize(30); - ll.addView(tv); + binding.pitArea.addView(tv); for (int a = 0; a < psda.data.array.length; a++) { tv = new TextView(getContext()); @@ -193,38 +166,24 @@ public class TeamsFragment extends Fragment { } - ll.addView(tv); + + binding.pitArea.addView(tv); - pit_latest_values[a].add_individual_view(ll, psda.data.array[a]); + pit_latest_values[a].add_individual_view(binding.pitArea, psda.data.array[a]); } } + private int matchIndex = 0; - - public void add_match_data(LinearLayout ll, frcTeam team, int mode){ + public void add_match_data(frcTeam team, int mode){ + binding.matchArea.removeAllViews(); + binding.individualViewSelector.setVisibility(View.GONE); String[] files = fileEditor.getMatchesByTeamNum(evcode, team.teamNumber); - ll.addView(new MaterialDivider(getContext())); - - TextView tv = new TextView(getContext()); - tv.setLayoutParams(new FrameLayout.LayoutParams( - ViewGroup.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.WRAP_CONTENT - )); - tv.setGravity(Gravity.CENTER_HORIZONTAL); - tv.setText("----- Match data -----"); - tv.setPadding(0,10,0,10); - tv.setTextSize(30); - ll.addView(tv); - - ll.addView(new MaterialDivider(getContext())); - - - if(files.length == 0){ - tv = new TextView(getContext()); + TextView tv = new TextView(getContext()); tv.setLayoutParams(new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT @@ -232,19 +191,19 @@ public class TeamsFragment extends Fragment { tv.setGravity(Gravity.CENTER_HORIZONTAL); tv.setText("No match data has been collected!"); tv.setTextSize(23); - ll.addView(tv); + binding.matchArea.addView(tv); return; } switch (mode){ case 0: - add_individual_views(ll,files); + add_individual_views(files); break; case 1: - add_compiled_views(ll,files); + add_compiled_views(files); break; case 2: - add_history_views(ll,files); + add_history_views(files); break; } } @@ -252,50 +211,75 @@ public class TeamsFragment extends Fragment { - public void add_individual_views(LinearLayout ll, String[] files) { - for (int i = 0; i < files.length; i++) { - try { - String[] split = files[i].split("-"); - int match_num = Integer.parseInt(split[1]); + public void add_individual_views(String[] files) { - ScoutingDataWriter.ParsedScoutingDataResult psda = ScoutingDataWriter.load(files[i], match_values, match_transferValues); - TextView tv = new TextView(getContext()); + matchIndex = 0; + + binding.individualViewSelector.setVisibility(View.VISIBLE); + + binding.matchesPlusBtn.setOnClickListener(view -> { + matchIndex++; + update_individual_view(files); + }); + + binding.matchesMinusBtn.setOnClickListener(view -> { + matchIndex--; + update_individual_view(files); + }); + + update_individual_view(files); + } + + private void update_individual_view(String[] files){ + binding.matchesPlusBtn.setEnabled(matchIndex < files.length - 1); + binding.matchesMinusBtn.setEnabled(matchIndex > 0); + binding.matchArea.removeAllViews(); + + + try { + String[] split = files[matchIndex].split("-"); + int match_num = Integer.parseInt(split[1]); + binding.matchNum.setText(split[1]); + + ScoutingDataWriter.ParsedScoutingDataResult psda = ScoutingDataWriter.load(files[matchIndex], match_values, match_transferValues); + + TextView tv = new TextView(getContext()); + tv.setLayoutParams(new FrameLayout.LayoutParams( + ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.WRAP_CONTENT + )); + tv.setPadding(0, 40, 0, 5); + tv.setGravity(Gravity.CENTER_HORIZONTAL); + tv.setText("M" + (match_num) + " " + split[2] + "-" + split[3] + " by " + psda.username); + tv.setTextSize(30); + binding.matchArea.addView(tv); + + for (int i = 0; i < psda.data.array.length; i++) { + tv = new TextView(getContext()); tv.setLayoutParams(new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT )); - tv.setPadding(0, 40, 0, 5); tv.setGravity(Gravity.CENTER_HORIZONTAL); - tv.setText("M" + (match_num) + " " + split[2] + "-" + split[3] + " by " + psda.username); - tv.setTextSize(30); - ll.addView(tv); + tv.setText(psda.data.array[i].getName()); + tv.setTextSize(25); - for (int a = 0; a < psda.data.array.length; a++) { - tv = new TextView(getContext()); - tv.setLayoutParams(new FrameLayout.LayoutParams( - ViewGroup.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.WRAP_CONTENT - )); - tv.setGravity(Gravity.CENTER_HORIZONTAL); - tv.setText(psda.data.array[a].getName()); - tv.setTextSize(25); - - if (psda.data.array[a].isNull()) { - tv.setBackgroundColor(0xffff0000); - tv.setTextColor(0xff000000); - } - - ll.addView(tv); - - - match_latest_values[a].add_individual_view(ll, psda.data.array[a]); + if (psda.data.array[i].isNull()) { + tv.setBackgroundColor(0xffff0000); + tv.setTextColor(0xff000000); } - }catch (Exception e){ - e.printStackTrace(); - AlertManager.alert("Warning!", "Failure to load file " + files[i]); + + binding.matchArea.addView(tv); + + + match_latest_values[i].add_individual_view(binding.matchArea, psda.data.array[i]); } + }catch (Exception e){ + e.printStackTrace(); + AlertManager.alert("Warning!", "Failure to load file " + files[matchIndex]); } + } @@ -303,7 +287,7 @@ public class TeamsFragment extends Fragment { - public void add_compiled_views(LinearLayout ll, String[] files){ + public void add_compiled_views(String[] files){ dataType[][] data = new dataType[match_latest_values.length][files.length]; for (int i = 0; i < files.length; i++) { try { @@ -327,9 +311,9 @@ public class TeamsFragment extends Fragment { tv.setGravity(Gravity.CENTER_HORIZONTAL); tv.setText(match_latest_values[i].name); tv.setTextSize(30); - ll.addView(tv); + binding.matchArea.addView(tv); - match_latest_values[i].add_compiled_view(ll, data[i]); + match_latest_values[i].add_compiled_view(binding.matchArea, data[i]); } } @@ -337,7 +321,7 @@ public class TeamsFragment extends Fragment { - public void add_history_views(LinearLayout ll, String[] files){ + public void add_history_views(String[] files){ dataType[][] data = new dataType[match_latest_values.length][files.length]; for (int i = 0; i < files.length; i++) { try { @@ -361,9 +345,9 @@ public class TeamsFragment extends Fragment { tv.setGravity(Gravity.CENTER_HORIZONTAL); tv.setText(match_latest_values[i].name); tv.setTextSize(30); - ll.addView(tv); + binding.matchArea.addView(tv); - match_latest_values[i].add_history_view(ll, data[i]); + match_latest_values[i].add_history_view(binding.matchArea, data[i]); } } } diff --git a/app/src/main/java/com/ridgebotics/ridgescout/ui/scouting/MatchScoutingFragment.java b/app/src/main/java/com/ridgebotics/ridgescout/ui/scouting/MatchScoutingFragment.java index ff4d216..02befe8 100644 --- a/app/src/main/java/com/ridgebotics/ridgescout/ui/scouting/MatchScoutingFragment.java +++ b/app/src/main/java/com/ridgebotics/ridgescout/ui/scouting/MatchScoutingFragment.java @@ -65,16 +65,6 @@ public class MatchScoutingFragment extends Fragment { - - cur_match_num = settingsManager.getMatchNum(); - - if(cur_match_num >= event.matches.size()) { - cur_match_num = 0; - settingsManager.setMatchNum(0); - } - - update_match_num(); - binding.nextButton.setOnClickListener(v -> { if(edited) save(); settingsManager.setMatchNum(cur_match_num+1); @@ -111,6 +101,14 @@ public class MatchScoutingFragment extends Fragment { // if(edited) save(); // }); + cur_match_num = settingsManager.getMatchNum(); + + if(cur_match_num >= event.matches.size()) { + cur_match_num = 0; + settingsManager.setMatchNum(0); + } + + update_match_num(); create_fields(); update_scouting_data(); @@ -142,15 +140,10 @@ public class MatchScoutingFragment extends Fragment { int cur_match_num; String username; String filename; - boolean edited = false; - ToggleTitleView[] titles; - AutoSaveManager asm = new AutoSaveManager(this::save); - ArrayList dataTypes; - public void save(){ @@ -203,16 +196,11 @@ public class MatchScoutingFragment extends Fragment { final ToggleTitleView ttv = new ToggleTitleView(getContext()); ttv.setTitle(DataManager.match_latest_values[i].name); ttv.setDescription(DataManager.match_latest_values[i].description); -// final TextView tv = new TextView(getContext()); -// tv.setTextAlignment(View.TEXT_ALIGNMENT_CENTER); -// tv.setText(DataManager.match_latest_values[i].name); -// tv.setPadding(8,8,8,8); -// tv.setTextSize(24); titles[i] = ttv; final View v = DataManager.match_latest_values[i].createView(getContext(), dataType -> { -// edited = true; +// edited = true; if(asm.isRunning) update_asm(); return 0; @@ -225,19 +213,14 @@ public class MatchScoutingFragment extends Fragment { if(asm.isRunning) update_asm(); +// System.out.println("Checked!"); + if(enabled){ DataManager.match_latest_values[fi].nullify(); - }else{ + }else DataManager.match_latest_values[fi].setViewValue(DataManager.match_latest_values[fi].default_value); - } }); - ttv.setOnClickListener(p -> { -// boolean blank = !latest_values[fi].getViewValue().isNull(); - -// System.out.println(blank); - - }); binding.MatchScoutArea.addView(v); } @@ -360,6 +343,7 @@ public class MatchScoutingFragment extends Fragment { ScoutingDataWriter.ParsedScoutingDataResult psdr = ScoutingDataWriter.load(filename, DataManager.match_values, DataManager.match_transferValues); dataType[] types = psdr.data.array; + for(int i = 0; i < DataManager.match_latest_values.length; i++){ // types[i] = latest_values[i].getViewValue(); try { @@ -369,12 +353,8 @@ public class MatchScoutingFragment extends Fragment { DataManager.match_latest_values[i].setViewValue(DataManager.match_latest_values[i].default_value); } + titles[i].setEnabled(DataManager.match_latest_values[i].isBlank); - if(DataManager.match_latest_values[i].isBlank){ - titles[i].disable(); - }else{ - titles[i].enable(); - } } } diff --git a/app/src/main/java/com/ridgebotics/ridgescout/utility/AlertManager.java b/app/src/main/java/com/ridgebotics/ridgescout/utility/AlertManager.java index 324eb67..f776db5 100644 --- a/app/src/main/java/com/ridgebotics/ridgescout/utility/AlertManager.java +++ b/app/src/main/java/com/ridgebotics/ridgescout/utility/AlertManager.java @@ -53,19 +53,17 @@ public class AlertManager { public static void error(Exception e) { e.printStackTrace(); - ((Activity) context).runOnUiThread(new Runnable() { - public void run() { - StringWriter sw = new StringWriter(); - e.printStackTrace(new PrintWriter(sw)); + ((Activity) context).runOnUiThread(() -> { + StringWriter sw = new StringWriter(); + e.printStackTrace(new PrintWriter(sw)); - AlertDialog.Builder alert = new AlertDialog.Builder(context); - alert.setMessage(sw.toString()); - alert.setTitle(e.getMessage()); - alert.setPositiveButton("OK", null); - alert.setCancelable(true); + AlertDialog.Builder alert = new AlertDialog.Builder(context); + alert.setMessage(sw.toString()); + alert.setTitle(e.getMessage()); + alert.setPositiveButton("OK", null); + alert.setCancelable(true); - alert.create().show(); - } + alert.create().show(); }); } diff --git a/app/src/main/res/drawable/border.xml b/app/src/main/res/drawable/border.xml index e48a19d..83c790d 100644 --- a/app/src/main/res/drawable/border.xml +++ b/app/src/main/res/drawable/border.xml @@ -1,7 +1,7 @@ - + + android:layout_height="match_parent"> - + android:layout_height="match_parent"> - + android:layout_height="match_parent" + android:orientation="vertical" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent"> - + - + + + + + + + + + + + + + + + +