mirror of
https://github.com/Team4388/RidgeScout.git
synced 2026-06-09 00:37:59 -06:00
Make FieldEditorHelper.java
This commit is contained in:
@@ -6,21 +6,22 @@ Ridgebotics 2025 scouting app in Android
|
|||||||
- Make the "Report" menu, A tool that lets users select data to display from the the teams and compare menus.
|
- Make the "Report" menu, A tool that lets users select data to display from the the teams and compare menus.
|
||||||
- Make practice mode
|
- Make practice mode
|
||||||
#### Data Analysis:
|
#### Data Analysis:
|
||||||
|
- Add CSV exporting of match scouting data.
|
||||||
- Statbotics intigration
|
- Statbotics intigration
|
||||||
- AI overview of scouting data for a team???
|
- AI overview of scouting data for a team???
|
||||||
#### Functionality:
|
#### Functionality:
|
||||||
- Make the system for blank and unselected fields better.
|
- Make the system for blank and unselected fields better.
|
||||||
- Add more types of data fields.
|
- Add more types of data fields.
|
||||||
- Make server software to allow for easy sync over wifi
|
- Make server software to allow for easy sync over wifi
|
||||||
|
- Test the scouting app
|
||||||
|
|
||||||
## In Progress:
|
## In Progress:
|
||||||
#### Scouting:
|
#### Scouting:
|
||||||
|
- Fix scouting offset bug
|
||||||
#### Data Analysis:
|
#### Data Analysis:
|
||||||
- Add CSV exporting of match scouting data.
|
|
||||||
- Make the "Compare" menu, cross comparing team's stats.
|
- Make the "Compare" menu, cross comparing team's stats.
|
||||||
#### Functionality:
|
#### Functionality:
|
||||||
- Make pit and match data field builder UIs. I don't want to have to keep editing a variable
|
- Make pit and match data field builder UIs. I don't want to have to keep editing a variable
|
||||||
- Test the scouting app
|
|
||||||
|
|
||||||
|
|
||||||
## Done:
|
## Done:
|
||||||
@@ -35,4 +36,4 @@ Ridgebotics 2025 scouting app in Android
|
|||||||
- Make everything use Fragments instead of views that toggle visibility
|
- Make everything use Fragments instead of views that toggle visibility
|
||||||
- Make the file browser UI
|
- Make the file browser UI
|
||||||
- Bluetooth data sync
|
- Bluetooth data sync
|
||||||
- Formalize error messages & stacktraces
|
- Formalize error messages & stacktraces
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ public abstract class dataType {
|
|||||||
STRING
|
STRING
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Object value;
|
private Object value;
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
|
|||||||
@@ -49,9 +49,6 @@ public class dropdownType extends inputType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public byte[] encode() throws ByteBuilder.buildingException {
|
public byte[] encode() throws ByteBuilder.buildingException {
|
||||||
ByteBuilder bb = new ByteBuilder();
|
ByteBuilder bb = new ByteBuilder();
|
||||||
bb.addString(name);
|
bb.addString(name);
|
||||||
|
|||||||
@@ -35,11 +35,26 @@ public abstract class inputType {
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// public enum parameterType {
|
||||||
|
// NUMBER,
|
||||||
|
// STRING,
|
||||||
|
// STRINGARRAY
|
||||||
|
// }
|
||||||
|
|
||||||
|
// public static parameterType[] parameterTypeByInputType(inputTypes t){
|
||||||
|
// switch (t){
|
||||||
|
// case SLIDER:
|
||||||
|
// return new parameterType[]{parameterType.NUMBER, };
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
public abstract String get_type_name();
|
public abstract String get_type_name();
|
||||||
|
|
||||||
public abstract byte[] encode() throws ByteBuilder.buildingException;
|
public abstract byte[] encode() throws ByteBuilder.buildingException;
|
||||||
public abstract void decode(byte[] bytes) throws BuiltByteParser.byteParsingExeption;
|
public abstract void decode(byte[] bytes) throws BuiltByteParser.byteParsingExeption;
|
||||||
|
|
||||||
|
// public abstract dataType[] getConfig();
|
||||||
|
// public abstract void setConfig(dataType[] config);
|
||||||
|
|
||||||
public abstract View createView(Context context, Function<dataType, Integer> onUpdate);
|
public abstract View createView(Context context, Function<dataType, Integer> onUpdate);
|
||||||
public boolean isBlank = false;
|
public boolean isBlank = false;
|
||||||
|
|||||||
@@ -0,0 +1,160 @@
|
|||||||
|
package com.astatin3.scoutingapp2025.ui.data;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.TableLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.astatin3.scoutingapp2025.types.input.dropdownType;
|
||||||
|
import com.astatin3.scoutingapp2025.types.input.inputType;
|
||||||
|
import com.astatin3.scoutingapp2025.types.input.sliderType;
|
||||||
|
import com.astatin3.scoutingapp2025.types.input.tallyType;
|
||||||
|
import com.astatin3.scoutingapp2025.types.input.textType;
|
||||||
|
|
||||||
|
public class FieldEditorHelper {
|
||||||
|
private enum parameterTypeEnum {
|
||||||
|
paramNumber,
|
||||||
|
paramString,
|
||||||
|
paramStringArray
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class parameterType {
|
||||||
|
public String name;
|
||||||
|
public parameterTypeEnum id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class paramNumber extends parameterType{
|
||||||
|
public int val;
|
||||||
|
public paramNumber(String name, int val){
|
||||||
|
this.name = name;
|
||||||
|
this.val = val;
|
||||||
|
this.id = parameterTypeEnum.paramNumber;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class paramString extends parameterType {
|
||||||
|
public String val;
|
||||||
|
public paramString(String name, String val){
|
||||||
|
this.name = name;
|
||||||
|
this.val = val;
|
||||||
|
this.id = parameterTypeEnum.paramString;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class paramStringArray extends parameterType{
|
||||||
|
public String[] val;
|
||||||
|
public paramStringArray(String name, String[] val){
|
||||||
|
this.name = name;
|
||||||
|
this.val = val;
|
||||||
|
this.id = parameterTypeEnum.paramStringArray;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final parameterType[] defaultSliderParams = new parameterType[]{
|
||||||
|
new paramNumber("Min", 0),
|
||||||
|
new paramNumber("Max", 10),
|
||||||
|
new paramNumber("Default Value", 5)
|
||||||
|
};
|
||||||
|
private static final parameterType[] defaultDropdownParams = new parameterType[]{
|
||||||
|
new paramStringArray("Default Value", new String[]{"Zero","One","Two","Three"}),
|
||||||
|
new paramNumber("Default Option", 0),
|
||||||
|
};
|
||||||
|
private static final parameterType[] defaultTextParams = new parameterType[]{
|
||||||
|
new paramString("Default Value", "")
|
||||||
|
};
|
||||||
|
private static final parameterType[] defaultTallyParams = new parameterType[]{
|
||||||
|
new paramNumber("Default Value", 0)
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
private static parameterType[] getSliderParams(sliderType s){
|
||||||
|
return new parameterType[]{
|
||||||
|
new paramNumber("Min", s.min),
|
||||||
|
new paramNumber("Max", s.max),
|
||||||
|
new paramNumber("Default Value", (int) s.default_value)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private static parameterType[] getDropdownParams(dropdownType s){
|
||||||
|
return new parameterType[]{
|
||||||
|
new paramStringArray("Default Value",s.text_options),
|
||||||
|
new paramNumber("Default Option", (int) s.default_value),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private static parameterType[] getTextParams(textType s){
|
||||||
|
return new parameterType[]{
|
||||||
|
new paramString("Default Value", (String) s.default_value)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private static parameterType[] getTallyParams(tallyType s){
|
||||||
|
return new parameterType[]{
|
||||||
|
new paramNumber("Default Value", (int) s.default_value)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private static parameterType[] getParamsFromInputType(inputType t){
|
||||||
|
switch (t.getInputType()){
|
||||||
|
case TALLY:
|
||||||
|
return getTallyParams((tallyType) t);
|
||||||
|
case SLIDER:
|
||||||
|
return getSliderParams((sliderType) t);
|
||||||
|
case DROPDOWN:
|
||||||
|
return getDropdownParams((dropdownType) t);
|
||||||
|
case NOTES_INPUT:
|
||||||
|
return getTextParams((textType) t);
|
||||||
|
}
|
||||||
|
return new parameterType[]{};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private static View createNumberEdit(Context c){
|
||||||
|
TextView tv = new TextView(c);
|
||||||
|
tv.setText("Number edit");
|
||||||
|
return tv;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static View createStringEdit(Context c){
|
||||||
|
TextView tv = new TextView(c);
|
||||||
|
tv.setText("String edit");
|
||||||
|
return tv;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static View createStringArrayEdit(Context c){
|
||||||
|
TextView tv = new TextView(c);
|
||||||
|
tv.setText("String Array edit");
|
||||||
|
return tv;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static View createEdit(Context c, parameterType t){
|
||||||
|
switch (t.id){
|
||||||
|
case paramNumber:
|
||||||
|
return createNumberEdit(c);
|
||||||
|
case paramString:
|
||||||
|
return createStringEdit(c);
|
||||||
|
case paramStringArray:
|
||||||
|
return createStringArrayEdit(c);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private parameterType[] types;
|
||||||
|
private View[] views;
|
||||||
|
public FieldEditorHelper(Context c, inputType t, TableLayout parentView){
|
||||||
|
types = getParamsFromInputType(t);
|
||||||
|
for(int i = 0; i < types.length; i++){
|
||||||
|
TextView tv = new TextView(c);
|
||||||
|
tv.setText(types[i].name);
|
||||||
|
tv.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
|
||||||
|
tv.setTextSize(20);
|
||||||
|
parentView.addView(tv);
|
||||||
|
|
||||||
|
parentView.addView(createEdit(c, types[i]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -18,6 +18,7 @@ import androidx.fragment.app.Fragment;
|
|||||||
import com.astatin3.scoutingapp2025.databinding.FragmentDataFieldsBinding;
|
import com.astatin3.scoutingapp2025.databinding.FragmentDataFieldsBinding;
|
||||||
import com.astatin3.scoutingapp2025.scoutingData.fields;
|
import com.astatin3.scoutingapp2025.scoutingData.fields;
|
||||||
import com.astatin3.scoutingapp2025.types.input.inputType;
|
import com.astatin3.scoutingapp2025.types.input.inputType;
|
||||||
|
import com.astatin3.scoutingapp2025.utility.DataManager;
|
||||||
|
|
||||||
public class FieldsFragment extends Fragment {
|
public class FieldsFragment extends Fragment {
|
||||||
FragmentDataFieldsBinding binding;
|
FragmentDataFieldsBinding binding;
|
||||||
@@ -185,13 +186,29 @@ public class FieldsFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void onFieldSelect(inputType field){
|
private void onFieldSelect(inputType field){
|
||||||
System.out.println(field.name);
|
//System.out.println(field.name);
|
||||||
|
|
||||||
binding.editButton.setOnClickListener(v -> {
|
binding.editButton.setOnClickListener(v -> {
|
||||||
|
binding.addButton.setVisibility(View.GONE);
|
||||||
|
binding.upButton.setVisibility(View.GONE);
|
||||||
|
binding.downButton.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
binding.ValueEditTable.removeAllViews();
|
||||||
binding.valueEditContainer.setVisibility(View.VISIBLE);
|
binding.valueEditContainer.setVisibility(View.VISIBLE);
|
||||||
TextView tv = new TextView(getContext());
|
TextView tv = new TextView(getContext());
|
||||||
tv.setText("Test!");
|
|
||||||
|
tv.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
|
||||||
|
tv.setText(field.name);
|
||||||
|
tv.setPadding(8,8,8,8);
|
||||||
|
tv.setTextSize(24);
|
||||||
|
|
||||||
binding.ValueEditTable.addView(tv);
|
binding.ValueEditTable.addView(tv);
|
||||||
|
|
||||||
|
FieldEditorHelper fe = new FieldEditorHelper(
|
||||||
|
getContext(),
|
||||||
|
field,
|
||||||
|
binding.ValueEditTable
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
-2
@@ -18,8 +18,6 @@ import androidx.annotation.Nullable;
|
|||||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
import com.astatin3.scoutingapp2025.databinding.FragmentDataCompileBinding;
|
|
||||||
import com.astatin3.scoutingapp2025.databinding.FragmentTransferBinding;
|
|
||||||
import com.astatin3.scoutingapp2025.databinding.FragmentTransferCodeSenderBinding;
|
import com.astatin3.scoutingapp2025.databinding.FragmentTransferCodeSenderBinding;
|
||||||
import com.astatin3.scoutingapp2025.utility.AlertManager;
|
import com.astatin3.scoutingapp2025.utility.AlertManager;
|
||||||
import com.astatin3.scoutingapp2025.utility.fileEditor;
|
import com.astatin3.scoutingapp2025.utility.fileEditor;
|
||||||
|
|||||||
@@ -17,6 +17,12 @@ public class BuiltByteParser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String unBlankStrNull(String str){
|
||||||
|
if(str.equals("null")){
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
else return str;
|
||||||
|
}
|
||||||
|
|
||||||
public abstract class parsedObject {
|
public abstract class parsedObject {
|
||||||
public abstract Integer getType();
|
public abstract Integer getType();
|
||||||
@@ -100,7 +106,7 @@ public class BuiltByteParser {
|
|||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
stringObject so = new stringObject();
|
stringObject so = new stringObject();
|
||||||
so.str = new String(block, StandardCharsets.UTF_8);
|
so.str = unBlankStrNull(new String(block, StandardCharsets.UTF_8));
|
||||||
objects.add(so);
|
objects.add(so);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
|
|||||||
@@ -25,6 +25,13 @@ public class ByteBuilder {
|
|||||||
public abstract byte[] build();
|
public abstract byte[] build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String blankStrNull(String str){
|
||||||
|
if(str.isEmpty() || str.isEmpty()){
|
||||||
|
return "null";
|
||||||
|
}
|
||||||
|
else return str;
|
||||||
|
}
|
||||||
|
|
||||||
private class boolType extends byteType {
|
private class boolType extends byteType {
|
||||||
public boolean val;
|
public boolean val;
|
||||||
public byte getType(){return bool_id;}
|
public byte getType(){return bool_id;}
|
||||||
@@ -87,6 +94,7 @@ public class ByteBuilder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
public ByteBuilder addString(String str) throws buildingException {
|
public ByteBuilder addString(String str) throws buildingException {
|
||||||
|
str = blankStrNull(str);
|
||||||
if(str.length() > 65536){throw new buildingException("String too long (greater than 65536)");}
|
if(str.length() > 65536){throw new buildingException("String too long (greater than 65536)");}
|
||||||
|
|
||||||
stringType stringType = new stringType();
|
stringType stringType = new stringType();
|
||||||
|
|||||||
Reference in New Issue
Block a user