mirror of
https://github.com/Team4388/RidgeScout.git
synced 2026-06-09 08:38:03 -06:00
Work on adding blankable fields
This commit is contained in:
@@ -60,13 +60,13 @@ public class ScoutingDataWriter {
|
|||||||
|
|
||||||
for(int i = 0; i < values[version].length; i++){
|
for(int i = 0; i < values[version].length; i++){
|
||||||
switch (objects.get(i+2).getType()){
|
switch (objects.get(i+2).getType()){
|
||||||
case 0:
|
case 1:
|
||||||
dataTypes[i] = new intType(values[version][i].name, (int) objects.get(i+2).get());
|
dataTypes[i] = new intType(values[version][i].name, (int) objects.get(i+2).get());
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 2:
|
||||||
String name = values[version][i].name;
|
String name = values[version][i].name;
|
||||||
String value = (String) objects.get(i+2).get();
|
String value = (String) objects.get(i+2).get();
|
||||||
dataTypes[i] = new stringType(name,value);
|
dataTypes[i] = new stringType(name, value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ public abstract class dataType {
|
|||||||
}
|
}
|
||||||
public String name;
|
public String name;
|
||||||
public Object value;
|
public Object value;
|
||||||
|
|
||||||
|
public abstract boolean isNull();
|
||||||
|
// public abstract Object getNullValue();
|
||||||
public abstract valueTypes getValueType();
|
public abstract valueTypes getValueType();
|
||||||
public Object get(){
|
public Object get(){
|
||||||
return value;
|
return value;
|
||||||
|
|||||||
@@ -1,9 +1,21 @@
|
|||||||
package com.astatin3.scoutingapp2025.types.data;
|
package com.astatin3.scoutingapp2025.types.data;
|
||||||
|
|
||||||
public class intType extends dataType{
|
public class intType extends dataType {
|
||||||
public valueTypes getValueType() {return valueTypes.NUM;}
|
private static final int nulval = 255;
|
||||||
public intType(String name, int value){
|
|
||||||
|
public valueTypes getValueType() {
|
||||||
|
return valueTypes.NUM;
|
||||||
|
}
|
||||||
|
|
||||||
|
public intType(String name, int value) {
|
||||||
super(name);
|
super(name);
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isNull() {
|
||||||
|
return ((int) value) == nulval;
|
||||||
|
}
|
||||||
|
public static Object getNullValue(){
|
||||||
|
return nulval;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,17 @@
|
|||||||
package com.astatin3.scoutingapp2025.types.data;
|
package com.astatin3.scoutingapp2025.types.data;
|
||||||
|
|
||||||
public class stringType extends dataType{
|
public class stringType extends dataType{
|
||||||
|
private static final String nulval = "Joe";
|
||||||
|
|
||||||
public valueTypes getValueType() {return valueTypes.STRING;}
|
public valueTypes getValueType() {return valueTypes.STRING;}
|
||||||
public stringType(String name, String value){
|
public stringType(String name, String value){
|
||||||
super(name);
|
super(name);
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
public boolean isNull(){
|
||||||
|
return value.equals(nulval);
|
||||||
|
}
|
||||||
|
public static Object getNullValue(){
|
||||||
|
return nulval;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,6 +109,7 @@ public class dropdownType extends inputType {
|
|||||||
}
|
}
|
||||||
public dataType getViewValue(){
|
public dataType getViewValue(){
|
||||||
if(dropdown == null) return null;
|
if(dropdown == null) return null;
|
||||||
|
if(dropdown.getVisibility() == View.GONE) return new intType(name, (int)intType.getNullValue());
|
||||||
return new intType(name, dropdown.getSelectedIndex());
|
return new intType(name, dropdown.getSelectedIndex());
|
||||||
}
|
}
|
||||||
public void add_individual_view(LinearLayout parent, dataType data){
|
public void add_individual_view(LinearLayout parent, dataType data){
|
||||||
|
|||||||
@@ -2,8 +2,11 @@ package com.astatin3.scoutingapp2025.types.input;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.CheckBox;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
|
||||||
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||||
|
|
||||||
import com.astatin3.scoutingapp2025.types.data.dataType;
|
import com.astatin3.scoutingapp2025.types.data.dataType;
|
||||||
import com.astatin3.scoutingapp2025.utility.BuiltByteParser;
|
import com.astatin3.scoutingapp2025.utility.BuiltByteParser;
|
||||||
import com.astatin3.scoutingapp2025.utility.ByteBuilder;
|
import com.astatin3.scoutingapp2025.utility.ByteBuilder;
|
||||||
@@ -21,8 +24,6 @@ public abstract class inputType {
|
|||||||
NOTES_INPUT
|
NOTES_INPUT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public String name;
|
public String name;
|
||||||
public Object default_value;
|
public Object default_value;
|
||||||
public abstract inputTypes getInputType();
|
public abstract inputTypes getInputType();
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import android.widget.LinearLayout;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.astatin3.scoutingapp2025.types.data.dataType;
|
import com.astatin3.scoutingapp2025.types.data.dataType;
|
||||||
|
import com.astatin3.scoutingapp2025.types.data.intType;
|
||||||
import com.astatin3.scoutingapp2025.types.data.stringType;
|
import com.astatin3.scoutingapp2025.types.data.stringType;
|
||||||
import com.astatin3.scoutingapp2025.utility.BuiltByteParser;
|
import com.astatin3.scoutingapp2025.utility.BuiltByteParser;
|
||||||
import com.astatin3.scoutingapp2025.utility.ByteBuilder;
|
import com.astatin3.scoutingapp2025.utility.ByteBuilder;
|
||||||
@@ -64,6 +65,7 @@ public class notesType extends inputType {
|
|||||||
}
|
}
|
||||||
public dataType getViewValue(){
|
public dataType getViewValue(){
|
||||||
if(text == null) return null;
|
if(text == null) return null;
|
||||||
|
if(text.getVisibility() == View.GONE) return new stringType(name, (String) stringType.getNullValue());
|
||||||
return new stringType(name, text.getText().toString());
|
return new stringType(name, text.getText().toString());
|
||||||
}
|
}
|
||||||
public void add_individual_view(LinearLayout parent, dataType data){
|
public void add_individual_view(LinearLayout parent, dataType data){
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import androidx.annotation.NonNull;
|
|||||||
|
|
||||||
import com.astatin3.scoutingapp2025.types.data.dataType;
|
import com.astatin3.scoutingapp2025.types.data.dataType;
|
||||||
import com.astatin3.scoutingapp2025.types.data.intType;
|
import com.astatin3.scoutingapp2025.types.data.intType;
|
||||||
|
import com.astatin3.scoutingapp2025.types.data.stringType;
|
||||||
import com.astatin3.scoutingapp2025.utility.BuiltByteParser;
|
import com.astatin3.scoutingapp2025.utility.BuiltByteParser;
|
||||||
import com.astatin3.scoutingapp2025.utility.ByteBuilder;
|
import com.astatin3.scoutingapp2025.utility.ByteBuilder;
|
||||||
import com.github.mikephil.charting.charts.LineChart;
|
import com.github.mikephil.charting.charts.LineChart;
|
||||||
@@ -81,7 +82,8 @@ public class sliderType extends inputType {
|
|||||||
}
|
}
|
||||||
public dataType getViewValue(){
|
public dataType getViewValue(){
|
||||||
if(slider == null) return null;
|
if(slider == null) return null;
|
||||||
return new intType(name, min + (int) (slider.getValue() * (max-min)));
|
if(slider.getVisibility() == View.GONE) return new intType(name, (int) intType.getNullValue());
|
||||||
|
return new intType(name, min + (int) (slider.getValue() * (max-min)));
|
||||||
}
|
}
|
||||||
public void add_individual_view(LinearLayout parent, dataType data){
|
public void add_individual_view(LinearLayout parent, dataType data){
|
||||||
Slider slider = new Slider(parent.getContext());
|
Slider slider = new Slider(parent.getContext());
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ public class dataFragment extends Fragment {
|
|||||||
// binding.teamsView.setVisibility(View.VISIBLE);
|
// binding.teamsView.setVisibility(View.VISIBLE);
|
||||||
// binding.teamsView.init(binding, event);
|
// binding.teamsView.init(binding, event);
|
||||||
// submenu = true;
|
// submenu = true;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
binding.fieldsButton.setOnClickListener(v -> {
|
binding.fieldsButton.setOnClickListener(v -> {
|
||||||
@@ -90,6 +91,7 @@ public class dataFragment extends Fragment {
|
|||||||
binding.buttons.setVisibility(View.VISIBLE);
|
binding.buttons.setVisibility(View.VISIBLE);
|
||||||
binding.statusView.setVisibility(View.GONE);
|
binding.statusView.setVisibility(View.GONE);
|
||||||
binding.teamsView.setVisibility(View.GONE);
|
binding.teamsView.setVisibility(View.GONE);
|
||||||
|
binding.fieldsView.setVisibility(View.GONE);
|
||||||
submenu = false;
|
submenu = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ public class fieldsView extends ConstraintLayout {
|
|||||||
this.binding = binding;
|
this.binding = binding;
|
||||||
|
|
||||||
binding.fieldsSelectButtons.setVisibility(VISIBLE);
|
binding.fieldsSelectButtons.setVisibility(VISIBLE);
|
||||||
|
binding.fieldsArea.removeAllViews();
|
||||||
binding.fieldsSelectButtons.bringToFront();
|
binding.fieldsSelectButtons.bringToFront();
|
||||||
|
|
||||||
binding.fieldsArea.setStretchAllColumns(true);
|
binding.fieldsArea.setStretchAllColumns(true);
|
||||||
|
|||||||
@@ -2,7 +2,9 @@ package com.astatin3.scoutingapp2025.ui.scouting;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
import android.util.TypedValue;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.CheckBox;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||||
@@ -13,6 +15,7 @@ import com.astatin3.scoutingapp2025.SettingsVersionStack.latestSettings;
|
|||||||
import com.astatin3.scoutingapp2025.databinding.FragmentScoutingBinding;
|
import com.astatin3.scoutingapp2025.databinding.FragmentScoutingBinding;
|
||||||
import com.astatin3.scoutingapp2025.scoutingData.transfer.transferType;
|
import com.astatin3.scoutingapp2025.scoutingData.transfer.transferType;
|
||||||
import com.astatin3.scoutingapp2025.types.data.dataType;
|
import com.astatin3.scoutingapp2025.types.data.dataType;
|
||||||
|
import com.astatin3.scoutingapp2025.types.data.intType;
|
||||||
import com.astatin3.scoutingapp2025.types.input.inputType;
|
import com.astatin3.scoutingapp2025.types.input.inputType;
|
||||||
import com.astatin3.scoutingapp2025.utility.fileEditor;
|
import com.astatin3.scoutingapp2025.utility.fileEditor;
|
||||||
import com.astatin3.scoutingapp2025.types.frcEvent;
|
import com.astatin3.scoutingapp2025.types.frcEvent;
|
||||||
@@ -147,8 +150,7 @@ public class matchScoutingView extends ConstraintLayout {
|
|||||||
update_scouting_data();
|
update_scouting_data();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int default_text_color = 0;
|
||||||
|
|
||||||
|
|
||||||
private void create_fields(){
|
private void create_fields(){
|
||||||
if(asm.isRunning){
|
if(asm.isRunning){
|
||||||
@@ -156,13 +158,15 @@ public class matchScoutingView extends ConstraintLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 0 ; i < latest_values.length; i++) {
|
for(int i = 0 ; i < latest_values.length; i++) {
|
||||||
TextView tv = new TextView(getContext());
|
final TextView tv = new TextView(getContext());
|
||||||
tv.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
|
tv.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
|
||||||
tv.setText(latest_values[i].name);
|
tv.setText(latest_values[i].name);
|
||||||
|
tv.setPadding(8,8,8,8);
|
||||||
tv.setTextSize(24);
|
tv.setTextSize(24);
|
||||||
binding.MatchScoutArea.addView(tv);
|
|
||||||
|
|
||||||
View v = latest_values[i].createView(getContext(), new Function<dataType, Integer>() {
|
default_text_color = tv.getCurrentTextColor();
|
||||||
|
|
||||||
|
final View v = latest_values[i].createView(getContext(), new Function<dataType, Integer>() {
|
||||||
@Override
|
@Override
|
||||||
public Integer apply(dataType dataType) {
|
public Integer apply(dataType dataType) {
|
||||||
// edited = true;
|
// edited = true;
|
||||||
@@ -172,6 +176,26 @@ public class matchScoutingView extends ConstraintLayout {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
binding.MatchScoutArea.addView(tv);
|
||||||
|
int fi = i;
|
||||||
|
tv.setOnClickListener(p -> {
|
||||||
|
boolean blank = latest_values[fi].getViewValue().isNull();
|
||||||
|
|
||||||
|
System.out.println(blank);
|
||||||
|
|
||||||
|
if(blank){
|
||||||
|
tv.setBackgroundColor(0xffff0000);
|
||||||
|
tv.setTextColor(0xff000000);
|
||||||
|
v.setVisibility(GONE);
|
||||||
|
latest_values[fi].setViewValue(intType.getNullValue());
|
||||||
|
}else{
|
||||||
|
tv.setBackgroundColor(0x00000000);
|
||||||
|
tv.setTextColor(default_text_color);
|
||||||
|
v.setVisibility(VISIBLE);
|
||||||
|
latest_values[fi].setViewValue(latest_values[fi].default_value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
binding.MatchScoutArea.addView(v);
|
binding.MatchScoutArea.addView(v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,10 +4,11 @@ import java.nio.charset.StandardCharsets;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class BuiltByteParser {
|
public class BuiltByteParser {
|
||||||
public static final Integer intType = 0;
|
public static final Integer boolType = 0;
|
||||||
public static final Integer stringType = 1;
|
public static final Integer intType = 1;
|
||||||
public static final Integer intArrayType = 2;
|
public static final Integer stringType = 2;
|
||||||
public static final Integer stringArrayType = 3;
|
public static final Integer intArrayType = 3;
|
||||||
|
public static final Integer stringArrayType = 4;
|
||||||
|
|
||||||
public class byteParsingExeption extends Exception {
|
public class byteParsingExeption extends Exception {
|
||||||
public byteParsingExeption() {}
|
public byteParsingExeption() {}
|
||||||
@@ -22,6 +23,11 @@ public class BuiltByteParser {
|
|||||||
public abstract Object get();
|
public abstract Object get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class boolObject extends parsedObject{
|
||||||
|
boolean val;
|
||||||
|
public Integer getType(){return boolType;}
|
||||||
|
public Object get(){return val;}
|
||||||
|
}
|
||||||
|
|
||||||
public class intObject extends parsedObject{
|
public class intObject extends parsedObject{
|
||||||
int num;
|
int num;
|
||||||
@@ -83,16 +89,21 @@ public class BuiltByteParser {
|
|||||||
|
|
||||||
switch(type){
|
switch(type){
|
||||||
case 0:
|
case 0:
|
||||||
|
boolObject bo = new boolObject();
|
||||||
|
bo.val = block[0] == (byte) 1;
|
||||||
|
objects.add(bo);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
intObject io = new intObject();
|
intObject io = new intObject();
|
||||||
io.num = fileEditor.fromBytes(block, length);
|
io.num = fileEditor.fromBytes(block, length);
|
||||||
objects.add(io);
|
objects.add(io);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 2:
|
||||||
stringObject so = new stringObject();
|
stringObject so = new stringObject();
|
||||||
so.str = new String(block, StandardCharsets.UTF_8);
|
so.str = new String(block, StandardCharsets.UTF_8);
|
||||||
objects.add(so);
|
objects.add(so);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 3:
|
||||||
BuiltByteParser int_bbp = new BuiltByteParser(block);
|
BuiltByteParser int_bbp = new BuiltByteParser(block);
|
||||||
ArrayList<parsedObject> intArrayObjects = int_bbp.parse();
|
ArrayList<parsedObject> intArrayObjects = int_bbp.parse();
|
||||||
|
|
||||||
@@ -106,7 +117,7 @@ public class BuiltByteParser {
|
|||||||
ia.arr = intArr;
|
ia.arr = intArr;
|
||||||
objects.add(ia);
|
objects.add(ia);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 4:
|
||||||
|
|
||||||
BuiltByteParser str_bbp = new BuiltByteParser(block);
|
BuiltByteParser str_bbp = new BuiltByteParser(block);
|
||||||
ArrayList<parsedObject> strArrayObjects = str_bbp.parse();
|
ArrayList<parsedObject> strArrayObjects = str_bbp.parse();
|
||||||
|
|||||||
@@ -4,10 +4,11 @@ import java.nio.charset.StandardCharsets;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class ByteBuilder {
|
public class ByteBuilder {
|
||||||
public static final int int_id = 0;
|
public static final int bool_id = 0;
|
||||||
public static final int string_id = 1;
|
public static final int int_id = 1;
|
||||||
public static final int int_arr_id = 2;
|
public static final int string_id = 2;
|
||||||
public static final int string_arr_id = 3;
|
public static final int int_arr_id = 3;
|
||||||
|
public static final int string_arr_id = 4;
|
||||||
|
|
||||||
ArrayList<byteType> bytesToBuild = new ArrayList<>();
|
ArrayList<byteType> bytesToBuild = new ArrayList<>();
|
||||||
|
|
||||||
@@ -24,6 +25,23 @@ public class ByteBuilder {
|
|||||||
public abstract byte[] build();
|
public abstract byte[] build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class boolType extends byteType {
|
||||||
|
public boolean val;
|
||||||
|
public byte getType(){return bool_id;}
|
||||||
|
public int length(){return 1;}
|
||||||
|
public byte[] build(){
|
||||||
|
return new byte[]{(byte) (val ? 1 : 0)};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ByteBuilder addBool(boolean n) throws buildingException {
|
||||||
|
boolType boolType = new boolType();
|
||||||
|
boolType.val = n;
|
||||||
|
|
||||||
|
bytesToBuild.add(boolType);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
private class intType extends byteType {
|
private class intType extends byteType {
|
||||||
public int precision;
|
public int precision;
|
||||||
public int num;
|
public int num;
|
||||||
|
|||||||
Reference in New Issue
Block a user