mirror of
https://github.com/Team4388/RidgeScout.git
synced 2026-06-09 08:38:03 -06:00
Work on Field Editor, Improve capitalization of classes
This commit is contained in:
@@ -3,16 +3,14 @@ package com.ridgebotics.ridgescout;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import com.ridgebotics.ridgescout.databinding.ActivityMainBinding;
|
||||
import com.ridgebotics.ridgescout.scoutingData.fields;
|
||||
import com.ridgebotics.ridgescout.scoutingData.Fields;
|
||||
import com.ridgebotics.ridgescout.utility.SentimentAnalysis;
|
||||
import com.ridgebotics.ridgescout.utility.AlertManager;
|
||||
import com.ridgebotics.ridgescout.utility.fileEditor;
|
||||
import com.ridgebotics.ridgescout.utility.FileEditor;
|
||||
import com.google.android.material.bottomnavigation.BottomNavigationView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.navigation.NavController;
|
||||
import androidx.navigation.NavOptions;
|
||||
@@ -21,8 +19,7 @@ import androidx.navigation.ui.AppBarConfiguration;
|
||||
import androidx.navigation.ui.NavigationUI;
|
||||
|
||||
|
||||
import com.ridgebotics.ridgescout.utility.settingsManager;
|
||||
import com.google.android.material.navigation.NavigationBarView;
|
||||
import com.ridgebotics.ridgescout.utility.SettingsManager;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.TimeZone;
|
||||
@@ -41,15 +38,15 @@ public class MainActivity extends AppCompatActivity {
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
|
||||
settingsManager.prefs = this.getSharedPreferences(
|
||||
SettingsManager.prefs = this.getSharedPreferences(
|
||||
"com.ridgebotics.ridgescout", Context.MODE_PRIVATE);
|
||||
|
||||
if(!fileEditor.fileExist(fields.matchFieldsFilename)){
|
||||
fields.save(fields.matchFieldsFilename, fields.default_match_fields);
|
||||
if(!FileEditor.fileExist(Fields.matchFieldsFilename)){
|
||||
Fields.save(Fields.matchFieldsFilename, Fields.default_match_fields);
|
||||
}
|
||||
|
||||
if(!fileEditor.fileExist(fields.pitsFieldsFilename)){
|
||||
fields.save(fields.pitsFieldsFilename, fields.default_pit_fields);
|
||||
if(!FileEditor.fileExist(Fields.pitsFieldsFilename)){
|
||||
Fields.save(Fields.pitsFieldsFilename, Fields.default_pit_fields);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+74
-74
@@ -1,22 +1,22 @@
|
||||
package com.ridgebotics.ridgescout.scoutingData;
|
||||
|
||||
import com.ridgebotics.ridgescout.types.input.checkboxType;
|
||||
import com.ridgebotics.ridgescout.types.input.dropdownType;
|
||||
import com.ridgebotics.ridgescout.types.input.fieldposType;
|
||||
import com.ridgebotics.ridgescout.types.input.inputType;
|
||||
import com.ridgebotics.ridgescout.types.input.numberType;
|
||||
import com.ridgebotics.ridgescout.types.input.tallyType;
|
||||
import com.ridgebotics.ridgescout.types.input.textType;
|
||||
import com.ridgebotics.ridgescout.types.input.sliderType;
|
||||
import com.ridgebotics.ridgescout.types.input.CheckboxType;
|
||||
import com.ridgebotics.ridgescout.types.input.DropdownType;
|
||||
import com.ridgebotics.ridgescout.types.input.FieldposType;
|
||||
import com.ridgebotics.ridgescout.types.input.FieldType;
|
||||
import com.ridgebotics.ridgescout.types.input.NumberType;
|
||||
import com.ridgebotics.ridgescout.types.input.TallyType;
|
||||
import com.ridgebotics.ridgescout.types.input.TextType;
|
||||
import com.ridgebotics.ridgescout.types.input.SliderType;
|
||||
import com.ridgebotics.ridgescout.utility.AlertManager;
|
||||
import com.ridgebotics.ridgescout.utility.fileEditor;
|
||||
import com.ridgebotics.ridgescout.utility.FileEditor;
|
||||
import com.ridgebotics.ridgescout.utility.BuiltByteParser;
|
||||
import com.ridgebotics.ridgescout.utility.ByteBuilder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
|
||||
public class fields {
|
||||
public class Fields {
|
||||
// public static ScoutingVersion sv = new ScoutingVersion();
|
||||
|
||||
public static final String matchFieldsFilename = "matches.fields";
|
||||
@@ -26,77 +26,77 @@ public class fields {
|
||||
return UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
public static final inputType[][] default_match_fields = new inputType[][] {
|
||||
public static final FieldType[][] default_match_fields = new FieldType[][] {
|
||||
{
|
||||
new fieldposType(uuid(),"Auto start pos", "Where does the robot start its auto?", new int[]{0,0}),
|
||||
new FieldposType(uuid(),"Auto start pos", "Where does the robot start its auto?", new int[]{0,0}),
|
||||
|
||||
new tallyType(uuid(),"Auto L4 Coral", "How many coral did this robot score in L4 during auto?", 0),
|
||||
new tallyType(uuid(),"Auto L3 Coral", "How many coral did this robot score in L3 during auto?", 0),
|
||||
new tallyType(uuid(),"Auto L2 Coral", "How many coral did this robot score in L2 during auto?", 0),
|
||||
new tallyType(uuid(),"Auto L1/Trough Coral", "How many coral did this robot score in L1 during auto?", 0),
|
||||
new tallyType(uuid(),"Auto Processor Algae", "How many algae did this robot score in the Barge during auto?", 0),
|
||||
new tallyType(uuid(),"Auto Barge Algae", "How many algae did this robot score in the Barge during auto?", 0),
|
||||
new TallyType(uuid(),"Auto L4 Coral", "How many coral did this robot score in L4 during auto?", 0),
|
||||
new TallyType(uuid(),"Auto L3 Coral", "How many coral did this robot score in L3 during auto?", 0),
|
||||
new TallyType(uuid(),"Auto L2 Coral", "How many coral did this robot score in L2 during auto?", 0),
|
||||
new TallyType(uuid(),"Auto L1/Trough Coral", "How many coral did this robot score in L1 during auto?", 0),
|
||||
new TallyType(uuid(),"Auto Processor Algae", "How many algae did this robot score in the Barge during auto?", 0),
|
||||
new TallyType(uuid(),"Auto Barge Algae", "How many algae did this robot score in the Barge during auto?", 0),
|
||||
|
||||
new dropdownType(uuid(),"Auto Quality", "How did the robot drive during auto?", new String[]{"Smooth", "Jittery"}, 0),
|
||||
new textType(uuid(),"Auto Comments", "Anything interesting about auto", ""),
|
||||
new DropdownType(uuid(),"Auto Quality", "How did the robot drive during auto?", new String[]{"Smooth", "Jittery"}, 0),
|
||||
new TextType(uuid(),"Auto Comments", "Anything interesting about auto", ""),
|
||||
|
||||
new tallyType(uuid(),"Teleop L4 Coral", "How many coral did this robot score in L4 during auto?", 0),
|
||||
new tallyType(uuid(),"Teleop L3 Coral", "How many coral did this robot score in L3 during auto?", 0),
|
||||
new tallyType(uuid(),"Teleop L2 Coral", "How many coral did this robot score in L2 during auto?", 0),
|
||||
new tallyType(uuid(),"Teleop L1 Coral", "How many coral did this robot score in L1 during auto?", 0),
|
||||
new tallyType(uuid(),"Teleop Processor Algae", "How many algae did this robot score in the Barge during auto?", 0),
|
||||
new tallyType(uuid(),"Teleop Barge Algae", "How many algae did this robot score in the Barge during auto?", 0),
|
||||
new TallyType(uuid(),"Teleop L4 Coral", "How many coral did this robot score in L4 during auto?", 0),
|
||||
new TallyType(uuid(),"Teleop L3 Coral", "How many coral did this robot score in L3 during auto?", 0),
|
||||
new TallyType(uuid(),"Teleop L2 Coral", "How many coral did this robot score in L2 during auto?", 0),
|
||||
new TallyType(uuid(),"Teleop L1 Coral", "How many coral did this robot score in L1 during auto?", 0),
|
||||
new TallyType(uuid(),"Teleop Processor Algae", "How many algae did this robot score in the Barge during auto?", 0),
|
||||
new TallyType(uuid(),"Teleop Barge Algae", "How many algae did this robot score in the Barge during auto?", 0),
|
||||
|
||||
new checkboxType(uuid(),"Upper Algae Removal", "Did the robot remove upper Algae?", 0),
|
||||
new checkboxType(uuid(),"Lower Algae Removal", "Did the robot remove lower Algae?", 0),
|
||||
new CheckboxType(uuid(),"Upper Algae Removal", "Did the robot remove upper Algae?", 0),
|
||||
new CheckboxType(uuid(),"Lower Algae Removal", "Did the robot remove lower Algae?", 0),
|
||||
|
||||
new dropdownType(uuid(),"Teleop Quality", "How did the robot drive during Teleop?", new String[]{"Smooth", "Jittery"}, 0),
|
||||
new textType(uuid(),"Teleop Comments", "Anything interesting about Teleop", ""),
|
||||
new DropdownType(uuid(),"Teleop Quality", "How did the robot drive during Teleop?", new String[]{"Smooth", "Jittery"}, 0),
|
||||
new TextType(uuid(),"Teleop Comments", "Anything interesting about Teleop", ""),
|
||||
|
||||
new dropdownType(uuid(),"Climb State", "What was the final condition of the robot?", new String[]{"Nothing", "Continued Cycling", "Park", "Attempted Shallow", "Shallow", "Attempted Deep", "Deep"}, 0),
|
||||
new DropdownType(uuid(),"Climb State", "What was the final condition of the robot?", new String[]{"Nothing", "Continued Cycling", "Park", "Attempted Shallow", "Shallow", "Attempted Deep", "Deep"}, 0),
|
||||
|
||||
new dropdownType(uuid(),"Robot Condition", "Was anything broken?", new String[]{"Everything was working", "Something was maybe broken", "Something was broken", "Robot was disabled for part of the match", "Missing robot"}, 0),
|
||||
new DropdownType(uuid(),"Robot Condition", "Was anything broken?", new String[]{"Everything was working", "Something was maybe broken", "Something was broken", "Robot was disabled for part of the match", "Missing robot"}, 0),
|
||||
|
||||
new textType(uuid(),"Other Comments", "Any other comments you have", "")
|
||||
new TextType(uuid(),"Other Comments", "Any other comments you have", "")
|
||||
}
|
||||
};
|
||||
|
||||
public static final inputType[][] default_pit_fields = new inputType[][] {
|
||||
public static final FieldType[][] default_pit_fields = new FieldType[][] {
|
||||
{
|
||||
new dropdownType(uuid(),"Drivetrain type", "What type of drivetrain does this team have?", new String[]{"Swerve Drive", "Tank Drive (Differential)", "Other, Info in comments"}, 0),
|
||||
new dropdownType(uuid(),"Intake type", "What type of intake does this team have?", new String[]{"Ground only", "Player Station only", "Both", "Other, Info in comments"}, 0),
|
||||
new dropdownType(uuid(),"Intake Consistency", "How consistent is the robot at intakeing?", new String[]{"Does not work", "Worked a few times during testing", "Works most of the time", "Fails sometimes", "Never fails"}, 0),
|
||||
new DropdownType(uuid(),"Drivetrain type", "What type of drivetrain does this team have?", new String[]{"Swerve Drive", "Tank Drive (Differential)", "Other, Info in comments"}, 0),
|
||||
new DropdownType(uuid(),"Intake type", "What type of intake does this team have?", new String[]{"Ground only", "Player Station only", "Both", "Other, Info in comments"}, 0),
|
||||
new DropdownType(uuid(),"Intake Consistency", "How consistent is the robot at intakeing?", new String[]{"Does not work", "Worked a few times during testing", "Works most of the time", "Fails sometimes", "Never fails"}, 0),
|
||||
|
||||
new dropdownType(uuid(),"Score Area", "What does this robot score?", new String[]{"Only Algae", "Mostly Algae", "Both", "Mostly Coral", "Only Coral"}, 0),
|
||||
new DropdownType(uuid(),"Score Area", "What does this robot score?", new String[]{"Only Algae", "Mostly Algae", "Both", "Mostly Coral", "Only Coral"}, 0),
|
||||
|
||||
new checkboxType(uuid(),"L4 Scoring", "Will the robot score in Layer 4?", 0),
|
||||
new checkboxType(uuid(),"L3 Scoring", "Will the robot score in Layer 3?", 0),
|
||||
new checkboxType(uuid(),"L2 Scoring", "Will the robot score in Layer 3?", 0),
|
||||
new checkboxType(uuid(),"L1/Trough Scoring", "Will the robot score in Layer 1?", 0),
|
||||
new checkboxType(uuid(),"Processor Scoring", "Will the robot score in the Processor?", 0),
|
||||
new checkboxType(uuid(),"Barge Scoring", "Will the robot score algae in the Barge?", 0),
|
||||
new dropdownType(uuid(),"Scoring Consistency", "How consistent is the robot at Scoring?", new String[]{"Does not work", "Worked a few times during testing", "Works most of the time", "Fails sometimes", "Never fails"}, 0),
|
||||
new CheckboxType(uuid(),"L4 Scoring", "Will the robot score in Layer 4?", 0),
|
||||
new CheckboxType(uuid(),"L3 Scoring", "Will the robot score in Layer 3?", 0),
|
||||
new CheckboxType(uuid(),"L2 Scoring", "Will the robot score in Layer 3?", 0),
|
||||
new CheckboxType(uuid(),"L1/Trough Scoring", "Will the robot score in Layer 1?", 0),
|
||||
new CheckboxType(uuid(),"Processor Scoring", "Will the robot score in the Processor?", 0),
|
||||
new CheckboxType(uuid(),"Barge Scoring", "Will the robot score algae in the Barge?", 0),
|
||||
new DropdownType(uuid(),"Scoring Consistency", "How consistent is the robot at Scoring?", new String[]{"Does not work", "Worked a few times during testing", "Works most of the time", "Fails sometimes", "Never fails"}, 0),
|
||||
|
||||
new textType(uuid(),"Auto Capability", "What autos does this team have?", ""),
|
||||
new dropdownType(uuid(),"Auto Consistency", "How consistent is the robot at Auto?", new String[]{"Does not work", "Worked a few times during testing", "Works most of the time", "Fails sometimes", "Never fails"}, 0),
|
||||
new TextType(uuid(),"Auto Capability", "What autos does this team have?", ""),
|
||||
new DropdownType(uuid(),"Auto Consistency", "How consistent is the robot at Auto?", new String[]{"Does not work", "Worked a few times during testing", "Works most of the time", "Fails sometimes", "Never fails"}, 0),
|
||||
|
||||
new dropdownType(uuid(),"Climb type", "What does the robot do to climb?", new String[]{"No Climb", "Only Shallow", "Only Deep", "Both Shallow and Deep"}, 0),
|
||||
new dropdownType(uuid(),"Climb Consistency", "How consistent is the robot at climbing?", new String[]{"Does not work", "Worked a few times during testing", "Works most of the time", "Fails sometimes", "Never fails"}, 0),
|
||||
new DropdownType(uuid(),"Climb type", "What does the robot do to climb?", new String[]{"No Climb", "Only Shallow", "Only Deep", "Both Shallow and Deep"}, 0),
|
||||
new DropdownType(uuid(),"Climb Consistency", "How consistent is the robot at climbing?", new String[]{"Does not work", "Worked a few times during testing", "Works most of the time", "Fails sometimes", "Never fails"}, 0),
|
||||
|
||||
new textType(uuid(),"Cool Comments", "Is there anything cool about the robot?", ""),
|
||||
new TextType(uuid(),"Cool Comments", "Is there anything cool about the robot?", ""),
|
||||
|
||||
new textType(uuid(),"Comments", "Things go here", "Day 1:\n\nDay 2:\n\nDay 3:\n")
|
||||
new TextType(uuid(),"Comments", "Things go here", "Day 1:\n\nDay 2:\n\nDay 3:\n")
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
public static boolean save(String filename, inputType[][] values){
|
||||
public static boolean save(String filename, FieldType[][] values){
|
||||
try {
|
||||
ByteBuilder bb = new ByteBuilder();
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
bb.addRaw(127, save_version(values[i]));
|
||||
}
|
||||
fileEditor.writeFile(filename, bb.build());
|
||||
FileEditor.writeFile(filename, bb.build());
|
||||
return true;
|
||||
}catch (ByteBuilder.buildingException e) {
|
||||
AlertManager.error(e);
|
||||
@@ -105,7 +105,7 @@ public class fields {
|
||||
}
|
||||
}
|
||||
|
||||
private static byte[] save_version(inputType[] values) throws ByteBuilder.buildingException {
|
||||
private static byte[] save_version(FieldType[] values) throws ByteBuilder.buildingException {
|
||||
ByteBuilder bb = new ByteBuilder();
|
||||
for(int i =0; i < values.length; i++){
|
||||
bb.addRaw(values[i].get_byte_id(), values[i].encode());
|
||||
@@ -113,15 +113,15 @@ public class fields {
|
||||
return bb.build();
|
||||
}
|
||||
|
||||
public static inputType[][] load(String filename){
|
||||
byte[] bytes = fileEditor.readFile(filename);
|
||||
public static FieldType[][] load(String filename){
|
||||
byte[] bytes = FileEditor.readFile(filename);
|
||||
|
||||
// System.out.println(bytes);
|
||||
|
||||
try {
|
||||
BuiltByteParser bbp = new BuiltByteParser(bytes);
|
||||
ArrayList<BuiltByteParser.parsedObject> objects = bbp.parse();
|
||||
inputType[][] values = new inputType[objects.size()][];
|
||||
FieldType[][] values = new FieldType[objects.size()][];
|
||||
|
||||
for(int i = 0 ; i < objects.size(); i++){
|
||||
values[i] = load_version((byte[]) objects.get(i).get());
|
||||
@@ -135,35 +135,35 @@ public class fields {
|
||||
}
|
||||
}
|
||||
|
||||
private static inputType[] load_version(byte[] bytes) throws BuiltByteParser.byteParsingExeption{
|
||||
private static FieldType[] load_version(byte[] bytes) throws BuiltByteParser.byteParsingExeption{
|
||||
BuiltByteParser bbp = new BuiltByteParser(bytes);
|
||||
ArrayList<BuiltByteParser.parsedObject> objects = bbp.parse();
|
||||
inputType[] output = new inputType[objects.size()];
|
||||
FieldType[] output = new FieldType[objects.size()];
|
||||
|
||||
for(int i = 0 ; i < objects.size(); i++){
|
||||
BuiltByteParser.parsedObject obj = objects.get(i);
|
||||
inputType t = null;
|
||||
FieldType t = null;
|
||||
switch (obj.getType()){
|
||||
case inputType.slider_type_id:
|
||||
t = new sliderType();
|
||||
case FieldType.slider_type_id:
|
||||
t = new SliderType();
|
||||
break;
|
||||
case inputType.dropdownType:
|
||||
t = new dropdownType();
|
||||
case FieldType.dropdownType:
|
||||
t = new DropdownType();
|
||||
break;
|
||||
case inputType.notesType:
|
||||
t = new textType();
|
||||
case FieldType.notesType:
|
||||
t = new TextType();
|
||||
break;
|
||||
case inputType.tallyType:
|
||||
t = new tallyType();
|
||||
case FieldType.tallyType:
|
||||
t = new TallyType();
|
||||
break;
|
||||
case inputType.numberType:
|
||||
t = new numberType();
|
||||
case FieldType.numberType:
|
||||
t = new NumberType();
|
||||
break;
|
||||
case inputType.checkboxType:
|
||||
t = new checkboxType();
|
||||
case FieldType.checkboxType:
|
||||
t = new CheckboxType();
|
||||
break;
|
||||
case inputType.fieldposType:
|
||||
t = new fieldposType();
|
||||
case FieldType.fieldposType:
|
||||
t = new FieldposType();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package com.ridgebotics.ridgescout.scoutingData;
|
||||
|
||||
import com.ridgebotics.ridgescout.scoutingData.transfer.transferType;
|
||||
import com.ridgebotics.ridgescout.scoutingData.transfer.TransferType;
|
||||
import com.ridgebotics.ridgescout.types.ScoutingArray;
|
||||
import com.ridgebotics.ridgescout.types.data.dataType;
|
||||
import com.ridgebotics.ridgescout.types.data.intArrType;
|
||||
import com.ridgebotics.ridgescout.types.data.stringType;
|
||||
import com.ridgebotics.ridgescout.types.input.inputType;
|
||||
import com.ridgebotics.ridgescout.types.data.intType;
|
||||
import com.ridgebotics.ridgescout.types.data.DataType;
|
||||
import com.ridgebotics.ridgescout.types.data.IntArrType;
|
||||
import com.ridgebotics.ridgescout.types.data.StringType;
|
||||
import com.ridgebotics.ridgescout.types.input.FieldType;
|
||||
import com.ridgebotics.ridgescout.types.data.IntType;
|
||||
import com.ridgebotics.ridgescout.utility.AlertManager;
|
||||
import com.ridgebotics.ridgescout.utility.fileEditor;
|
||||
import com.ridgebotics.ridgescout.utility.FileEditor;
|
||||
import com.ridgebotics.ridgescout.utility.BuiltByteParser;
|
||||
import com.ridgebotics.ridgescout.utility.ByteBuilder;
|
||||
|
||||
@@ -19,7 +19,7 @@ public class ScoutingDataWriter {
|
||||
// private static final int int_type_id = 255;
|
||||
// private static final int string_type_id = 254;
|
||||
|
||||
public static boolean save(int version, String username, String filename, dataType[] data){
|
||||
public static boolean save(int version, String username, String filename, DataType[] data){
|
||||
ByteBuilder bb = new ByteBuilder();
|
||||
try {
|
||||
bb.addInt(version);
|
||||
@@ -40,7 +40,7 @@ public class ScoutingDataWriter {
|
||||
}
|
||||
}
|
||||
byte[] bytes = bb.build();
|
||||
fileEditor.writeFile(filename, bytes);
|
||||
FileEditor.writeFile(filename, bytes);
|
||||
return true;
|
||||
} catch (ByteBuilder.buildingException e) {
|
||||
AlertManager.error(e);
|
||||
@@ -55,12 +55,12 @@ public class ScoutingDataWriter {
|
||||
public ScoutingArray data;
|
||||
}
|
||||
|
||||
public static ParsedScoutingDataResult load(String filename, inputType[][] values , transferType[][] transferValues){
|
||||
byte[] bytes = fileEditor.readFile(filename);
|
||||
public static ParsedScoutingDataResult load(String filename, FieldType[][] values , TransferType[][] transferValues){
|
||||
byte[] bytes = FileEditor.readFile(filename);
|
||||
BuiltByteParser bbp = new BuiltByteParser(bytes);
|
||||
try {
|
||||
ArrayList<BuiltByteParser.parsedObject> objects = bbp.parse();
|
||||
dataType[] dataTypes = new dataType[objects.size()-2];
|
||||
DataType[] dataTypes = new DataType[objects.size()-2];
|
||||
|
||||
int version = ((int)objects.get(0).get());
|
||||
// System.out.println(version);
|
||||
@@ -69,17 +69,17 @@ public class ScoutingDataWriter {
|
||||
for(int i = 0; i < values[version].length; i++){
|
||||
switch (objects.get(i+2).getType()){
|
||||
case 1: // Int
|
||||
dataTypes[i] = intType.newNull(values[version][i].name);
|
||||
dataTypes[i] = IntType.newNull(values[version][i].name);
|
||||
dataTypes[i].forceSetValue(objects.get(i+2).get());
|
||||
System.out.println("Loaded INT: " + values[version][i].name + ", ("+ dataTypes[i].get() +")");
|
||||
break;
|
||||
case 2: // String
|
||||
dataTypes[i] = stringType.newNull(values[version][i].name);
|
||||
dataTypes[i] = StringType.newNull(values[version][i].name);
|
||||
dataTypes[i].forceSetValue(objects.get(i+2).get());
|
||||
System.out.println("Loaded STR: " + values[version][i].name + ", ("+ dataTypes[i].get() +")");
|
||||
break;
|
||||
case 3: // Int array
|
||||
dataTypes[i] = intArrType.newNull(values[version][i].name);
|
||||
dataTypes[i] = IntArrType.newNull(values[version][i].name);
|
||||
dataTypes[i].forceSetValue(objects.get(i+2).get());
|
||||
System.out.println("Loaded intARR: " + values[version][i].name + ", ("+ Arrays.toString((int[])dataTypes[i].get()) +")");
|
||||
break;
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package com.ridgebotics.ridgescout.scoutingData.transfer;
|
||||
|
||||
public class createTransferType extends transferType {
|
||||
public class CreateTransferType extends TransferType {
|
||||
public transferValue getType() {return transferValue.CREATE;}
|
||||
public createTransferType(String name){
|
||||
public CreateTransferType(String name){
|
||||
super(name);
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package com.ridgebotics.ridgescout.scoutingData.transfer;
|
||||
|
||||
public class directTransferType extends transferType {
|
||||
public class DirectTransferType extends TransferType {
|
||||
public transferValue getType() {return transferValue.DIRECT;}
|
||||
public directTransferType(String name){
|
||||
public DirectTransferType(String name){
|
||||
super(name);
|
||||
}
|
||||
}
|
||||
+10
-10
@@ -1,20 +1,20 @@
|
||||
package com.ridgebotics.ridgescout.scoutingData.transfer;
|
||||
|
||||
import com.ridgebotics.ridgescout.types.input.inputType;
|
||||
import com.ridgebotics.ridgescout.types.input.FieldType;
|
||||
|
||||
public abstract class transferType {
|
||||
public abstract class TransferType {
|
||||
public enum transferValue {
|
||||
DIRECT,
|
||||
CREATE
|
||||
}
|
||||
public String name;
|
||||
public abstract transferValue getType();
|
||||
public transferType(String name){
|
||||
public TransferType(String name){
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
private static inputType get_input_type_by_name(inputType[] values, String name){
|
||||
for(inputType it : values){
|
||||
private static FieldType get_input_type_by_name(FieldType[] values, String name){
|
||||
for(FieldType it : values){
|
||||
if(it.name.equals(name)){
|
||||
return it;
|
||||
}
|
||||
@@ -22,16 +22,16 @@ public abstract class transferType {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static transferType[][] get_transfer_values(inputType[][] values) {
|
||||
transferType[][] output = new transferType[values.length][];
|
||||
public static TransferType[][] get_transfer_values(FieldType[][] values) {
|
||||
TransferType[][] output = new TransferType[values.length][];
|
||||
for(int a = 1; a < values.length; a++){
|
||||
transferType[] v = new transferType[values[a].length];
|
||||
TransferType[] v = new TransferType[values[a].length];
|
||||
for(int b = 0; b < values[a].length; b++){
|
||||
String name = values[a][b].name;
|
||||
if(get_input_type_by_name(values[a-1], name) != null){
|
||||
v[b] = new directTransferType(name);
|
||||
v[b] = new DirectTransferType(name);
|
||||
}else{
|
||||
v[b] = new createTransferType(name);
|
||||
v[b] = new CreateTransferType(name);
|
||||
}
|
||||
}
|
||||
output[a-1] = v;
|
||||
@@ -1,21 +1,21 @@
|
||||
package com.ridgebotics.ridgescout.types;
|
||||
|
||||
import com.ridgebotics.ridgescout.scoutingData.transfer.createTransferType;
|
||||
import com.ridgebotics.ridgescout.scoutingData.transfer.directTransferType;
|
||||
import com.ridgebotics.ridgescout.scoutingData.transfer.transferType;
|
||||
import com.ridgebotics.ridgescout.types.data.dataType;
|
||||
import com.ridgebotics.ridgescout.types.data.intType;
|
||||
import com.ridgebotics.ridgescout.types.data.stringType;
|
||||
import com.ridgebotics.ridgescout.types.input.inputType;
|
||||
import com.ridgebotics.ridgescout.scoutingData.transfer.CreateTransferType;
|
||||
import com.ridgebotics.ridgescout.scoutingData.transfer.DirectTransferType;
|
||||
import com.ridgebotics.ridgescout.scoutingData.transfer.TransferType;
|
||||
import com.ridgebotics.ridgescout.types.data.DataType;
|
||||
import com.ridgebotics.ridgescout.types.data.IntType;
|
||||
import com.ridgebotics.ridgescout.types.data.StringType;
|
||||
import com.ridgebotics.ridgescout.types.input.FieldType;
|
||||
|
||||
public class ScoutingArray {
|
||||
public int version;
|
||||
public dataType[] array;
|
||||
public inputType[][] values;
|
||||
public DataType[] array;
|
||||
public FieldType[][] values;
|
||||
public int latest_version_num;
|
||||
public transferType[][] transfer_values;
|
||||
public TransferType[][] transfer_values;
|
||||
|
||||
public ScoutingArray(int version, dataType[] array, inputType[][] values, transferType[][] transfer_values){
|
||||
public ScoutingArray(int version, DataType[] array, FieldType[][] values, TransferType[][] transfer_values){
|
||||
this.version = version;
|
||||
this.array = array;
|
||||
this.values = values;
|
||||
@@ -23,24 +23,24 @@ public class ScoutingArray {
|
||||
this.transfer_values = transfer_values;
|
||||
}
|
||||
|
||||
public ScoutingArray(int version, dataType[] array, inputType[][] values){
|
||||
this(version, array, values, transferType.get_transfer_values(values));
|
||||
public ScoutingArray(int version, DataType[] array, FieldType[][] values){
|
||||
this(version, array, values, TransferType.get_transfer_values(values));
|
||||
}
|
||||
|
||||
public void update(){
|
||||
while(version<latest_version_num){
|
||||
dataType[] new_values = new dataType[transfer_values[version].length];
|
||||
DataType[] new_values = new DataType[transfer_values[version].length];
|
||||
for(int i = 0; i < transfer_values[version].length; i++){
|
||||
transferType tv = transfer_values[version][i];
|
||||
TransferType tv = transfer_values[version][i];
|
||||
switch (tv.getType()){
|
||||
case DIRECT:
|
||||
new_values[i] = direct_transfer((directTransferType) tv);
|
||||
new_values[i] = direct_transfer((DirectTransferType) tv);
|
||||
continue;
|
||||
// case RENAME:
|
||||
// new_values[i] = rename_transfer((renameTransferType) tv);
|
||||
// continue;
|
||||
case CREATE:
|
||||
new_values[i] = create_transfer((createTransferType) tv);
|
||||
new_values[i] = create_transfer((CreateTransferType) tv);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -50,8 +50,8 @@ public class ScoutingArray {
|
||||
}
|
||||
}
|
||||
|
||||
private inputType get_input_type_by_name(int version, String name){
|
||||
for(inputType it : values[version]){
|
||||
private FieldType get_input_type_by_name(int version, String name){
|
||||
for(FieldType it : values[version]){
|
||||
if(it.name.equals(name)){
|
||||
return it;
|
||||
}
|
||||
@@ -59,8 +59,8 @@ public class ScoutingArray {
|
||||
return null;
|
||||
}
|
||||
|
||||
private dataType get_data_type_by_name(String name){
|
||||
for(dataType dt : array){
|
||||
private DataType get_data_type_by_name(String name){
|
||||
for(DataType dt : array){
|
||||
if(dt.getName().equals(name)){
|
||||
return dt;
|
||||
}
|
||||
@@ -68,7 +68,7 @@ public class ScoutingArray {
|
||||
return null;
|
||||
}
|
||||
|
||||
private dataType direct_transfer(directTransferType tv){
|
||||
private DataType direct_transfer(DirectTransferType tv){
|
||||
return get_data_type_by_name(tv.name);
|
||||
}
|
||||
|
||||
@@ -78,13 +78,13 @@ public class ScoutingArray {
|
||||
// return dt;
|
||||
// }
|
||||
|
||||
private dataType create_transfer(createTransferType tv){
|
||||
inputType it = get_input_type_by_name(version+1, tv.name);
|
||||
private DataType create_transfer(CreateTransferType tv){
|
||||
FieldType it = get_input_type_by_name(version+1, tv.name);
|
||||
switch (it.getValueType()){
|
||||
case NUM:
|
||||
return intType.newNull(it.name);
|
||||
return IntType.newNull(it.name);
|
||||
case STRING:
|
||||
return stringType.newNull(it.name);
|
||||
return StringType.newNull(it.name);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
+10
-11
@@ -3,25 +3,24 @@ package com.ridgebotics.ridgescout.types;
|
||||
import com.ridgebotics.ridgescout.utility.AlertManager;
|
||||
import com.ridgebotics.ridgescout.utility.BuiltByteParser;
|
||||
import com.ridgebotics.ridgescout.utility.ByteBuilder;
|
||||
import com.ridgebotics.ridgescout.utility.fileEditor;
|
||||
import com.ridgebotics.ridgescout.utility.FileEditor;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
|
||||
public class file {
|
||||
public class ScoutingFile {
|
||||
public static final int typecode = 255;
|
||||
public String filename;
|
||||
public byte[] data;
|
||||
|
||||
|
||||
public file(){}
|
||||
public ScoutingFile(){}
|
||||
|
||||
public file(String filename){
|
||||
this(filename, fileEditor.readFile(filename));
|
||||
public ScoutingFile(String filename){
|
||||
this(filename, FileEditor.readFile(filename));
|
||||
}
|
||||
|
||||
public file(String filename, byte[] data){
|
||||
public ScoutingFile(String filename, byte[] data){
|
||||
this.filename = filename;
|
||||
this.data = data;
|
||||
}
|
||||
@@ -37,7 +36,7 @@ public class file {
|
||||
// bb.addRaw(255, fileEditor.getByteBlock(data, i*65535, (i+1)*65535));
|
||||
// }
|
||||
|
||||
bb.addRaw(255, Objects.requireNonNull(fileEditor.readFile(filename)));
|
||||
bb.addRaw(255, Objects.requireNonNull(FileEditor.readFile(filename)));
|
||||
|
||||
return bb.build();
|
||||
|
||||
@@ -47,11 +46,11 @@ public class file {
|
||||
}
|
||||
}
|
||||
|
||||
public static file decode(byte[] bytes){
|
||||
public static ScoutingFile decode(byte[] bytes){
|
||||
try{
|
||||
ArrayList<BuiltByteParser.parsedObject> objects = new BuiltByteParser(bytes).parse();
|
||||
|
||||
file f = new file();
|
||||
ScoutingFile f = new ScoutingFile();
|
||||
|
||||
f.filename = (String) objects.get(0).get();
|
||||
|
||||
@@ -74,6 +73,6 @@ public class file {
|
||||
|
||||
public boolean write(){
|
||||
if(data == null || filename == null) return false;
|
||||
return fileEditor.writeFile(filename, data);
|
||||
return FileEditor.writeFile(filename, data);
|
||||
}
|
||||
}
|
||||
+2
-6
@@ -1,10 +1,6 @@
|
||||
package com.ridgebotics.ridgescout.types.data;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class dataType {
|
||||
public abstract class DataType {
|
||||
public enum valueTypes {
|
||||
NUM,
|
||||
NUMARR,
|
||||
@@ -30,7 +26,7 @@ public abstract class dataType {
|
||||
|
||||
public String getName() {return name;}
|
||||
|
||||
public dataType(String name){
|
||||
public DataType(String name){
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
package com.ridgebotics.ridgescout.types.data;
|
||||
|
||||
public class intArrType extends dataType {
|
||||
public class IntArrType extends DataType {
|
||||
public static final int[] nullval = new int[]{255, 255};
|
||||
// public static final int unselectedval = 1;
|
||||
|
||||
@@ -23,13 +23,13 @@ public class intArrType extends dataType {
|
||||
forceSetValue((int[]) value);
|
||||
}
|
||||
|
||||
public intArrType(String name, int[] value) {
|
||||
public IntArrType(String name, int[] value) {
|
||||
super(name);
|
||||
set(value);
|
||||
}
|
||||
|
||||
public static intArrType newNull(String name){
|
||||
return new intArrType(name, nullval);
|
||||
public static IntArrType newNull(String name){
|
||||
return new IntArrType(name, nullval);
|
||||
}
|
||||
|
||||
// public static intType newUnselected(String name){
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
package com.ridgebotics.ridgescout.types.data;
|
||||
|
||||
public class intType extends dataType {
|
||||
public class IntType extends DataType {
|
||||
public static final int nullval = 255;
|
||||
// public static final int unselectedval = 1;
|
||||
|
||||
@@ -23,13 +23,13 @@ public class intType extends dataType {
|
||||
forceSetValue((int) value);
|
||||
}
|
||||
|
||||
public intType(String name, int value) {
|
||||
public IntType(String name, int value) {
|
||||
super(name);
|
||||
set(value);
|
||||
}
|
||||
|
||||
public static intType newNull(String name){
|
||||
final intType a = new intType(name, 0);
|
||||
public static IntType newNull(String name){
|
||||
final IntType a = new IntType(name, 0);
|
||||
a.forceSetValue(nullval);
|
||||
return a;
|
||||
}
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
package com.ridgebotics.ridgescout.types.data;
|
||||
|
||||
public class stringType extends dataType{
|
||||
public class StringType extends DataType {
|
||||
public static final String nullval = "null";
|
||||
// public static final String unselectedval = "■";
|
||||
|
||||
@@ -23,13 +23,13 @@ public class stringType extends dataType{
|
||||
forceSetValue(value);
|
||||
}
|
||||
|
||||
public stringType(String name, String value) {
|
||||
public StringType(String name, String value) {
|
||||
super(name);
|
||||
forceSetValue(value);
|
||||
}
|
||||
|
||||
public static stringType newNull(String name){
|
||||
final stringType a = new stringType(name, "");
|
||||
public static StringType newNull(String name){
|
||||
final StringType a = new StringType(name, "");
|
||||
a.forceSetValue(nullval);
|
||||
return a;
|
||||
}
|
||||
@@ -2,14 +2,11 @@ package com.ridgebotics.ridgescout.types;
|
||||
|
||||
import static com.ridgebotics.ridgescout.utility.DataManager.event;
|
||||
|
||||
import android.widget.TableRow;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import com.ridgebotics.ridgescout.utility.AlertManager;
|
||||
import com.ridgebotics.ridgescout.utility.BuiltByteParser;
|
||||
import com.ridgebotics.ridgescout.utility.ByteBuilder;
|
||||
import com.ridgebotics.ridgescout.utility.settingsManager;
|
||||
import com.ridgebotics.ridgescout.utility.SettingsManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -37,8 +34,8 @@ public class frcEvent {
|
||||
bb.addRaw(frcMatch.typecode, match.encode());
|
||||
}
|
||||
|
||||
if(settingsManager.getEVCode().equals("unset")){
|
||||
settingsManager.setEVCode(eventCode);
|
||||
if(SettingsManager.getEVCode().equals("unset")){
|
||||
SettingsManager.setEVCode(eventCode);
|
||||
}
|
||||
|
||||
return bb.build();
|
||||
|
||||
+16
-24
@@ -1,20 +1,12 @@
|
||||
package com.ridgebotics.ridgescout.types.input;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
|
||||
import com.github.mikephil.charting.charts.LineChart;
|
||||
import com.github.mikephil.charting.charts.PieChart;
|
||||
@@ -25,8 +17,8 @@ import com.github.mikephil.charting.data.LineDataSet;
|
||||
import com.github.mikephil.charting.data.PieData;
|
||||
import com.github.mikephil.charting.data.PieDataSet;
|
||||
import com.github.mikephil.charting.data.PieEntry;
|
||||
import com.ridgebotics.ridgescout.types.data.dataType;
|
||||
import com.ridgebotics.ridgescout.types.data.intType;
|
||||
import com.ridgebotics.ridgescout.types.data.DataType;
|
||||
import com.ridgebotics.ridgescout.types.data.IntType;
|
||||
import com.ridgebotics.ridgescout.utility.BuiltByteParser;
|
||||
import com.ridgebotics.ridgescout.utility.ByteBuilder;
|
||||
|
||||
@@ -34,14 +26,14 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class checkboxType extends inputType {
|
||||
public class CheckboxType extends FieldType {
|
||||
public int get_byte_id() {return checkboxType;}
|
||||
public inputTypes getInputType(){return inputTypes.CHECKBOX;}
|
||||
public dataType.valueTypes getValueType(){return dataType.valueTypes.NUM;}
|
||||
public DataType.valueTypes getValueType(){return DataType.valueTypes.NUM;}
|
||||
public Object get_fallback_value(){return 0;}
|
||||
public checkboxType(){};
|
||||
public CheckboxType(){};
|
||||
public String get_type_name(){return "Checkbox";}
|
||||
public checkboxType(String UUID, String name, String description, int isChecked){
|
||||
public CheckboxType(String UUID, String name, String description, int isChecked){
|
||||
super(UUID, name, description);
|
||||
this.default_value = isChecked;
|
||||
}
|
||||
@@ -59,7 +51,7 @@ public class checkboxType extends inputType {
|
||||
|
||||
public CheckBox checkBox = null;
|
||||
|
||||
public View createView(Context context, Function<dataType, Integer> onUpdate){
|
||||
public View createView(Context context, Function<DataType, Integer> onUpdate){
|
||||
checkBox = new CheckBox(context);
|
||||
checkBox.setTextAppearance(com.google.android.material.R.style.TextAppearance_MaterialComponents_Headline6);
|
||||
checkBox.setText(name);
|
||||
@@ -72,7 +64,7 @@ public class checkboxType extends inputType {
|
||||
}
|
||||
public void setViewValue(Object value) {
|
||||
if(checkBox == null) return;
|
||||
if(intType.isNull((int) value)){
|
||||
if(IntType.isNull((int) value)){
|
||||
nullify();
|
||||
return;
|
||||
}
|
||||
@@ -86,10 +78,10 @@ public class checkboxType extends inputType {
|
||||
isBlank = true;
|
||||
checkBox.setVisibility(View.GONE);
|
||||
}
|
||||
public dataType getViewValue(){
|
||||
public DataType getViewValue(){
|
||||
if(checkBox == null) return null;
|
||||
if(checkBox.getVisibility() == View.GONE) return new intType(name, intType.nullval);
|
||||
return new intType(name, checkBox.isChecked() ? 1 : 0);
|
||||
if(checkBox.getVisibility() == View.GONE) return new IntType(name, IntType.nullval);
|
||||
return new IntType(name, checkBox.isChecked() ? 1 : 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -97,7 +89,7 @@ public class checkboxType extends inputType {
|
||||
|
||||
|
||||
|
||||
public void add_individual_view(LinearLayout parent, dataType data){
|
||||
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_Headline6);
|
||||
@@ -112,7 +104,7 @@ public class checkboxType extends inputType {
|
||||
public static int[] colors = {0x7f00ff00, 0x7f7f0000};
|
||||
|
||||
|
||||
public void add_compiled_view(LinearLayout parent, dataType[] data){
|
||||
public void add_compiled_view(LinearLayout parent, DataType[] data){
|
||||
PieChart chart = new PieChart(parent.getContext());
|
||||
FrameLayout.LayoutParams layout = new FrameLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
@@ -152,7 +144,7 @@ public class checkboxType extends inputType {
|
||||
|
||||
|
||||
|
||||
public void add_history_view(LinearLayout parent, dataType[] data){
|
||||
public void add_history_view(LinearLayout parent, DataType[] data){
|
||||
LineChart chart = new LineChart(parent.getContext());
|
||||
FrameLayout.LayoutParams layout = new FrameLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
@@ -212,11 +204,11 @@ public class checkboxType extends inputType {
|
||||
parent.addView(chart);
|
||||
}
|
||||
|
||||
public void addDataToTable(LinearLayout parent, List<dataType>[] data){
|
||||
public void addDataToTable(LinearLayout parent, List<DataType>[] data){
|
||||
|
||||
}
|
||||
|
||||
public String toString(dataType data){
|
||||
public String toString(DataType data){
|
||||
return (int) data.get() == 1 ? "true" : "false";
|
||||
}
|
||||
}
|
||||
+16
-21
@@ -1,8 +1,5 @@
|
||||
package com.ridgebotics.ridgescout.types.input;
|
||||
|
||||
import static com.google.android.material.internal.ContextUtils.getActivity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.view.Gravity;
|
||||
@@ -12,10 +9,8 @@ import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.ridgebotics.ridgescout.types.data.dataType;
|
||||
import com.ridgebotics.ridgescout.types.data.intType;
|
||||
import com.ridgebotics.ridgescout.types.data.DataType;
|
||||
import com.ridgebotics.ridgescout.types.data.IntType;
|
||||
import com.ridgebotics.ridgescout.ui.CustomSpinnerView;
|
||||
import com.ridgebotics.ridgescout.utility.BuiltByteParser;
|
||||
import com.ridgebotics.ridgescout.utility.ByteBuilder;
|
||||
@@ -34,15 +29,15 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class dropdownType extends inputType {
|
||||
public class DropdownType extends FieldType {
|
||||
public String[] text_options;
|
||||
public int get_byte_id() {return dropdownType;}
|
||||
public inputTypes getInputType(){return inputTypes.DROPDOWN;}
|
||||
public dataType.valueTypes getValueType(){return dataType.valueTypes.NUM;}
|
||||
public DataType.valueTypes getValueType(){return DataType.valueTypes.NUM;}
|
||||
public Object get_fallback_value(){return 0;}
|
||||
public dropdownType(){};
|
||||
public DropdownType(){};
|
||||
public String get_type_name(){return "Dropdown";}
|
||||
public dropdownType(String UUID, String name, String description, String[] text_options, int defaultSelIndex){
|
||||
public DropdownType(String UUID, String name, String description, String[] text_options, int defaultSelIndex){
|
||||
super(UUID, name, description);
|
||||
this.text_options = text_options;
|
||||
this.default_value = defaultSelIndex;
|
||||
@@ -60,7 +55,7 @@ public class dropdownType extends inputType {
|
||||
|
||||
public CustomSpinnerView dropdown = null;
|
||||
|
||||
public View createView(Context context, Function<dataType, Integer> onUpdate){
|
||||
public View createView(Context context, Function<DataType, Integer> onUpdate){
|
||||
dropdown = new CustomSpinnerView(context);
|
||||
|
||||
ArrayList<String> iconSpinnerItems = new ArrayList<>(Arrays.asList(text_options));
|
||||
@@ -76,7 +71,7 @@ public class dropdownType extends inputType {
|
||||
}
|
||||
public void setViewValue(Object value) {
|
||||
if(dropdown == null) return;
|
||||
if(intType.isNull((int) value)){
|
||||
if(IntType.isNull((int) value)){
|
||||
nullify();
|
||||
return;
|
||||
}
|
||||
@@ -90,10 +85,10 @@ public class dropdownType extends inputType {
|
||||
isBlank = true;
|
||||
dropdown.setVisibility(View.GONE);
|
||||
}
|
||||
public dataType getViewValue(){
|
||||
public DataType getViewValue(){
|
||||
if(dropdown == null) return null;
|
||||
if(dropdown.getVisibility() == View.GONE) return new intType(name, intType.nullval);
|
||||
return new intType(name, dropdown.getIndex());
|
||||
if(dropdown.getVisibility() == View.GONE) return new IntType(name, IntType.nullval);
|
||||
return new IntType(name, dropdown.getIndex());
|
||||
}
|
||||
|
||||
|
||||
@@ -101,7 +96,7 @@ public class dropdownType extends inputType {
|
||||
|
||||
|
||||
|
||||
public void add_individual_view(LinearLayout parent, dataType data){
|
||||
public void add_individual_view(LinearLayout parent, DataType data){
|
||||
if(data.isNull()) return;
|
||||
TextView tv = new TextView(parent.getContext());
|
||||
tv.setLayoutParams(new FrameLayout.LayoutParams(
|
||||
@@ -137,7 +132,7 @@ public class dropdownType extends inputType {
|
||||
return colors;
|
||||
}
|
||||
|
||||
public void add_compiled_view(LinearLayout parent, dataType[] data){
|
||||
public void add_compiled_view(LinearLayout parent, DataType[] data){
|
||||
PieChart chart = new PieChart(parent.getContext());
|
||||
FrameLayout.LayoutParams layout = new FrameLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
@@ -171,7 +166,7 @@ public class dropdownType extends inputType {
|
||||
|
||||
|
||||
|
||||
public void add_history_view(LinearLayout parent, dataType[] data){
|
||||
public void add_history_view(LinearLayout parent, DataType[] data){
|
||||
LineChart chart = new LineChart(parent.getContext());
|
||||
FrameLayout.LayoutParams layout = new FrameLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
@@ -237,11 +232,11 @@ public class dropdownType extends inputType {
|
||||
parent.addView(chart);
|
||||
}
|
||||
|
||||
public void addDataToTable(LinearLayout parent, List<dataType>[] data){
|
||||
public void addDataToTable(LinearLayout parent, List<DataType>[] data){
|
||||
|
||||
}
|
||||
|
||||
public String toString(dataType data){
|
||||
public String toString(DataType data){
|
||||
return text_options[(int) data.get()];
|
||||
}
|
||||
}
|
||||
+15
-16
@@ -1,11 +1,10 @@
|
||||
package com.ridgebotics.ridgescout.types.input;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.ridgebotics.ridgescout.types.data.dataType;
|
||||
import com.ridgebotics.ridgescout.types.data.DataType;
|
||||
import com.ridgebotics.ridgescout.utility.BuiltByteParser;
|
||||
import com.ridgebotics.ridgescout.utility.ByteBuilder;
|
||||
|
||||
@@ -13,7 +12,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
public abstract class inputType {
|
||||
public abstract class FieldType {
|
||||
public static final int slider_type_id = 255;
|
||||
public static final int dropdownType = 254;
|
||||
public static final int notesType = 253;
|
||||
@@ -36,11 +35,11 @@ public abstract class inputType {
|
||||
public String description;
|
||||
public Object default_value;
|
||||
public abstract inputTypes getInputType();
|
||||
public abstract dataType.valueTypes getValueType();
|
||||
public abstract DataType.valueTypes getValueType();
|
||||
public abstract Object get_fallback_value();
|
||||
public abstract int get_byte_id();
|
||||
public inputType(){}
|
||||
public inputType(String UUID, String name, String description){
|
||||
public FieldType(){}
|
||||
public FieldType(String UUID, String name, String description){
|
||||
this.UUID = UUID;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
@@ -79,34 +78,34 @@ public abstract class inputType {
|
||||
// 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 abstract void nullify();
|
||||
public void setViewValue(dataType type){setViewValue(type.get());}
|
||||
public void setViewValue(DataType type){setViewValue(type.get());}
|
||||
public abstract void setViewValue(Object value);
|
||||
public abstract dataType getViewValue();
|
||||
public abstract DataType getViewValue();
|
||||
|
||||
|
||||
|
||||
public abstract void add_individual_view(LinearLayout parent, dataType data);
|
||||
public abstract void add_compiled_view(LinearLayout parent, dataType[] data);
|
||||
public abstract void add_history_view(LinearLayout parent, dataType[] data);
|
||||
public abstract void add_individual_view(LinearLayout parent, DataType data);
|
||||
public abstract void add_compiled_view(LinearLayout parent, DataType[] data);
|
||||
public abstract void add_history_view(LinearLayout parent, DataType[] data);
|
||||
|
||||
|
||||
public abstract void addDataToTable(LinearLayout parent, List<dataType>[] data);
|
||||
public abstract void addDataToTable(LinearLayout parent, List<DataType>[] data);
|
||||
|
||||
|
||||
public abstract String toString(dataType data);
|
||||
public abstract String toString(DataType data);
|
||||
|
||||
|
||||
public int[] getNumberBounds(List<dataType>[] data){
|
||||
public int[] getNumberBounds(List<DataType>[] data){
|
||||
int min = Integer.MAX_VALUE;
|
||||
int max = Integer.MIN_VALUE;
|
||||
|
||||
for(int teamNum = 0; teamNum < data.length; teamNum++){
|
||||
if(data[teamNum] == null) continue;
|
||||
for(int i = 0; i < data[teamNum].size(); i++){
|
||||
dataType dataPoint = data[teamNum].get(i);
|
||||
DataType dataPoint = data[teamNum].get(i);
|
||||
if(dataPoint == null || dataPoint.getValueType() != getValueType()) continue;
|
||||
int num = (int) dataPoint.get();
|
||||
if(num > max) max = num;
|
||||
+19
-29
@@ -1,29 +1,19 @@
|
||||
package com.ridgebotics.ridgescout.types.input;
|
||||
|
||||
import static android.text.InputType.TYPE_CLASS_NUMBER;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.EditText;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.github.mikephil.charting.charts.LineChart;
|
||||
import com.github.mikephil.charting.components.Legend;
|
||||
import com.github.mikephil.charting.data.Entry;
|
||||
import com.github.mikephil.charting.data.LineData;
|
||||
import com.github.mikephil.charting.data.LineDataSet;
|
||||
import com.ridgebotics.ridgescout.R;
|
||||
import com.ridgebotics.ridgescout.types.data.dataType;
|
||||
import com.ridgebotics.ridgescout.types.data.intArrType;
|
||||
import com.ridgebotics.ridgescout.types.data.intType;
|
||||
import com.ridgebotics.ridgescout.types.data.DataType;
|
||||
import com.ridgebotics.ridgescout.types.data.IntArrType;
|
||||
import com.ridgebotics.ridgescout.ui.scouting.FieldPosView;
|
||||
import com.ridgebotics.ridgescout.ui.scouting.MultiFieldPosView;
|
||||
import com.ridgebotics.ridgescout.utility.BuiltByteParser;
|
||||
@@ -33,14 +23,14 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class fieldposType extends inputType {
|
||||
public class FieldposType extends FieldType {
|
||||
public int get_byte_id() {return fieldposType;}
|
||||
public inputTypes getInputType(){return inputTypes.FIELDPOS;}
|
||||
public dataType.valueTypes getValueType(){return dataType.valueTypes.NUM;}
|
||||
public DataType.valueTypes getValueType(){return DataType.valueTypes.NUM;}
|
||||
public Object get_fallback_value(){return 0;}
|
||||
public fieldposType(){}
|
||||
public FieldposType(){}
|
||||
public String get_type_name(){return "Field Pos";}
|
||||
public fieldposType(String UUID, String name, String description, int[] default_value){
|
||||
public FieldposType(String UUID, String name, String description, int[] default_value){
|
||||
super(UUID, name, description);
|
||||
this.default_value = default_value;
|
||||
}
|
||||
@@ -63,9 +53,9 @@ public class fieldposType extends inputType {
|
||||
|
||||
public FieldPosView field = null;
|
||||
|
||||
public View createView(Context context, Function<dataType, Integer> onUpdate){
|
||||
public View createView(Context context, Function<DataType, Integer> onUpdate){
|
||||
field = new FieldPosView(context, pos -> {
|
||||
onUpdate.apply(new intArrType(name, pos));
|
||||
onUpdate.apply(new IntArrType(name, pos));
|
||||
});
|
||||
setViewValue(default_value);
|
||||
return field;
|
||||
@@ -74,7 +64,7 @@ public class fieldposType extends inputType {
|
||||
|
||||
public void setViewValue(Object value) {
|
||||
if(field == null) return;
|
||||
if(intArrType.isNull((int[]) value)){
|
||||
if(IntArrType.isNull((int[]) value)){
|
||||
nullify();
|
||||
return;
|
||||
}
|
||||
@@ -91,15 +81,15 @@ public class fieldposType extends inputType {
|
||||
isBlank = true;
|
||||
field.setVisibility(View.GONE);
|
||||
}
|
||||
public dataType getViewValue(){
|
||||
public DataType getViewValue(){
|
||||
if(field == null) return null;
|
||||
if(field.getVisibility() == View.GONE) return intArrType.newNull(name);
|
||||
return new intArrType(name, field.getPos());
|
||||
if(field.getVisibility() == View.GONE) return IntArrType.newNull(name);
|
||||
return new IntArrType(name, field.getPos());
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void add_individual_view(LinearLayout parent, dataType data){
|
||||
public void add_individual_view(LinearLayout parent, DataType data){
|
||||
if(data.isNull()) return;
|
||||
|
||||
FieldPosView fp = new FieldPosView(parent.getContext());
|
||||
@@ -142,7 +132,7 @@ public class fieldposType extends inputType {
|
||||
return entries;
|
||||
}
|
||||
|
||||
private static int findMin(dataType[] data){
|
||||
private static int findMin(DataType[] data){
|
||||
int min = (int)data[0].get();
|
||||
for(int i = 1; i < data.length; i++)
|
||||
if((int)data[i].get() < min)
|
||||
@@ -150,7 +140,7 @@ public class fieldposType extends inputType {
|
||||
return min;
|
||||
}
|
||||
|
||||
private static int findMax(dataType[] data){
|
||||
private static int findMax(DataType[] data){
|
||||
int max = (int)data[0].get();
|
||||
for(int i = 1; i < data.length; i++)
|
||||
if((int)data[i].get() > max)
|
||||
@@ -158,7 +148,7 @@ public class fieldposType extends inputType {
|
||||
return max;
|
||||
}
|
||||
|
||||
public void add_compiled_view(LinearLayout parent, dataType[] data){
|
||||
public void add_compiled_view(LinearLayout parent, DataType[] data){
|
||||
MultiFieldPosView mfp = new MultiFieldPosView(parent.getContext());
|
||||
for(int i = 0; i < data.length; i++){
|
||||
if(data[i].isNull()) continue;
|
||||
@@ -167,7 +157,7 @@ public class fieldposType extends inputType {
|
||||
parent.addView(mfp);
|
||||
}
|
||||
|
||||
public void add_history_view(LinearLayout parent, dataType[] data){
|
||||
public void add_history_view(LinearLayout parent, DataType[] data){
|
||||
LineChart chart = new LineChart(parent.getContext());
|
||||
FrameLayout.LayoutParams layout = new FrameLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
@@ -224,11 +214,11 @@ public class fieldposType extends inputType {
|
||||
parent.addView(chart);
|
||||
}
|
||||
|
||||
public void addDataToTable(LinearLayout parent, List<dataType>[] data){
|
||||
public void addDataToTable(LinearLayout parent, List<DataType>[] data){
|
||||
|
||||
}
|
||||
|
||||
public String toString(dataType data){
|
||||
public String toString(DataType data){
|
||||
int[] intarr = (int[]) data.get();
|
||||
return "[" + intarr[0] + "," + intarr[1] + "]";
|
||||
}
|
||||
+20
-21
@@ -2,7 +2,6 @@ package com.ridgebotics.ridgescout.types.input;
|
||||
|
||||
import static android.text.InputType.TYPE_CLASS_NUMBER;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.text.Editable;
|
||||
@@ -20,8 +19,8 @@ import com.github.mikephil.charting.components.Legend;
|
||||
import com.github.mikephil.charting.data.Entry;
|
||||
import com.github.mikephil.charting.data.LineData;
|
||||
import com.github.mikephil.charting.data.LineDataSet;
|
||||
import com.ridgebotics.ridgescout.types.data.dataType;
|
||||
import com.ridgebotics.ridgescout.types.data.intType;
|
||||
import com.ridgebotics.ridgescout.types.data.DataType;
|
||||
import com.ridgebotics.ridgescout.types.data.IntType;
|
||||
import com.ridgebotics.ridgescout.utility.BuiltByteParser;
|
||||
import com.ridgebotics.ridgescout.utility.ByteBuilder;
|
||||
|
||||
@@ -29,14 +28,14 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class numberType extends inputType {
|
||||
public class NumberType extends FieldType {
|
||||
public int get_byte_id() {return numberType;}
|
||||
public inputTypes getInputType(){return inputTypes.NUMBER;}
|
||||
public dataType.valueTypes getValueType(){return dataType.valueTypes.NUM;}
|
||||
public DataType.valueTypes getValueType(){return DataType.valueTypes.NUM;}
|
||||
public Object get_fallback_value(){return 0;}
|
||||
public numberType(){}
|
||||
public NumberType(){}
|
||||
public String get_type_name(){return "Number";}
|
||||
public numberType(String UUID, String name, String description, int default_value){
|
||||
public NumberType(String UUID, String name, String description, int default_value){
|
||||
super(UUID, name, description);
|
||||
this.default_value = default_value;
|
||||
}
|
||||
@@ -58,7 +57,7 @@ public class numberType extends inputType {
|
||||
|
||||
public EditText num = null;
|
||||
|
||||
public View createView(Context context, Function<dataType, Integer> onUpdate){
|
||||
public View createView(Context context, Function<DataType, Integer> onUpdate){
|
||||
num = new EditText(context);
|
||||
num.setInputType(TYPE_CLASS_NUMBER);
|
||||
num.addTextChangedListener(new TextWatcher() {
|
||||
@@ -76,7 +75,7 @@ public class numberType extends inputType {
|
||||
|
||||
public void setViewValue(Object value) {
|
||||
if(num == null) return;
|
||||
if(intType.isNull((int)value)){
|
||||
if(IntType.isNull((int)value)){
|
||||
nullify();
|
||||
return;
|
||||
}
|
||||
@@ -89,28 +88,28 @@ public class numberType extends inputType {
|
||||
isBlank = true;
|
||||
num.setVisibility(View.GONE);
|
||||
}
|
||||
public dataType getViewValue(){
|
||||
public DataType getViewValue(){
|
||||
if(num == null) return null;
|
||||
if(num.getVisibility() == View.GONE) return intType.newNull(name);
|
||||
return new intType(name, safeToInt(num.getText().toString()));
|
||||
if(num.getVisibility() == View.GONE) return IntType.newNull(name);
|
||||
return new IntType(name, safeToInt(num.getText().toString()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
private int safeToInt(String num){
|
||||
if(num.isEmpty())
|
||||
return intType.nullval;
|
||||
return IntType.nullval;
|
||||
try {
|
||||
return Integer.parseInt(num);
|
||||
}catch (NumberFormatException e){
|
||||
return intType.nullval;
|
||||
return IntType.nullval;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void add_individual_view(LinearLayout parent, dataType data){
|
||||
public void add_individual_view(LinearLayout parent, DataType data){
|
||||
if(data.isNull()) return;
|
||||
|
||||
TextView tv = new TextView(parent.getContext());
|
||||
@@ -157,7 +156,7 @@ public class numberType extends inputType {
|
||||
return entries;
|
||||
}
|
||||
|
||||
private static int findMin(dataType[] data){
|
||||
private static int findMin(DataType[] data){
|
||||
int min = (int)data[0].get();
|
||||
for(int i = 1; i < data.length; i++)
|
||||
if((int)data[i].get() < min)
|
||||
@@ -165,7 +164,7 @@ public class numberType extends inputType {
|
||||
return min;
|
||||
}
|
||||
|
||||
private static int findMax(dataType[] data){
|
||||
private static int findMax(DataType[] data){
|
||||
int max = (int)data[0].get();
|
||||
for(int i = 1; i < data.length; i++)
|
||||
if((int)data[i].get() > max)
|
||||
@@ -173,7 +172,7 @@ public class numberType extends inputType {
|
||||
return max;
|
||||
}
|
||||
|
||||
public void add_compiled_view(LinearLayout parent, dataType[] data){
|
||||
public void add_compiled_view(LinearLayout parent, DataType[] data){
|
||||
LineChart chart = new LineChart(parent.getContext());
|
||||
FrameLayout.LayoutParams layout = new FrameLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
@@ -252,7 +251,7 @@ public class numberType extends inputType {
|
||||
|
||||
|
||||
|
||||
public void add_history_view(LinearLayout parent, dataType[] data){
|
||||
public void add_history_view(LinearLayout parent, DataType[] data){
|
||||
LineChart chart = new LineChart(parent.getContext());
|
||||
FrameLayout.LayoutParams layout = new FrameLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
@@ -310,11 +309,11 @@ public class numberType extends inputType {
|
||||
parent.addView(chart);
|
||||
}
|
||||
|
||||
public void addDataToTable(LinearLayout parent, List<dataType>[] data){
|
||||
public void addDataToTable(LinearLayout parent, List<DataType>[] data){
|
||||
|
||||
}
|
||||
|
||||
public String toString(dataType data){
|
||||
public String toString(DataType data){
|
||||
return String.valueOf((int) data.get());
|
||||
}
|
||||
}
|
||||
+16
-16
@@ -9,8 +9,8 @@ import android.widget.LinearLayout;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.ridgebotics.ridgescout.types.data.dataType;
|
||||
import com.ridgebotics.ridgescout.types.data.intType;
|
||||
import com.ridgebotics.ridgescout.types.data.DataType;
|
||||
import com.ridgebotics.ridgescout.types.data.IntType;
|
||||
import com.ridgebotics.ridgescout.utility.AlertManager;
|
||||
import com.ridgebotics.ridgescout.utility.BuiltByteParser;
|
||||
import com.ridgebotics.ridgescout.utility.ByteBuilder;
|
||||
@@ -25,17 +25,17 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class sliderType extends inputType {
|
||||
public class SliderType extends FieldType {
|
||||
// public int defaultValue;
|
||||
public int min;
|
||||
public int max;
|
||||
public int get_byte_id() {return slider_type_id;}
|
||||
public inputTypes getInputType(){return inputTypes.SLIDER;}
|
||||
public dataType.valueTypes getValueType(){return dataType.valueTypes.NUM;}
|
||||
public DataType.valueTypes getValueType(){return DataType.valueTypes.NUM;}
|
||||
public Object get_fallback_value(){return 0;}
|
||||
public sliderType(){};
|
||||
public SliderType(){};
|
||||
public String get_type_name(){return "Slider";}
|
||||
public sliderType(String UUID, String name, String description, int defaultValue, int min, int max){
|
||||
public SliderType(String UUID, String name, String description, int defaultValue, int min, int max){
|
||||
super(UUID, name, description);
|
||||
this.default_value = defaultValue;
|
||||
this.min = min;
|
||||
@@ -61,7 +61,7 @@ public class sliderType extends inputType {
|
||||
|
||||
public Slider slider = null;
|
||||
|
||||
public View createView(Context context, Function<dataType, Integer> onUpdate){
|
||||
public View createView(Context context, Function<DataType, Integer> onUpdate){
|
||||
slider = new Slider(context);
|
||||
setViewValue(default_value);
|
||||
slider.setStepSize((float) 1 / (max-min));
|
||||
@@ -76,7 +76,7 @@ public class sliderType extends inputType {
|
||||
|
||||
public void setViewValue(Object value) {
|
||||
if(slider == null) return;
|
||||
if(intType.isNull((int) value)){
|
||||
if(IntType.isNull((int) value)){
|
||||
nullify();
|
||||
return;
|
||||
}
|
||||
@@ -96,10 +96,10 @@ public class sliderType extends inputType {
|
||||
|
||||
slider.setVisibility(View.VISIBLE);
|
||||
}
|
||||
public dataType getViewValue(){
|
||||
public DataType getViewValue(){
|
||||
if(slider == null) return null;
|
||||
if(slider.getVisibility() == View.GONE) return intType.newNull(name);
|
||||
return new intType(name, min + (int) (slider.getValue() * (max-min)));
|
||||
if(slider.getVisibility() == View.GONE) return IntType.newNull(name);
|
||||
return new IntType(name, min + (int) (slider.getValue() * (max-min)));
|
||||
}
|
||||
public void nullify(){
|
||||
isBlank = true;
|
||||
@@ -111,7 +111,7 @@ public class sliderType extends inputType {
|
||||
|
||||
|
||||
|
||||
public void add_individual_view(LinearLayout parent, dataType data){
|
||||
public void add_individual_view(LinearLayout parent, DataType data){
|
||||
if(data.isNull()) return;
|
||||
Slider slider = new Slider(parent.getContext());
|
||||
|
||||
@@ -165,7 +165,7 @@ public class sliderType extends inputType {
|
||||
return entries;
|
||||
}
|
||||
|
||||
public void add_compiled_view(LinearLayout parent, dataType[] data){
|
||||
public void add_compiled_view(LinearLayout parent, DataType[] data){
|
||||
LineChart chart = new LineChart(parent.getContext());
|
||||
FrameLayout.LayoutParams layout = new FrameLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
@@ -241,7 +241,7 @@ public class sliderType extends inputType {
|
||||
|
||||
|
||||
|
||||
public void add_history_view(LinearLayout parent, dataType[] data){
|
||||
public void add_history_view(LinearLayout parent, DataType[] data){
|
||||
LineChart chart = new LineChart(parent.getContext());
|
||||
FrameLayout.LayoutParams layout = new FrameLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
@@ -296,11 +296,11 @@ public class sliderType extends inputType {
|
||||
parent.addView(chart);
|
||||
}
|
||||
|
||||
public void addDataToTable(LinearLayout parent, List<dataType>[] data){
|
||||
public void addDataToTable(LinearLayout parent, List<DataType>[] data){
|
||||
|
||||
}
|
||||
|
||||
public String toString(dataType data){
|
||||
public String toString(DataType data){
|
||||
return String.valueOf((int) data.get());
|
||||
}
|
||||
}
|
||||
+19
-20
@@ -1,6 +1,5 @@
|
||||
package com.ridgebotics.ridgescout.types.input;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.view.Gravity;
|
||||
@@ -10,8 +9,8 @@ import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.ridgebotics.ridgescout.types.data.dataType;
|
||||
import com.ridgebotics.ridgescout.types.data.intType;
|
||||
import com.ridgebotics.ridgescout.types.data.DataType;
|
||||
import com.ridgebotics.ridgescout.types.data.IntType;
|
||||
import com.ridgebotics.ridgescout.ui.scouting.TallyCounterView;
|
||||
import com.ridgebotics.ridgescout.utility.AlertManager;
|
||||
import com.ridgebotics.ridgescout.utility.BuiltByteParser;
|
||||
@@ -26,14 +25,14 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class tallyType extends inputType {
|
||||
public class TallyType extends FieldType {
|
||||
public int get_byte_id() {return tallyType;}
|
||||
public inputTypes getInputType(){return inputTypes.TALLY;}
|
||||
public dataType.valueTypes getValueType(){return dataType.valueTypes.NUM;}
|
||||
public DataType.valueTypes getValueType(){return DataType.valueTypes.NUM;}
|
||||
public Object get_fallback_value(){return 0;}
|
||||
public tallyType(){}
|
||||
public TallyType(){}
|
||||
public String get_type_name(){return "Tally";}
|
||||
public tallyType(String UUID, String name, String description, int default_value){
|
||||
public TallyType(String UUID, String name, String description, int default_value){
|
||||
super(UUID, name, description);
|
||||
this.default_value = default_value;
|
||||
}
|
||||
@@ -55,7 +54,7 @@ public class tallyType extends inputType {
|
||||
|
||||
public TallyCounterView tally = null;
|
||||
|
||||
public View createView(Context context, Function<dataType, Integer> onUpdate){
|
||||
public View createView(Context context, Function<DataType, Integer> onUpdate){
|
||||
tally = new TallyCounterView(context);
|
||||
tally.setOnCountChangedListener(n -> onUpdate.apply(getViewValue()));
|
||||
|
||||
@@ -67,7 +66,7 @@ public class tallyType extends inputType {
|
||||
|
||||
public void setViewValue(Object value) {
|
||||
if(tally == null) return;
|
||||
if(intType.isNull((int)value)){
|
||||
if(IntType.isNull((int)value)){
|
||||
nullify();
|
||||
return;
|
||||
}
|
||||
@@ -80,10 +79,10 @@ public class tallyType extends inputType {
|
||||
isBlank = true;
|
||||
tally.setVisibility(View.GONE);
|
||||
}
|
||||
public dataType getViewValue(){
|
||||
public DataType getViewValue(){
|
||||
if(tally == null) return null;
|
||||
if(tally.getVisibility() == View.GONE) return intType.newNull(name);
|
||||
return new intType(name, tally.getValue());
|
||||
if(tally.getVisibility() == View.GONE) return IntType.newNull(name);
|
||||
return new IntType(name, tally.getValue());
|
||||
}
|
||||
|
||||
|
||||
@@ -91,7 +90,7 @@ public class tallyType extends inputType {
|
||||
|
||||
|
||||
|
||||
public void add_individual_view(LinearLayout parent, dataType data){
|
||||
public void add_individual_view(LinearLayout parent, DataType data){
|
||||
if(data.isNull()) return;
|
||||
|
||||
TextView tv = new TextView(parent.getContext());
|
||||
@@ -138,7 +137,7 @@ public class tallyType extends inputType {
|
||||
return entries;
|
||||
}
|
||||
|
||||
private static int findMin(dataType[] data){
|
||||
private static int findMin(DataType[] data){
|
||||
int min = (int)data[0].get();
|
||||
for(int i = 1; i < data.length; i++)
|
||||
if((int)data[i].get() < min)
|
||||
@@ -146,7 +145,7 @@ public class tallyType extends inputType {
|
||||
return min;
|
||||
}
|
||||
|
||||
private static int findMax(dataType[] data){
|
||||
private static int findMax(DataType[] data){
|
||||
int max = (int)data[0].get();
|
||||
for(int i = 1; i < data.length; i++)
|
||||
if((int)data[i].get() > max)
|
||||
@@ -154,7 +153,7 @@ public class tallyType extends inputType {
|
||||
return max;
|
||||
}
|
||||
|
||||
public void add_compiled_view(LinearLayout parent, dataType[] data){
|
||||
public void add_compiled_view(LinearLayout parent, DataType[] data){
|
||||
LineChart chart = new LineChart(parent.getContext());
|
||||
FrameLayout.LayoutParams layout = new FrameLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
@@ -233,7 +232,7 @@ public class tallyType extends inputType {
|
||||
|
||||
|
||||
|
||||
public void add_history_view(LinearLayout parent, dataType[] data){
|
||||
public void add_history_view(LinearLayout parent, DataType[] data){
|
||||
LineChart chart = new LineChart(parent.getContext());
|
||||
FrameLayout.LayoutParams layout = new FrameLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
@@ -291,14 +290,14 @@ public class tallyType extends inputType {
|
||||
parent.addView(chart);
|
||||
}
|
||||
|
||||
public void addDataToTable(LinearLayout parent, List<dataType>[] data){
|
||||
public void addDataToTable(LinearLayout parent, List<DataType>[] data){
|
||||
int min = Integer.MAX_VALUE;
|
||||
int max = Integer.MIN_VALUE;
|
||||
|
||||
for(int teamNum = 0; teamNum < data.length; teamNum++){
|
||||
if(data[teamNum] == null) continue;
|
||||
for(int i = 0; i < data[teamNum].size(); i++){
|
||||
dataType dataPoint = data[teamNum].get(i);
|
||||
DataType dataPoint = data[teamNum].get(i);
|
||||
if(dataPoint == null || dataPoint.getValueType() != getValueType()) continue;
|
||||
int num = (int) dataPoint.get();
|
||||
System.out.println(num);
|
||||
@@ -310,7 +309,7 @@ public class tallyType extends inputType {
|
||||
AlertManager.alert("Results","Min: " + min + " Max: " + max);
|
||||
}
|
||||
|
||||
public String toString(dataType data){
|
||||
public String toString(DataType data){
|
||||
return String.valueOf((int) data.get());
|
||||
}
|
||||
}
|
||||
+16
-17
@@ -1,6 +1,5 @@
|
||||
package com.ridgebotics.ridgescout.types.input;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.text.Editable;
|
||||
@@ -13,8 +12,8 @@ import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.ridgebotics.ridgescout.types.data.dataType;
|
||||
import com.ridgebotics.ridgescout.types.data.stringType;
|
||||
import com.ridgebotics.ridgescout.types.data.DataType;
|
||||
import com.ridgebotics.ridgescout.types.data.StringType;
|
||||
import com.ridgebotics.ridgescout.utility.SentimentAnalysis;
|
||||
import com.ridgebotics.ridgescout.utility.BuiltByteParser;
|
||||
import com.ridgebotics.ridgescout.utility.ByteBuilder;
|
||||
@@ -28,14 +27,14 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class textType extends inputType {
|
||||
public class TextType extends FieldType {
|
||||
|
||||
public int get_byte_id() {return notesType;}
|
||||
public inputTypes getInputType(){return inputTypes.NOTES_INPUT;}
|
||||
public dataType.valueTypes getValueType(){return dataType.valueTypes.STRING;}
|
||||
public DataType.valueTypes getValueType(){return DataType.valueTypes.STRING;}
|
||||
public Object get_fallback_value(){return "<no-notes>";}
|
||||
public textType(){}
|
||||
public textType(String UUID, String name, String description, String default_text){
|
||||
public TextType(){}
|
||||
public TextType(String UUID, String name, String description, String default_text){
|
||||
super(UUID, name, description);
|
||||
this.default_value = default_text;
|
||||
}
|
||||
@@ -69,7 +68,7 @@ public class textType extends inputType {
|
||||
|
||||
public EditText text = null;
|
||||
|
||||
public View createView(Context context, Function<dataType, Integer> onUpdate){
|
||||
public View createView(Context context, Function<DataType, Integer> onUpdate){
|
||||
text = new EditText(context);
|
||||
text.setText((String)default_value);
|
||||
text.addTextChangedListener(new TextWatcher() {
|
||||
@@ -83,7 +82,7 @@ public class textType extends inputType {
|
||||
}
|
||||
public void setViewValue(Object value) {
|
||||
if(text == null) return;
|
||||
if(stringType.isNull((String) value)){
|
||||
if(StringType.isNull((String) value)){
|
||||
nullify();
|
||||
return;
|
||||
}
|
||||
@@ -95,16 +94,16 @@ public class textType extends inputType {
|
||||
isBlank = true;
|
||||
text.setVisibility(View.GONE);
|
||||
}
|
||||
public dataType getViewValue(){
|
||||
public DataType getViewValue(){
|
||||
if(text == null) return null;
|
||||
if(text.getVisibility() == View.GONE) return new stringType(name, stringType.nullval);
|
||||
return new stringType(name, text.getText().toString());
|
||||
if(text.getVisibility() == View.GONE) return new StringType(name, StringType.nullval);
|
||||
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){
|
||||
if(data.isNull()) return;
|
||||
TextView tv = new TextView(parent.getContext());
|
||||
tv.setLayoutParams(new FrameLayout.LayoutParams(
|
||||
@@ -134,7 +133,7 @@ public class textType extends inputType {
|
||||
|
||||
TextView positive_text;
|
||||
|
||||
public void add_compiled_view(LinearLayout parent, dataType[] data) {
|
||||
public void add_compiled_view(LinearLayout parent, DataType[] data) {
|
||||
positive_mean = 0;
|
||||
count = 0;
|
||||
|
||||
@@ -163,7 +162,7 @@ public class textType extends inputType {
|
||||
}
|
||||
|
||||
|
||||
public void add_history_view(LinearLayout parent, dataType[] data){
|
||||
public void add_history_view(LinearLayout parent, DataType[] data){
|
||||
LineChart chart = new LineChart(parent.getContext());
|
||||
FrameLayout.LayoutParams layout = new FrameLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
@@ -222,11 +221,11 @@ public class textType extends inputType {
|
||||
|
||||
}
|
||||
|
||||
public void addDataToTable(LinearLayout parent, List<dataType>[] data){
|
||||
public void addDataToTable(LinearLayout parent, List<DataType>[] data){
|
||||
|
||||
}
|
||||
|
||||
public String toString(dataType data){
|
||||
public String toString(DataType data){
|
||||
return String.valueOf(data.get());
|
||||
}
|
||||
}
|
||||
@@ -1,27 +1,19 @@
|
||||
package com.ridgebotics.ridgescout.ui;
|
||||
|
||||
import static android.app.PendingIntent.getActivity;
|
||||
import static com.ridgebotics.ridgescout.utility.settingsManager.getEditor;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
||||
import com.ridgebotics.ridgescout.R;
|
||||
import com.ridgebotics.ridgescout.databinding.ViewCustomSpinnerBinding;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CustomSpinnerView extends LinearLayout {
|
||||
|
||||
@@ -7,7 +7,6 @@ import android.graphics.drawable.Drawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TableRow;
|
||||
import android.widget.TextView;
|
||||
|
||||
@@ -15,7 +14,7 @@ import androidx.annotation.Nullable;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
|
||||
import com.ridgebotics.ridgescout.R;
|
||||
import com.ridgebotics.ridgescout.types.input.inputType;
|
||||
import com.ridgebotics.ridgescout.types.input.FieldType;
|
||||
|
||||
public class FieldBorderedRow extends TableRow {
|
||||
public FieldBorderedRow(Context context, @Nullable AttributeSet attrs) {
|
||||
@@ -55,7 +54,7 @@ public class FieldBorderedRow extends TableRow {
|
||||
);
|
||||
}
|
||||
|
||||
public void fromField(inputType field){
|
||||
public void fromField(FieldType field){
|
||||
((TextView) findViewById(R.id.field_option_name)).setText(field.name);
|
||||
((TextView) findViewById(R.id.field_option_type)).setText(field.get_type_name());
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import androidx.annotation.Nullable;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
|
||||
import com.ridgebotics.ridgescout.R;
|
||||
import com.ridgebotics.ridgescout.types.input.inputType;
|
||||
import com.ridgebotics.ridgescout.types.input.FieldType;
|
||||
|
||||
public class FieldDisplay extends ConstraintLayout {
|
||||
public FieldDisplay(Context context, @Nullable AttributeSet attrs) {
|
||||
@@ -28,7 +28,7 @@ public class FieldDisplay extends ConstraintLayout {
|
||||
init(context);
|
||||
}
|
||||
|
||||
private inputType field;
|
||||
private FieldType field;
|
||||
|
||||
public Button editButton;
|
||||
|
||||
@@ -46,13 +46,15 @@ public class FieldDisplay extends ConstraintLayout {
|
||||
box = findViewById(R.id.field_box);
|
||||
coloredBackground = findViewById(R.id.field_background);
|
||||
|
||||
editButton = findViewById(R.id.button_edit);
|
||||
|
||||
titleText = findViewById(R.id.field_title);
|
||||
typeText = findViewById(R.id.field_description);
|
||||
|
||||
buttonBox = findViewById(R.id.buttons);
|
||||
}
|
||||
|
||||
public void setInputType(inputType field){
|
||||
public void setInputType(FieldType field){
|
||||
this.field = field;
|
||||
|
||||
titleText.setText(field.name);
|
||||
@@ -87,6 +89,10 @@ public class FieldDisplay extends ConstraintLayout {
|
||||
findViewById(R.id.buttons).setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
public FieldType getField(){
|
||||
return field;
|
||||
}
|
||||
|
||||
public void setColor(int color){
|
||||
Drawable drawable = box.getBackground();
|
||||
drawable.mutate();
|
||||
|
||||
@@ -17,7 +17,6 @@ import com.ridgebotics.ridgescout.databinding.FragmentTeamSelectorBinding;
|
||||
import com.ridgebotics.ridgescout.types.frcTeam;
|
||||
import com.ridgebotics.ridgescout.utility.AlertManager;
|
||||
import com.ridgebotics.ridgescout.utility.DataManager;
|
||||
import com.ridgebotics.ridgescout.utility.fileEditor;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.ridgebotics.ridgescout.ui.data;
|
||||
|
||||
|
||||
import static android.view.View.GONE;
|
||||
import static android.view.View.TEXT_ALIGNMENT_VIEW_END;
|
||||
import static android.view.View.VISIBLE;
|
||||
import static androidx.navigation.fragment.FragmentKt.findNavController;
|
||||
|
||||
@@ -11,34 +10,23 @@ import static com.ridgebotics.ridgescout.utility.DataManager.event;
|
||||
import static com.ridgebotics.ridgescout.utility.DataManager.match_latest_values;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TableRow;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.ridgebotics.ridgescout.R;
|
||||
import com.ridgebotics.ridgescout.scoutingData.fields;
|
||||
import com.ridgebotics.ridgescout.types.frcTeam;
|
||||
import com.ridgebotics.ridgescout.ui.CustomSpinnerView;
|
||||
import com.ridgebotics.ridgescout.ui.FieldBorderedRow;
|
||||
import com.ridgebotics.ridgescout.ui.TeamListOption;
|
||||
import com.ridgebotics.ridgescout.ui.settings.FieldsFragment;
|
||||
import com.ridgebotics.ridgescout.utility.AlertManager;
|
||||
import com.ridgebotics.ridgescout.utility.DataManager;
|
||||
import com.ridgebotics.ridgescout.utility.settingsManager;
|
||||
import com.ridgebotics.ridgescout.utility.SettingsManager;
|
||||
import com.ridgebotics.ridgescout.databinding.FragmentDataBinding;
|
||||
import com.ridgebotics.ridgescout.ui.TeamSelectorFragment;
|
||||
import com.ridgebotics.ridgescout.utility.fileEditor;
|
||||
import com.ridgebotics.ridgescout.types.frcEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@@ -62,7 +50,7 @@ public class DataFragment extends Fragment {
|
||||
return root;
|
||||
}
|
||||
|
||||
option = settingsManager.getDataMode();
|
||||
option = SettingsManager.getDataMode();
|
||||
|
||||
binding.dataTypeDropdown.setTitle("Data type");
|
||||
binding.dataTypeDropdown.setOptions(List.of(new String[]{
|
||||
@@ -70,7 +58,7 @@ public class DataFragment extends Fragment {
|
||||
}), option);
|
||||
binding.dataTypeDropdown.setOnClickListener((item, index) -> {
|
||||
option = index;
|
||||
settingsManager.setDataMode(option);
|
||||
SettingsManager.setDataMode(option);
|
||||
reload_views();
|
||||
});
|
||||
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package com.ridgebotics.ridgescout.ui.data;
|
||||
|
||||
|
||||
import static android.view.View.GONE;
|
||||
import static android.view.View.VISIBLE;
|
||||
import static androidx.navigation.fragment.FragmentKt.findNavController;
|
||||
import static com.ridgebotics.ridgescout.utility.DataManager.evcode;
|
||||
import static com.ridgebotics.ridgescout.utility.DataManager.event;
|
||||
import static com.ridgebotics.ridgescout.utility.DataManager.match_latest_values;
|
||||
@@ -21,21 +18,13 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.ridgebotics.ridgescout.R;
|
||||
import com.ridgebotics.ridgescout.databinding.FragmentDataBinding;
|
||||
import com.ridgebotics.ridgescout.databinding.FragmentDataFieldDataBinding;
|
||||
import com.ridgebotics.ridgescout.scoutingData.ScoutingDataWriter;
|
||||
import com.ridgebotics.ridgescout.types.data.dataType;
|
||||
import com.ridgebotics.ridgescout.types.frcTeam;
|
||||
import com.ridgebotics.ridgescout.ui.FieldBorderedRow;
|
||||
import com.ridgebotics.ridgescout.ui.TeamListOption;
|
||||
import com.ridgebotics.ridgescout.types.data.DataType;
|
||||
import com.ridgebotics.ridgescout.utility.AlertManager;
|
||||
import com.ridgebotics.ridgescout.utility.DataManager;
|
||||
import com.ridgebotics.ridgescout.utility.fileEditor;
|
||||
import com.ridgebotics.ridgescout.utility.settingsManager;
|
||||
import com.ridgebotics.ridgescout.utility.FileEditor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class FieldDataFragment extends Fragment {
|
||||
@@ -61,10 +50,10 @@ public class FieldDataFragment extends Fragment {
|
||||
|
||||
Thread t = new Thread(() -> {
|
||||
|
||||
List<dataType>[] data = new ArrayList[event.teams.size()];
|
||||
List<DataType>[] data = new ArrayList[event.teams.size()];
|
||||
for (int teamIndex = 0; teamIndex < event.teams.size(); teamIndex++) {
|
||||
|
||||
List<String> filenames = new ArrayList<>(List.of(fileEditor.getMatchesByTeamNum(evcode, event.teams.get(teamIndex).teamNumber)));
|
||||
List<String> filenames = new ArrayList<>(List.of(FileEditor.getMatchesByTeamNum(evcode, event.teams.get(teamIndex).teamNumber)));
|
||||
filenames.removeAll(rescout_list);
|
||||
|
||||
for (int i = 0; i < filenames.size(); i++) {
|
||||
|
||||
@@ -14,24 +14,20 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TableLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.ridgebotics.ridgescout.ui.CustomSpinnerView;
|
||||
import com.ridgebotics.ridgescout.utility.AlertManager;
|
||||
import com.ridgebotics.ridgescout.utility.settingsManager;
|
||||
import com.ridgebotics.ridgescout.utility.SettingsManager;
|
||||
import com.ridgebotics.ridgescout.databinding.FragmentDataTeamsBinding;
|
||||
import com.ridgebotics.ridgescout.scoutingData.ScoutingDataWriter;
|
||||
import com.ridgebotics.ridgescout.types.data.dataType;
|
||||
import com.ridgebotics.ridgescout.types.data.DataType;
|
||||
import com.ridgebotics.ridgescout.types.frcTeam;
|
||||
import com.ridgebotics.ridgescout.utility.DataManager;
|
||||
import com.ridgebotics.ridgescout.utility.fileEditor;
|
||||
import com.google.android.material.divider.MaterialDivider;
|
||||
import com.ridgebotics.ridgescout.utility.FileEditor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -60,14 +56,14 @@ public class TeamsFragment extends Fragment {
|
||||
options.add("Compiled");
|
||||
options.add("History");
|
||||
|
||||
binding.dataTypeSpinner.setOptions(options, settingsManager.getTeamsDataMode());
|
||||
binding.dataTypeSpinner.setOptions(options, SettingsManager.getTeamsDataMode());
|
||||
|
||||
binding.dataTypeSpinner.setOnClickListener((item, index) -> {
|
||||
settingsManager.setTeamsDataMode(index);
|
||||
SettingsManager.setTeamsDataMode(index);
|
||||
loadTeam(index);
|
||||
});
|
||||
|
||||
loadTeam(settingsManager.getTeamsDataMode());
|
||||
loadTeam(SettingsManager.getTeamsDataMode());
|
||||
|
||||
return binding.getRoot();
|
||||
}
|
||||
@@ -117,7 +113,7 @@ public class TeamsFragment extends Fragment {
|
||||
|
||||
// ll.addView(new MaterialDivider(getContext()));
|
||||
|
||||
if(!fileEditor.fileExist(filename)){
|
||||
if(!FileEditor.fileExist(filename)){
|
||||
TextView tv = new TextView(getContext());
|
||||
tv.setLayoutParams(new FrameLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
@@ -173,7 +169,7 @@ public class TeamsFragment extends Fragment {
|
||||
public void add_match_data(frcTeam team, int mode){
|
||||
binding.matchArea.removeAllViews();
|
||||
binding.individualViewSelector.setVisibility(View.GONE);
|
||||
String[] files = fileEditor.getMatchesByTeamNum(evcode, team.teamNumber);
|
||||
String[] files = FileEditor.getMatchesByTeamNum(evcode, team.teamNumber);
|
||||
|
||||
if(files.length == 0){
|
||||
TextView tv = new TextView(getContext());
|
||||
@@ -281,7 +277,7 @@ public class TeamsFragment extends Fragment {
|
||||
|
||||
|
||||
public void add_compiled_views(String[] files){
|
||||
dataType[][] data = new dataType[match_latest_values.length][files.length];
|
||||
DataType[][] data = new DataType[match_latest_values.length][files.length];
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
try {
|
||||
ScoutingDataWriter.ParsedScoutingDataResult psda = ScoutingDataWriter.load(files[i], match_values, match_transferValues);
|
||||
@@ -316,7 +312,7 @@ public class TeamsFragment extends Fragment {
|
||||
|
||||
|
||||
public void add_history_views(String[] files){
|
||||
dataType[][] data = new dataType[match_latest_values.length][files.length];
|
||||
DataType[][] data = new DataType[match_latest_values.length][files.length];
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
try {
|
||||
ScoutingDataWriter.ParsedScoutingDataResult psda = ScoutingDataWriter.load(files[i], match_values, match_transferValues);
|
||||
|
||||
@@ -1,18 +1,13 @@
|
||||
package com.ridgebotics.ridgescout.ui.scouting;
|
||||
|
||||
import static android.widget.LinearLayout.HORIZONTAL;
|
||||
import static com.ridgebotics.ridgescout.utility.DataManager.evcode;
|
||||
import static com.ridgebotics.ridgescout.utility.DataManager.event;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.text.InputType;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ScrollView;
|
||||
@@ -21,17 +16,16 @@ import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.ridgebotics.ridgescout.databinding.FragmentScoutingEventBinding;
|
||||
import com.ridgebotics.ridgescout.types.frcTeam;
|
||||
import com.ridgebotics.ridgescout.ui.CustomSpinnerView;
|
||||
import com.ridgebotics.ridgescout.utility.DataManager;
|
||||
import com.ridgebotics.ridgescout.utility.fileEditor;
|
||||
import com.ridgebotics.ridgescout.utility.FileEditor;
|
||||
import com.ridgebotics.ridgescout.types.frcEvent;
|
||||
import com.ridgebotics.ridgescout.types.frcMatch;
|
||||
import com.ridgebotics.ridgescout.utility.settingsManager;
|
||||
import com.ridgebotics.ridgescout.utility.SettingsManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -74,7 +68,7 @@ public class EventFragment extends Fragment {
|
||||
|
||||
public void add_pit_scouting(frcEvent event){
|
||||
|
||||
if(settingsManager.getCustomEvents()){
|
||||
if(SettingsManager.getCustomEvents()){
|
||||
binding.teamsMinusBtn.setVisibility(View.VISIBLE);
|
||||
binding.teamsMinusBtn.setOnClickListener(view -> removeTeam());
|
||||
binding.teamsPlusBtn.setVisibility(View.VISIBLE);
|
||||
@@ -106,7 +100,7 @@ public class EventFragment extends Fragment {
|
||||
|
||||
text.setText(String.valueOf(num));
|
||||
final String filename = event.eventCode + "-" + num + ".pitscoutdata";
|
||||
if(fileEditor.fileExist(filename)){
|
||||
if(FileEditor.fileExist(filename)){
|
||||
final boolean[] rescout = {DataManager.rescout_list.contains(filename)};
|
||||
|
||||
text.setBackgroundColor(rescout[0] ? color_rescout : color_found);
|
||||
@@ -137,7 +131,7 @@ public class EventFragment extends Fragment {
|
||||
public void add_match_scouting(frcEvent event){
|
||||
|
||||
|
||||
if(settingsManager.getCustomEvents()){
|
||||
if(SettingsManager.getCustomEvents()){
|
||||
binding.matchesMinusBtn.setVisibility(View.VISIBLE);
|
||||
binding.matchesMinusBtn.setOnClickListener(view -> removeMatch());
|
||||
binding.matchesPlusBtn.setVisibility(View.VISIBLE);
|
||||
@@ -177,7 +171,7 @@ public class EventFragment extends Fragment {
|
||||
|
||||
text.setText(String.valueOf(team_num));
|
||||
final String filename = event.eventCode + "-" + match.matchIndex + "-" + alliance_position + "-" + team_num + ".matchscoutdata";
|
||||
if(fileEditor.fileExist(filename)){
|
||||
if(FileEditor.fileExist(filename)){
|
||||
final boolean[] rescout = {DataManager.rescout_list.contains(filename)};
|
||||
|
||||
text.setBackgroundColor(rescout[0] ? color_rescout : color_found);
|
||||
@@ -258,7 +252,7 @@ public class EventFragment extends Fragment {
|
||||
team.startingYear = safeToInt(startingYear.getText().toString());
|
||||
|
||||
event.teams.add(team);
|
||||
fileEditor.setEvent(event);
|
||||
FileEditor.setEvent(event);
|
||||
reloadTable();
|
||||
});
|
||||
|
||||
@@ -289,7 +283,7 @@ public class EventFragment extends Fragment {
|
||||
if(!(index >= 0 && index < teamNums.size())) return;
|
||||
|
||||
event.teams.remove(index);
|
||||
fileEditor.setEvent(event);
|
||||
FileEditor.setEvent(event);
|
||||
reloadTable();
|
||||
});
|
||||
|
||||
@@ -370,7 +364,7 @@ public class EventFragment extends Fragment {
|
||||
};
|
||||
|
||||
event.matches.add(match);
|
||||
fileEditor.setEvent(event);
|
||||
FileEditor.setEvent(event);
|
||||
reloadTable();
|
||||
});
|
||||
|
||||
@@ -400,7 +394,7 @@ public class EventFragment extends Fragment {
|
||||
builder.setPositiveButton("OK", (dialogInterface, i) -> {
|
||||
if(dropdown.getIndex() == -1) return;
|
||||
event.matches.remove(dropdown.getIndex());
|
||||
fileEditor.setEvent(event);
|
||||
FileEditor.setEvent(event);
|
||||
reloadTable();
|
||||
});
|
||||
|
||||
|
||||
+16
-17
@@ -16,18 +16,17 @@ import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.google.android.material.divider.MaterialDivider;
|
||||
import com.ridgebotics.ridgescout.ui.ToggleTitleView;
|
||||
import com.ridgebotics.ridgescout.ui.settings.settingsFragment;
|
||||
import com.ridgebotics.ridgescout.utility.settingsManager;
|
||||
import com.ridgebotics.ridgescout.utility.SettingsManager;
|
||||
import com.ridgebotics.ridgescout.databinding.FragmentScoutingMatchBinding;
|
||||
import com.ridgebotics.ridgescout.scoutingData.ScoutingDataWriter;
|
||||
import com.ridgebotics.ridgescout.types.data.dataType;
|
||||
import com.ridgebotics.ridgescout.types.data.DataType;
|
||||
import com.ridgebotics.ridgescout.types.frcMatch;
|
||||
import com.ridgebotics.ridgescout.types.frcTeam;
|
||||
import com.ridgebotics.ridgescout.types.input.inputType;
|
||||
import com.ridgebotics.ridgescout.types.input.FieldType;
|
||||
import com.ridgebotics.ridgescout.utility.AlertManager;
|
||||
import com.ridgebotics.ridgescout.utility.AutoSaveManager;
|
||||
import com.ridgebotics.ridgescout.utility.DataManager;
|
||||
import com.ridgebotics.ridgescout.utility.fileEditor;
|
||||
import com.ridgebotics.ridgescout.utility.FileEditor;
|
||||
|
||||
public class MatchScoutingFragment extends Fragment {
|
||||
|
||||
@@ -41,8 +40,8 @@ public class MatchScoutingFragment extends Fragment {
|
||||
|
||||
DataManager.reload_match_fields();
|
||||
|
||||
alliance_position = settingsManager.getAllyPos();
|
||||
username = settingsManager.getUsername();
|
||||
alliance_position = SettingsManager.getAllyPos();
|
||||
username = SettingsManager.getUsername();
|
||||
|
||||
binding.username.setText(username);
|
||||
binding.alliancePosText.setText(alliance_position);
|
||||
@@ -63,20 +62,20 @@ public class MatchScoutingFragment extends Fragment {
|
||||
|
||||
binding.nextButton.setOnClickListener(v -> {
|
||||
if(edited) save();
|
||||
settingsManager.setMatchNum(cur_match_num+1);
|
||||
SettingsManager.setMatchNum(cur_match_num+1);
|
||||
cur_match_num += 1;
|
||||
update_match_num();
|
||||
update_scouting_data();
|
||||
});
|
||||
|
||||
if(settingsManager.getEnableQuickAlliancePosChange())
|
||||
if(SettingsManager.getEnableQuickAlliancePosChange())
|
||||
binding.fileIndicator.setOnClickListener(v -> {
|
||||
// if(e.getAction() != MotionEvent.ACTION_MOVE) return true;
|
||||
// System.out.println(e.getAxisValue(0));
|
||||
if(edited) save();
|
||||
|
||||
alliance_position = incrementMatchPos(alliance_position);
|
||||
settingsManager.setAllyPos(alliance_position);
|
||||
SettingsManager.setAllyPos(alliance_position);
|
||||
binding.alliancePosText.setText(alliance_position);
|
||||
|
||||
update_match_num();
|
||||
@@ -86,7 +85,7 @@ public class MatchScoutingFragment extends Fragment {
|
||||
|
||||
binding.backButton.setOnClickListener(v -> {
|
||||
if(edited) save();
|
||||
settingsManager.setMatchNum(cur_match_num-1);
|
||||
SettingsManager.setMatchNum(cur_match_num-1);
|
||||
cur_match_num -= 1;
|
||||
update_match_num();
|
||||
update_scouting_data();
|
||||
@@ -96,11 +95,11 @@ public class MatchScoutingFragment extends Fragment {
|
||||
// if(edited) save();
|
||||
// });
|
||||
|
||||
cur_match_num = settingsManager.getMatchNum();
|
||||
cur_match_num = SettingsManager.getMatchNum();
|
||||
|
||||
if(cur_match_num >= event.matches.size()) {
|
||||
cur_match_num = 0;
|
||||
settingsManager.setMatchNum(0);
|
||||
SettingsManager.setMatchNum(0);
|
||||
}
|
||||
|
||||
update_match_num();
|
||||
@@ -300,7 +299,7 @@ public class MatchScoutingFragment extends Fragment {
|
||||
|
||||
binding.matchTeamCard.fromTeam(team);
|
||||
|
||||
boolean new_file = !fileEditor.fileExist(filename);
|
||||
boolean new_file = !FileEditor.fileExist(filename);
|
||||
|
||||
if(asm.isRunning){
|
||||
asm.stop();
|
||||
@@ -330,7 +329,7 @@ public class MatchScoutingFragment extends Fragment {
|
||||
|
||||
public void default_fields(){
|
||||
for(int i = 0; i < DataManager.match_latest_values.length; i++){
|
||||
inputType input = DataManager.match_latest_values[i];
|
||||
FieldType input = DataManager.match_latest_values[i];
|
||||
input.setViewValue(input.default_value);
|
||||
|
||||
titles[i].enable();
|
||||
@@ -342,7 +341,7 @@ public class MatchScoutingFragment extends Fragment {
|
||||
public void get_fields(){
|
||||
|
||||
ScoutingDataWriter.ParsedScoutingDataResult psdr = ScoutingDataWriter.load(filename, DataManager.match_values, DataManager.match_transferValues);
|
||||
dataType[] types = psdr.data.array;
|
||||
DataType[] types = psdr.data.array;
|
||||
|
||||
|
||||
for(int i = 0; i < DataManager.match_latest_values.length; i++){
|
||||
@@ -363,7 +362,7 @@ public class MatchScoutingFragment extends Fragment {
|
||||
|
||||
public void save_fields(){
|
||||
|
||||
dataType[] types = new dataType[DataManager.match_latest_values.length];
|
||||
DataType[] types = new DataType[DataManager.match_latest_values.length];
|
||||
|
||||
for(int i = 0; i < DataManager.match_latest_values.length; i++){
|
||||
types[i] = DataManager.match_latest_values[i].getViewValue();
|
||||
|
||||
@@ -9,7 +9,6 @@ import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
@@ -17,17 +16,16 @@ import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.google.android.material.divider.MaterialDivider;
|
||||
import com.ridgebotics.ridgescout.ui.ToggleTitleView;
|
||||
import com.ridgebotics.ridgescout.ui.settings.settingsFragment;
|
||||
import com.ridgebotics.ridgescout.utility.AlertManager;
|
||||
import com.ridgebotics.ridgescout.utility.settingsManager;
|
||||
import com.ridgebotics.ridgescout.utility.SettingsManager;
|
||||
import com.ridgebotics.ridgescout.databinding.FragmentScoutingPitBinding;
|
||||
import com.ridgebotics.ridgescout.scoutingData.ScoutingDataWriter;
|
||||
import com.ridgebotics.ridgescout.types.data.dataType;
|
||||
import com.ridgebotics.ridgescout.types.data.DataType;
|
||||
import com.ridgebotics.ridgescout.types.frcTeam;
|
||||
import com.ridgebotics.ridgescout.types.input.inputType;
|
||||
import com.ridgebotics.ridgescout.types.input.FieldType;
|
||||
import com.ridgebotics.ridgescout.utility.AutoSaveManager;
|
||||
import com.ridgebotics.ridgescout.utility.DataManager;
|
||||
import com.ridgebotics.ridgescout.utility.fileEditor;
|
||||
import com.ridgebotics.ridgescout.utility.FileEditor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.function.Function;
|
||||
@@ -47,7 +45,7 @@ public class PitScoutingFragment extends Fragment {
|
||||
|
||||
binding = FragmentScoutingPitBinding.inflate(inflater, container, false);
|
||||
|
||||
username = settingsManager.getUsername();
|
||||
username = SettingsManager.getUsername();
|
||||
DataManager.reload_pit_fields();
|
||||
|
||||
if(pit_latest_values == null) {
|
||||
@@ -75,13 +73,13 @@ public class PitScoutingFragment extends Fragment {
|
||||
|
||||
AutoSaveManager asm = new AutoSaveManager(this::save);
|
||||
|
||||
ArrayList<dataType> dataTypes;
|
||||
ArrayList<DataType> dataTypes;
|
||||
|
||||
public void save(){
|
||||
edited = false;
|
||||
enableRescoutButton();
|
||||
|
||||
dataType[] types = new dataType[pit_latest_values.length];
|
||||
DataType[] types = new DataType[pit_latest_values.length];
|
||||
|
||||
for(int i = 0; i < pit_latest_values.length; i++){
|
||||
types[i] = pit_latest_values[i].getViewValue();
|
||||
@@ -113,7 +111,7 @@ public class PitScoutingFragment extends Fragment {
|
||||
binding.pitFileIndicator.setVisibility(View.VISIBLE);
|
||||
binding.pitsTeamCard.setVisibility(View.VISIBLE);
|
||||
binding.pitBarTeamNum.setText(String.valueOf(team.teamNumber));
|
||||
binding.pitUsername.setText(settingsManager.getUsername());
|
||||
binding.pitUsername.setText(SettingsManager.getUsername());
|
||||
binding.pitsTeamCard.fromTeam(team);
|
||||
|
||||
filename = evcode + "-" + team.teamNumber + ".pitscoutdata";
|
||||
@@ -125,7 +123,7 @@ public class PitScoutingFragment extends Fragment {
|
||||
|
||||
create_fields();
|
||||
|
||||
if(!fileEditor.fileExist(filename)){
|
||||
if(!FileEditor.fileExist(filename)){
|
||||
default_fields();
|
||||
set_indicator_color(unsaved_color);
|
||||
disableRescoutButton();
|
||||
@@ -199,9 +197,9 @@ public class PitScoutingFragment extends Fragment {
|
||||
}
|
||||
});
|
||||
|
||||
View v = pit_latest_values[i].createView(getContext(), new Function<dataType, Integer>() {
|
||||
View v = pit_latest_values[i].createView(getContext(), new Function<DataType, Integer>() {
|
||||
@Override
|
||||
public Integer apply(dataType dataType) {
|
||||
public Integer apply(DataType dataType) {
|
||||
// edited = true;
|
||||
if(asm.isRunning)
|
||||
update_asm();
|
||||
@@ -215,7 +213,7 @@ public class PitScoutingFragment extends Fragment {
|
||||
|
||||
public void default_fields(){
|
||||
for(int i = 0; i < pit_latest_values.length; i++){
|
||||
inputType input = pit_latest_values[i];
|
||||
FieldType input = pit_latest_values[i];
|
||||
input.setViewValue(input.default_value);
|
||||
titles[i].enable();
|
||||
}
|
||||
@@ -224,7 +222,7 @@ public class PitScoutingFragment extends Fragment {
|
||||
public void get_fields(){
|
||||
|
||||
ScoutingDataWriter.ParsedScoutingDataResult psdr = ScoutingDataWriter.load(filename, pit_values, pit_transferValues);
|
||||
dataType[] types = psdr.data.array;
|
||||
DataType[] types = psdr.data.array;
|
||||
|
||||
for(int i = 0; i < pit_latest_values.length; i++){
|
||||
pit_latest_values[i].setViewValue(types[i]);
|
||||
|
||||
@@ -18,7 +18,7 @@ import com.ridgebotics.ridgescout.types.frcTeam;
|
||||
import com.ridgebotics.ridgescout.ui.TeamListOption;
|
||||
import com.ridgebotics.ridgescout.utility.AlertManager;
|
||||
import com.ridgebotics.ridgescout.utility.DataManager;
|
||||
import com.ridgebotics.ridgescout.utility.fileEditor;
|
||||
import com.ridgebotics.ridgescout.utility.FileEditor;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -106,7 +106,7 @@ public class PitSelectorFragment extends Fragment {
|
||||
|
||||
String filename = evcode + "-" + team.teamNumber + ".pitscoutdata";
|
||||
|
||||
if (fileEditor.fileExist(filename)) {
|
||||
if (FileEditor.fileExist(filename)) {
|
||||
final boolean[] rescout = {DataManager.rescout_list.contains(filename)};
|
||||
|
||||
teamRow.setColor(DataManager.rescout_list.contains(filename) ? 0x300000FF : 0x3000FF00);
|
||||
|
||||
@@ -21,11 +21,9 @@ import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.ridgebotics.ridgescout.R;
|
||||
import com.ridgebotics.ridgescout.types.frcEvent;
|
||||
import com.ridgebotics.ridgescout.utility.fileEditor;
|
||||
import com.ridgebotics.ridgescout.utility.settingsManager;
|
||||
import com.ridgebotics.ridgescout.utility.FileEditor;
|
||||
import com.ridgebotics.ridgescout.utility.SettingsManager;
|
||||
import com.ridgebotics.ridgescout.databinding.FragmentScoutingBinding;
|
||||
import com.ridgebotics.ridgescout.types.frcTeam;
|
||||
import com.ridgebotics.ridgescout.ui.TeamSelectorFragment;
|
||||
import com.ridgebotics.ridgescout.utility.DataManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -44,7 +42,7 @@ public class ScoutingFragment extends Fragment {
|
||||
|
||||
DataManager.reload_event();
|
||||
|
||||
if(settingsManager.getCustomEvents()){
|
||||
if(SettingsManager.getCustomEvents()){
|
||||
binding.eventAddButton.setVisibility(View.VISIBLE);
|
||||
binding.eventAddButton.setOnClickListener(view -> {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
||||
@@ -71,7 +69,7 @@ public class ScoutingFragment extends Fragment {
|
||||
event.teams = new ArrayList<>();
|
||||
event.matches = new ArrayList<>();
|
||||
|
||||
fileEditor.setEvent(event);
|
||||
FileEditor.setEvent(event);
|
||||
|
||||
|
||||
});
|
||||
|
||||
@@ -4,20 +4,25 @@ import static android.text.InputType.TYPE_CLASS_NUMBER;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TableLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.ridgebotics.ridgescout.types.input.checkboxType;
|
||||
import com.ridgebotics.ridgescout.types.input.dropdownType;
|
||||
import com.ridgebotics.ridgescout.types.input.fieldposType;
|
||||
import com.ridgebotics.ridgescout.types.input.inputType;
|
||||
import com.ridgebotics.ridgescout.types.input.numberType;
|
||||
import com.ridgebotics.ridgescout.types.input.sliderType;
|
||||
import com.ridgebotics.ridgescout.types.input.tallyType;
|
||||
import com.ridgebotics.ridgescout.types.input.textType;
|
||||
import com.ridgebotics.ridgescout.types.input.CheckboxType;
|
||||
import com.ridgebotics.ridgescout.types.input.DropdownType;
|
||||
import com.ridgebotics.ridgescout.types.input.FieldposType;
|
||||
import com.ridgebotics.ridgescout.types.input.FieldType;
|
||||
import com.ridgebotics.ridgescout.types.input.NumberType;
|
||||
import com.ridgebotics.ridgescout.types.input.SliderType;
|
||||
import com.ridgebotics.ridgescout.types.input.TallyType;
|
||||
import com.ridgebotics.ridgescout.types.input.TextType;
|
||||
import com.ridgebotics.ridgescout.utility.AlertManager;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.UUID;
|
||||
|
||||
public class FieldEditorHelper {
|
||||
private enum parameterTypeEnum {
|
||||
paramNumber,
|
||||
@@ -68,41 +73,49 @@ public class FieldEditorHelper {
|
||||
// }
|
||||
|
||||
public static final parameterType[] defaultSliderParams = new parameterType[]{
|
||||
new paramString("Name", "New Slider"),
|
||||
new paramString("Description", ""),
|
||||
new paramNumber("Min", 0),
|
||||
new paramNumber("Max", 10),
|
||||
new paramNumber("Default Value", 5)
|
||||
};
|
||||
public static final parameterType[] defaultDropdownParams = new parameterType[]{
|
||||
new paramString("Name", "New Dropdown"),
|
||||
new paramString("Description", ""),
|
||||
new paramStringArray("Default Value", new String[]{"Zero","One","Two","Three"}),
|
||||
new paramNumber("Default Option", 0),
|
||||
};
|
||||
public static final parameterType[] defaultTextParams = new parameterType[]{
|
||||
new paramString("Name", "New Text"),
|
||||
new paramString("Description", ""),
|
||||
new paramString("Default Value", "")
|
||||
};
|
||||
public static final parameterType[] defaultTallyParams = new parameterType[]{
|
||||
new paramString("Name", "New Tally"),
|
||||
new paramString("Description", ""),
|
||||
new paramNumber("Default Value", 0)
|
||||
};
|
||||
public static final parameterType[] defaultNumberParams = new parameterType[]{
|
||||
new paramString("Name", "New Number"),
|
||||
new paramString("Description", ""),
|
||||
new paramNumber("Default Value", 0)
|
||||
};
|
||||
public static final parameterType[] defaultCheckboxParam = new parameterType[]{
|
||||
new paramString("Name", "New Checkbox"),
|
||||
new paramString("Description", ""),
|
||||
new paramNumber("Default Value ( 1 or 0 )", 0)
|
||||
};
|
||||
public static final parameterType[] defaultFieldPosParam = new parameterType[]{
|
||||
new paramString("Name", "New Field Position"),
|
||||
new paramString("Description", ""),
|
||||
new paramNumber("Default X", 0),
|
||||
new paramNumber("Default Y", 0)
|
||||
};
|
||||
|
||||
|
||||
private static parameterType[] getSliderParams(sliderType s){
|
||||
private static parameterType[] getSliderParams(SliderType s){
|
||||
return new parameterType[]{
|
||||
new paramString("Name", s.name),
|
||||
new paramString("Description", s.description),
|
||||
new paramNumber("Min", s.min),
|
||||
new paramNumber("Max", s.max),
|
||||
@@ -110,44 +123,50 @@ public class FieldEditorHelper {
|
||||
};
|
||||
}
|
||||
|
||||
private static parameterType[] getDropdownParams(dropdownType s){
|
||||
private static parameterType[] getDropdownParams(DropdownType s){
|
||||
return new parameterType[]{
|
||||
new paramString("Name", s.name),
|
||||
new paramString("Description", s.description),
|
||||
new paramStringArray("Default Value",s.text_options),
|
||||
new paramNumber("Default Option", (int) s.default_value),
|
||||
};
|
||||
}
|
||||
|
||||
private static parameterType[] getTextParams(textType s){
|
||||
private static parameterType[] getTextParams(TextType s){
|
||||
return new parameterType[]{
|
||||
new paramString("Name", s.name),
|
||||
new paramString("Description", s.description),
|
||||
new paramString("Default Value", (String) s.default_value)
|
||||
};
|
||||
}
|
||||
|
||||
private static parameterType[] getTallyParams(tallyType s){
|
||||
private static parameterType[] getTallyParams(TallyType s){
|
||||
return new parameterType[]{
|
||||
new paramString("Name", s.name),
|
||||
new paramString("Description", s.description),
|
||||
new paramNumber("Default Value", (int) s.default_value)
|
||||
};
|
||||
}
|
||||
|
||||
private static parameterType[] getNumberParams(numberType s){
|
||||
private static parameterType[] getNumberParams(NumberType s){
|
||||
return new parameterType[]{
|
||||
new paramString("Name", s.name),
|
||||
new paramString("Description", s.description),
|
||||
new paramNumber("Default Value", (int) s.default_value)
|
||||
};
|
||||
}
|
||||
|
||||
private static parameterType[] getCheckboxParam(checkboxType s){
|
||||
private static parameterType[] getCheckboxParam(CheckboxType s){
|
||||
return new parameterType[]{
|
||||
new paramString("Name", s.name),
|
||||
new paramString("Description", s.description),
|
||||
new paramNumber("Default Value ( 1 or 0 )", (int) s.default_value)
|
||||
};
|
||||
}
|
||||
|
||||
private static parameterType[] getFieldPosParam(fieldposType s){
|
||||
private static parameterType[] getFieldPosParam(FieldposType s){
|
||||
return new parameterType[]{
|
||||
new paramString("Name", s.name),
|
||||
new paramString("Description", s.description),
|
||||
new paramNumber("Default X", ((int[]) s.default_value)[0]),
|
||||
new paramNumber("Default Y", ((int[]) s.default_value)[1])
|
||||
@@ -156,92 +175,99 @@ public class FieldEditorHelper {
|
||||
|
||||
|
||||
|
||||
public static void setSliderParams(sliderType s, parameterType[] types){
|
||||
s.description = ((paramString) types[0]).val;
|
||||
s.min = ((paramNumber) types[1]).val;
|
||||
s.max = ((paramNumber) types[2]).val;
|
||||
public static void setSliderParams(SliderType s, parameterType[] types){
|
||||
s.name = ((paramString) types[0]).val;
|
||||
s.description = ((paramString) types[1]).val;
|
||||
s.min = ((paramNumber) types[2]).val;
|
||||
s.max = ((paramNumber) types[3]).val;
|
||||
s.default_value = ((paramNumber) types[4]).val;
|
||||
}
|
||||
|
||||
public static void setDropdownParams(DropdownType s, parameterType[] types){
|
||||
s.name = ((paramString) types[0]).val;
|
||||
s.description = ((paramString) types[1]).val;
|
||||
s.text_options = ((paramStringArray) types[2]).val;
|
||||
s.default_value = ((paramNumber) types[3]).val;
|
||||
}
|
||||
|
||||
public static void setDropdownParams(dropdownType s, parameterType[] types){
|
||||
s.description = ((paramString) types[0]).val;
|
||||
s.text_options = ((paramStringArray) types[1]).val;
|
||||
public static void setTextParams(TextType s, parameterType[] types){
|
||||
s.name = ((paramString) types[0]).val;
|
||||
s.description = ((paramString) types[1]).val;
|
||||
s.default_value = ((paramString) types[2]).val;
|
||||
}
|
||||
|
||||
public static void setTallyParams(TallyType s, parameterType[] types){
|
||||
s.name = ((paramString) types[0]).val;
|
||||
s.description = ((paramString) types[1]).val;
|
||||
s.default_value = ((paramNumber) types[2]).val;
|
||||
}
|
||||
|
||||
public static void setTextParams(textType s, parameterType[] types){
|
||||
s.description = ((paramString) types[0]).val;
|
||||
s.default_value = ((paramString) types[1]).val;
|
||||
public static void setNumberParams(NumberType s, parameterType[] types){
|
||||
s.name = ((paramString) types[0]).val;
|
||||
s.description = ((paramString) types[1]).val;
|
||||
s.default_value = ((paramNumber) types[2]).val;
|
||||
}
|
||||
|
||||
public static void setTallyParams(tallyType s, parameterType[] types){
|
||||
s.description = ((paramString) types[0]).val;
|
||||
s.default_value = ((paramNumber) types[1]).val;
|
||||
public static void setCheckboxParam(CheckboxType s, parameterType[] types){
|
||||
s.name = ((paramString) types[0]).val;
|
||||
s.description = ((paramString) types[1]).val;
|
||||
s.default_value = ((paramNumber) types[2]).val;
|
||||
}
|
||||
|
||||
public static void setNumberParams(numberType s, parameterType[] types){
|
||||
s.description = ((paramString) types[0]).val;
|
||||
s.default_value = ((paramNumber) types[1]).val;
|
||||
}
|
||||
|
||||
public static void setCheckboxParam(checkboxType s, parameterType[] types){
|
||||
s.description = ((paramString) types[0]).val;
|
||||
s.default_value = ((paramNumber) types[1]).val;
|
||||
}
|
||||
|
||||
public static void setFieldPosParam(fieldposType s, parameterType[] types){
|
||||
s.description = ((paramString) types[0]).val;
|
||||
public static void setFieldPosParam(FieldposType s, parameterType[] types){
|
||||
s.name = ((paramString) types[0]).val;
|
||||
s.description = ((paramString) types[1]).val;
|
||||
s.default_value = new int[]{
|
||||
((paramNumber) types[1]).val,
|
||||
((paramNumber) types[2]).val
|
||||
((paramNumber) types[2]).val,
|
||||
((paramNumber) types[3]).val
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
private static void setInputParameter(inputType t, parameterType[] types){
|
||||
private static void setInputParameter(FieldType t, parameterType[] types){
|
||||
switch (t.getInputType()){
|
||||
case TALLY:
|
||||
setTallyParams((tallyType) t, types);
|
||||
setTallyParams((TallyType) t, types);
|
||||
break;
|
||||
case SLIDER:
|
||||
setSliderParams((sliderType) t, types);
|
||||
setSliderParams((SliderType) t, types);
|
||||
break;
|
||||
case DROPDOWN:
|
||||
setDropdownParams((dropdownType) t, types);
|
||||
setDropdownParams((DropdownType) t, types);
|
||||
break;
|
||||
case NOTES_INPUT:
|
||||
setTextParams((textType) t, types);
|
||||
setTextParams((TextType) t, types);
|
||||
break;
|
||||
case NUMBER:
|
||||
setNumberParams((numberType) t, types);
|
||||
setNumberParams((NumberType) t, types);
|
||||
break;
|
||||
case CHECKBOX:
|
||||
setCheckboxParam((checkboxType) t, types);
|
||||
setCheckboxParam((CheckboxType) t, types);
|
||||
break;
|
||||
case FIELDPOS:
|
||||
setFieldPosParam((fieldposType) t, types);
|
||||
setFieldPosParam((FieldposType) t, types);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static parameterType[] getParamsFromInputType(inputType t){
|
||||
private static parameterType[] getParamsFromInputType(FieldType t){
|
||||
switch (t.getInputType()){
|
||||
case TALLY:
|
||||
return getTallyParams((tallyType) t);
|
||||
return getTallyParams((TallyType) t);
|
||||
case SLIDER:
|
||||
return getSliderParams((sliderType) t);
|
||||
return getSliderParams((SliderType) t);
|
||||
case DROPDOWN:
|
||||
return getDropdownParams((dropdownType) t);
|
||||
return getDropdownParams((DropdownType) t);
|
||||
case NOTES_INPUT:
|
||||
return getTextParams((textType) t);
|
||||
return getTextParams((TextType) t);
|
||||
case NUMBER:
|
||||
return getNumberParams((numberType) t);
|
||||
return getNumberParams((NumberType) t);
|
||||
case CHECKBOX:
|
||||
return getCheckboxParam((checkboxType) t);
|
||||
return getCheckboxParam((CheckboxType) t);
|
||||
case FIELDPOS:
|
||||
return getFieldPosParam((fieldposType) t);
|
||||
return getFieldPosParam((FieldposType) t);
|
||||
}
|
||||
return new parameterType[]{};
|
||||
}
|
||||
@@ -252,18 +278,30 @@ public class FieldEditorHelper {
|
||||
EditText text = new EditText(c);
|
||||
text.setInputType(TYPE_CLASS_NUMBER);
|
||||
text.setText(String.valueOf(value));
|
||||
text.setLayoutParams(new LinearLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
));
|
||||
return text;
|
||||
}
|
||||
|
||||
private static View createStringEdit(Context c, String value){
|
||||
EditText text = new EditText(c);
|
||||
text.setText(value);
|
||||
text.setLayoutParams(new LinearLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
));
|
||||
return text;
|
||||
}
|
||||
|
||||
private static View createStringArrayEdit(Context c, String[] value){
|
||||
EditText text = new EditText(c);
|
||||
text.setText(String.join("\n", value));
|
||||
text.setLayoutParams(new LinearLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
));
|
||||
return text;
|
||||
}
|
||||
|
||||
@@ -308,11 +346,52 @@ public class FieldEditorHelper {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static FieldType createNewFieldType(int n){
|
||||
switch(n){
|
||||
case 0:
|
||||
SliderType slider = new SliderType();
|
||||
slider.UUID = UUID.randomUUID().toString();
|
||||
setSliderParams(slider, defaultSliderParams);
|
||||
return slider;
|
||||
case 1:
|
||||
TextType textType = new TextType();
|
||||
textType.UUID = UUID.randomUUID().toString();
|
||||
setTextParams(textType, defaultTextParams);
|
||||
return textType;
|
||||
case 2:
|
||||
DropdownType dropdownType = new DropdownType();
|
||||
dropdownType.UUID = UUID.randomUUID().toString();
|
||||
setDropdownParams(dropdownType, defaultDropdownParams);
|
||||
return dropdownType;
|
||||
case 3:
|
||||
TallyType tallyType = new TallyType();
|
||||
tallyType.UUID = UUID.randomUUID().toString();
|
||||
setTallyParams(tallyType, defaultTallyParams);
|
||||
return tallyType;
|
||||
case 4:
|
||||
NumberType numberType = new NumberType();
|
||||
numberType.UUID = UUID.randomUUID().toString();
|
||||
setNumberParams(numberType, defaultNumberParams);
|
||||
return numberType;
|
||||
case 5:
|
||||
CheckboxType checkboxType = new CheckboxType();
|
||||
checkboxType.UUID = UUID.randomUUID().toString();
|
||||
setCheckboxParam(checkboxType, defaultCheckboxParam);
|
||||
return checkboxType;
|
||||
case 6:
|
||||
FieldposType fieldposType = new FieldposType();
|
||||
fieldposType.UUID = UUID.randomUUID().toString();
|
||||
setFieldPosParam(fieldposType, defaultFieldPosParam);
|
||||
return fieldposType;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private parameterType[] types;
|
||||
private View[] views;
|
||||
private inputType t;
|
||||
public FieldEditorHelper(Context c, inputType t, TableLayout parentView, parameterType[] tmptypes){
|
||||
private FieldType t;
|
||||
public FieldEditorHelper(Context c, FieldType t, TableLayout parentView, parameterType[] tmptypes){
|
||||
this.types = tmptypes;
|
||||
this.t = t;
|
||||
views = new View[types.length];
|
||||
@@ -327,7 +406,7 @@ public class FieldEditorHelper {
|
||||
parentView.addView(views[i]);
|
||||
}
|
||||
}
|
||||
public FieldEditorHelper(Context c, inputType t, TableLayout parentView){
|
||||
public FieldEditorHelper(Context c, FieldType t, TableLayout parentView){
|
||||
this(c,t,parentView,getParamsFromInputType(t));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
package com.ridgebotics.ridgescout.ui.settings;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import static com.ridgebotics.ridgescout.utility.DataManager.match_values;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.text.InputType;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.EditText;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TableLayout;
|
||||
import android.widget.TableRow;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -23,26 +23,15 @@ import androidx.navigation.Navigation;
|
||||
import com.ridgebotics.ridgescout.MainActivity;
|
||||
import com.ridgebotics.ridgescout.R;
|
||||
import com.ridgebotics.ridgescout.databinding.FragmentSettingsFieldsBinding;
|
||||
import com.ridgebotics.ridgescout.scoutingData.fields;
|
||||
import com.ridgebotics.ridgescout.types.data.dataType;
|
||||
import com.ridgebotics.ridgescout.types.input.checkboxType;
|
||||
import com.ridgebotics.ridgescout.types.input.dropdownType;
|
||||
import com.ridgebotics.ridgescout.types.input.fieldposType;
|
||||
import com.ridgebotics.ridgescout.types.input.inputType;
|
||||
import com.ridgebotics.ridgescout.types.input.numberType;
|
||||
import com.ridgebotics.ridgescout.types.input.sliderType;
|
||||
import com.ridgebotics.ridgescout.types.input.tallyType;
|
||||
import com.ridgebotics.ridgescout.types.input.textType;
|
||||
import com.ridgebotics.ridgescout.scoutingData.Fields;
|
||||
import com.ridgebotics.ridgescout.types.input.FieldType;
|
||||
import com.ridgebotics.ridgescout.ui.CustomSpinnerView;
|
||||
import com.ridgebotics.ridgescout.ui.FieldDisplay;
|
||||
import com.ridgebotics.ridgescout.utility.AlertManager;
|
||||
import com.ridgebotics.ridgescout.utility.DataManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class FieldsFragment extends Fragment {
|
||||
FragmentSettingsFieldsBinding binding;
|
||||
@@ -54,7 +43,9 @@ public class FieldsFragment extends Fragment {
|
||||
|
||||
private int index = -1;
|
||||
|
||||
List<inputType> values;
|
||||
private boolean edited = false;
|
||||
|
||||
List<FieldType> values;
|
||||
List<FieldDisplay> views;
|
||||
|
||||
|
||||
@@ -68,38 +59,19 @@ public class FieldsFragment extends Fragment {
|
||||
|
||||
binding.upButton.setEnabled(false);
|
||||
binding.downButton.setEnabled(false);
|
||||
binding.saveButton.setEnabled(false);
|
||||
|
||||
inputType[][] tmp_values = fields.load(filename);
|
||||
FieldType[][] tmp_values = Fields.load(filename);
|
||||
if(tmp_values == null || tmp_values.length == 0) return binding.getRoot();
|
||||
|
||||
values = new ArrayList(List.of(tmp_values[tmp_values.length-1]));
|
||||
views = new ArrayList<>();
|
||||
|
||||
for(int i = 0; i < values.size(); i++){
|
||||
final FieldDisplay fd = new FieldDisplay(getContext());
|
||||
views.add(fd);
|
||||
|
||||
fd.setInputType(values.get(i));
|
||||
fd.setColor(unfocused_background_color);
|
||||
|
||||
final int fi = i;
|
||||
fd.setOnClickListener(v -> {
|
||||
index = views.indexOf(fd);
|
||||
for(int a = 0; a < values.size(); a++) {
|
||||
views.get(a).setColor(unfocused_background_color);
|
||||
views.get(a).hideButtons();
|
||||
}
|
||||
fd.setColor(background_color);
|
||||
fd.showButtons();
|
||||
|
||||
binding.upButton.setEnabled(index > 0);
|
||||
binding.downButton.setEnabled(index < views.size()-1);
|
||||
});
|
||||
|
||||
|
||||
binding.fieldsArea.addView(fd);
|
||||
createFieldDisplay(values.get(i));
|
||||
}
|
||||
|
||||
// Up and down buttons
|
||||
binding.upButton.setOnClickListener(v -> {
|
||||
if(index <= 0) return;
|
||||
Collections.swap(values, index, index-1);
|
||||
@@ -115,19 +87,198 @@ public class FieldsFragment extends Fragment {
|
||||
updateRowOrder();
|
||||
});
|
||||
|
||||
// Add Field button
|
||||
binding.addButton.setOnClickListener(v -> {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
||||
builder.setTitle("Select Type");
|
||||
|
||||
final CustomSpinnerView dropdown = new CustomSpinnerView(getContext());
|
||||
List<String> options = new ArrayList<>();
|
||||
|
||||
options.add("Slider");
|
||||
options.add("Text");
|
||||
options.add("Dropdown");
|
||||
options.add("Tally");
|
||||
options.add("Number");
|
||||
options.add("Checkbox");
|
||||
options.add("Field Position");
|
||||
|
||||
dropdown.setOptions(options, 0);
|
||||
dropdown.setTitle("Type");
|
||||
|
||||
builder.setView(dropdown);
|
||||
|
||||
builder.setNegativeButton("Cancel", (dialog, which) -> dialog.cancel());
|
||||
builder.setPositiveButton("OK", (dialog, which) -> addField(dropdown.getIndex()));
|
||||
|
||||
builder.show();
|
||||
});
|
||||
|
||||
// Back button listener
|
||||
((MainActivity) getActivity()).setOnBackPressed(() -> {
|
||||
if(!edited) return true;
|
||||
|
||||
AlertDialog.Builder alert = new AlertDialog.Builder(getContext());
|
||||
alert.setTitle("Warning!");
|
||||
alert.setMessage("You have not saved your progress!");
|
||||
alert.setPositiveButton("Return", null);
|
||||
alert.setNeutralButton("Quit without saving", (dialogInterface, i) -> {
|
||||
edited = false;
|
||||
if(getActivity() != null)
|
||||
getActivity().onBackPressed();
|
||||
});
|
||||
alert.setCancelable(true);
|
||||
|
||||
alert.create().show();
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
binding.saveButton.setOnClickListener(l -> save());
|
||||
|
||||
return binding.getRoot();
|
||||
}
|
||||
|
||||
private void createFieldDisplay(FieldType field){
|
||||
final FieldDisplay fd = new FieldDisplay(getContext());
|
||||
views.add(fd);
|
||||
|
||||
fd.setInputType(field);
|
||||
fd.setColor(unfocused_background_color);
|
||||
fd.setOnClickListener(v -> setFocus(fd,false));
|
||||
fd.editButton.setOnClickListener(v -> openEditor(fd));
|
||||
|
||||
binding.fieldsArea.addView(fd);
|
||||
}
|
||||
private void updateRowOrder(){
|
||||
binding.fieldsArea.removeAllViews();
|
||||
for(int i = 0; i < views.size(); i++){
|
||||
binding.fieldsArea.addView(views.get(i));
|
||||
}
|
||||
|
||||
binding.upButton.setEnabled(index > 0);
|
||||
binding.downButton.setEnabled(index < views.size()-1);
|
||||
binding.upButton.setEnabled(index != -1 && index > 0);
|
||||
binding.downButton.setEnabled(index != -1 && index < views.size()-1);
|
||||
enableEditing();
|
||||
}
|
||||
|
||||
private void setFocus(FieldDisplay fd, boolean scroll){
|
||||
index = views.indexOf(fd);
|
||||
for(int a = 0; a < values.size(); a++) {
|
||||
views.get(a).setColor(unfocused_background_color);
|
||||
views.get(a).hideButtons();
|
||||
}
|
||||
fd.setColor(background_color);
|
||||
fd.showButtons();
|
||||
|
||||
binding.upButton.setEnabled(index != -1 && index > 0);
|
||||
binding.downButton.setEnabled(index != -1 && index < views.size()-1);
|
||||
if(scroll)
|
||||
binding.scrollView.post(() -> binding.scrollView.scrollTo(0, fd.getTop()));
|
||||
}
|
||||
|
||||
private void openEditor(FieldDisplay fd){
|
||||
FieldType field = fd.getField();
|
||||
|
||||
ScrollView sv = new ScrollView(getContext());
|
||||
TableLayout table = new TableLayout(getContext());
|
||||
table.setStretchAllColumns(true);
|
||||
table.setPadding(10, 10, 10, 10);
|
||||
|
||||
sv.addView(table);
|
||||
|
||||
TextView UUID = new TextView(getContext());
|
||||
UUID.setText("Type: " + field.get_type_name() + "\nUUID: " + field.UUID);
|
||||
|
||||
table.addView(UUID);
|
||||
|
||||
FieldEditorHelper f = new FieldEditorHelper(getContext(), field, table);
|
||||
|
||||
AlertDialog.Builder alert = new AlertDialog.Builder(getContext());
|
||||
alert.setTitle("Edit " + field.name);
|
||||
alert.setView(sv);
|
||||
alert.setCancelable(false);
|
||||
alert.setNeutralButton("Cancel", (dialogInterface, i) -> {});
|
||||
alert.setPositiveButton("Save", (dialogInterface, i) -> {
|
||||
f.save();
|
||||
fd.setInputType(field);
|
||||
enableEditing();
|
||||
});
|
||||
|
||||
AlertDialog dialog = alert.create();
|
||||
dialog.show();
|
||||
|
||||
Button deleteButton = new Button(getContext());
|
||||
deleteButton.setText("DELETE");
|
||||
deleteButton.setOnClickListener(l -> {
|
||||
AlertDialog.Builder alert2 = new AlertDialog.Builder(getContext());
|
||||
alert2.setTitle("Warning!");
|
||||
alert2.setMessage("This may destroy any data after being saved!");
|
||||
alert2.setPositiveButton("Return", (dialogInterface, i) -> {});
|
||||
alert2.setNeutralButton("DELETE", (dialogInterface, i) -> {
|
||||
removeField(field);
|
||||
dialog.cancel();
|
||||
});
|
||||
|
||||
alert2.setCancelable(true);
|
||||
alert2.create().show();
|
||||
});
|
||||
|
||||
table.addView(deleteButton);
|
||||
}
|
||||
|
||||
private void enableEditing(){
|
||||
edited = true;
|
||||
binding.saveButton.setEnabled(true);
|
||||
}
|
||||
|
||||
private void addField(int n){
|
||||
FieldType field = FieldEditorHelper.createNewFieldType(n);
|
||||
|
||||
values.add(field);
|
||||
createFieldDisplay(field);
|
||||
setFocus(views.get(views.size()-1), true);
|
||||
}
|
||||
|
||||
private void removeField(FieldType field){
|
||||
int fieldIndex = values.indexOf(field);
|
||||
|
||||
views.remove(fieldIndex);
|
||||
values.remove(fieldIndex);
|
||||
|
||||
index = -1;
|
||||
|
||||
updateRowOrder();
|
||||
}
|
||||
|
||||
private void save(){
|
||||
AlertDialog.Builder alert = new AlertDialog.Builder(getContext());
|
||||
alert.setTitle("Warning!");
|
||||
alert.setMessage("Changing or removing some values will result in lost data!\nBut this will create a new field version, and you can revert at any time.");
|
||||
alert.setPositiveButton("OK", (dialog, which) -> {
|
||||
FieldType[][] currentValues = Fields.load(filename);
|
||||
assert currentValues != null;
|
||||
FieldType[][] newValues = new FieldType[currentValues.length][];
|
||||
newValues[newValues.length-1] = new FieldType[values.size()];
|
||||
|
||||
for(int i = 0; i < currentValues.length; i++) {
|
||||
newValues[i] = currentValues[i];
|
||||
}
|
||||
|
||||
for(int i = 0; i < values.size(); i++) {
|
||||
newValues[newValues.length - 1][i] = values.get(i);
|
||||
}
|
||||
|
||||
if(Fields.save(filename, newValues))
|
||||
AlertManager.toast("Saved");
|
||||
|
||||
Navigation.findNavController((Activity) getContext(), R.id.nav_host_fragment_activity_main).navigate(R.id.action_navigation_data_fields_to_navigation_settings);
|
||||
});
|
||||
alert.setNegativeButton("Cancel", null);
|
||||
alert.setCancelable(true);
|
||||
alert.create().show();
|
||||
}
|
||||
|
||||
|
||||
// @SuppressLint("ClickableViewAccessibility")
|
||||
// public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
||||
// @Nullable Bundle savedInstanceState) {
|
||||
@@ -523,7 +674,7 @@ public class FieldsFragment extends Fragment {
|
||||
// private void addField_Part_3(String title, int typeIndex) {
|
||||
// switch (typeIndex){
|
||||
// case 0:
|
||||
// sliderType slider = new sliderType();
|
||||
// SliderType slider = new SliderType();
|
||||
// slider.name = title;
|
||||
// FieldEditorHelper.setSliderParams(slider, FieldEditorHelper.defaultSliderParams);
|
||||
// addField_Part_4(slider);
|
||||
|
||||
+21
-25
@@ -2,18 +2,18 @@ package com.ridgebotics.ridgescout.ui.settings;
|
||||
|
||||
import static android.view.View.VISIBLE;
|
||||
import static androidx.navigation.fragment.FragmentKt.findNavController;
|
||||
import static com.ridgebotics.ridgescout.utility.settingsManager.AllyPosKey;
|
||||
import static com.ridgebotics.ridgescout.utility.settingsManager.CustomEventsKey;
|
||||
import static com.ridgebotics.ridgescout.utility.settingsManager.EnableQuickAllianceChangeKey;
|
||||
import static com.ridgebotics.ridgescout.utility.settingsManager.MatchNumKey;
|
||||
import static com.ridgebotics.ridgescout.utility.settingsManager.SelEVCodeKey;
|
||||
import static com.ridgebotics.ridgescout.utility.settingsManager.TeamNumKey;
|
||||
import static com.ridgebotics.ridgescout.utility.settingsManager.UnameKey;
|
||||
import static com.ridgebotics.ridgescout.utility.settingsManager.WifiModeKey;
|
||||
import static com.ridgebotics.ridgescout.utility.settingsManager.YearNumKey;
|
||||
import static com.ridgebotics.ridgescout.utility.settingsManager.defaults;
|
||||
import static com.ridgebotics.ridgescout.utility.settingsManager.getEditor;
|
||||
import static com.ridgebotics.ridgescout.utility.settingsManager.prefs;
|
||||
import static com.ridgebotics.ridgescout.utility.SettingsManager.AllyPosKey;
|
||||
import static com.ridgebotics.ridgescout.utility.SettingsManager.CustomEventsKey;
|
||||
import static com.ridgebotics.ridgescout.utility.SettingsManager.EnableQuickAllianceChangeKey;
|
||||
import static com.ridgebotics.ridgescout.utility.SettingsManager.MatchNumKey;
|
||||
import static com.ridgebotics.ridgescout.utility.SettingsManager.SelEVCodeKey;
|
||||
import static com.ridgebotics.ridgescout.utility.SettingsManager.TeamNumKey;
|
||||
import static com.ridgebotics.ridgescout.utility.SettingsManager.UnameKey;
|
||||
import static com.ridgebotics.ridgescout.utility.SettingsManager.WifiModeKey;
|
||||
import static com.ridgebotics.ridgescout.utility.SettingsManager.YearNumKey;
|
||||
import static com.ridgebotics.ridgescout.utility.SettingsManager.defaults;
|
||||
import static com.ridgebotics.ridgescout.utility.SettingsManager.getEditor;
|
||||
import static com.ridgebotics.ridgescout.utility.SettingsManager.prefs;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
@@ -25,26 +25,22 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TableLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.google.android.material.card.MaterialCardView;
|
||||
import com.google.android.material.checkbox.MaterialCheckBox;
|
||||
import com.google.android.material.textfield.TextInputEditText;
|
||||
import com.google.android.material.textfield.TextInputLayout;
|
||||
import com.ridgebotics.ridgescout.R;
|
||||
import com.ridgebotics.ridgescout.databinding.FragmentSettingsBinding;
|
||||
import com.ridgebotics.ridgescout.scoutingData.fields;
|
||||
import com.ridgebotics.ridgescout.ui.CustomSpinnerPopup;
|
||||
import com.ridgebotics.ridgescout.scoutingData.Fields;
|
||||
import com.ridgebotics.ridgescout.ui.CustomSpinnerView;
|
||||
import com.ridgebotics.ridgescout.ui.scouting.TallyCounterView;
|
||||
import com.ridgebotics.ridgescout.utility.DataManager;
|
||||
import com.ridgebotics.ridgescout.utility.fileEditor;
|
||||
import com.ridgebotics.ridgescout.utility.settingsManager;
|
||||
import com.ridgebotics.ridgescout.utility.FileEditor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -52,7 +48,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class settingsFragment extends Fragment {
|
||||
public class SettingsFragment extends Fragment {
|
||||
private FragmentSettingsBinding binding;
|
||||
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
@@ -69,12 +65,12 @@ public class settingsFragment extends Fragment {
|
||||
});
|
||||
|
||||
binding.fieldsMatchesButton.setOnClickListener(v -> {
|
||||
FieldsFragment.set_filename(fields.matchFieldsFilename);
|
||||
FieldsFragment.set_filename(Fields.matchFieldsFilename);
|
||||
findNavController(this).navigate(R.id.action_navigation_settings_to_navigation_data_fields);
|
||||
});
|
||||
|
||||
binding.fieldsPitsButton.setOnClickListener(v -> {
|
||||
FieldsFragment.set_filename(fields.pitsFieldsFilename);
|
||||
FieldsFragment.set_filename(Fields.pitsFieldsFilename);
|
||||
findNavController(this).navigate(R.id.action_navigation_settings_to_navigation_data_fields);
|
||||
});
|
||||
|
||||
@@ -91,11 +87,11 @@ public class settingsFragment extends Fragment {
|
||||
|
||||
manager.addItem(new CheckboxSettingsItem(CustomEventsKey, "Custom Events"));
|
||||
|
||||
StringSettingsItem FTPServer = new StringSettingsItem(settingsManager.FTPServer, "FTP Server (Sync)");
|
||||
StringSettingsItem FTPServer = new StringSettingsItem(com.ridgebotics.ridgescout.utility.SettingsManager.FTPServer, "FTP Server (Sync)");
|
||||
manager.addItem(FTPServer);
|
||||
CheckboxSettingsItem FTPSendMetaFiles = new CheckboxSettingsItem(settingsManager.FTPSendMetaFiles, "Sync meta files");
|
||||
CheckboxSettingsItem FTPSendMetaFiles = new CheckboxSettingsItem(com.ridgebotics.ridgescout.utility.SettingsManager.FTPSendMetaFiles, "Sync meta files");
|
||||
manager.addItem(FTPSendMetaFiles);
|
||||
CheckboxSettingsItem FTPEnabled = new CheckboxSettingsItem(settingsManager.FTPEnabled, "FTP Enabled", FTPServer, FTPSendMetaFiles);
|
||||
CheckboxSettingsItem FTPEnabled = new CheckboxSettingsItem(com.ridgebotics.ridgescout.utility.SettingsManager.FTPEnabled, "FTP Enabled", FTPServer, FTPSendMetaFiles);
|
||||
manager.addItem(FTPEnabled);
|
||||
|
||||
manager.addItem(new CheckboxSettingsItem(WifiModeKey, "Wifi Mode", FTPEnabled));
|
||||
@@ -116,7 +112,7 @@ public class settingsFragment extends Fragment {
|
||||
matchNum.setEnabled(hasEvent);
|
||||
manager.addItem(matchNum);
|
||||
|
||||
DropdownSettingsItem eventCode = new DropdownSettingsItem(SelEVCodeKey, "Event Code", fileEditor.getEventList().toArray(new String[0]));
|
||||
DropdownSettingsItem eventCode = new DropdownSettingsItem(SelEVCodeKey, "Event Code", FileEditor.getEventList().toArray(new String[0]));
|
||||
eventCode.reloadOnChange(true);
|
||||
manager.addItem(eventCode);
|
||||
|
||||
@@ -9,12 +9,12 @@ import static com.ridgebotics.ridgescout.utility.SharePrompt.shareContent;
|
||||
import android.content.Context;
|
||||
|
||||
import com.ridgebotics.ridgescout.scoutingData.ScoutingDataWriter;
|
||||
import com.ridgebotics.ridgescout.types.data.dataType;
|
||||
import com.ridgebotics.ridgescout.types.data.DataType;
|
||||
import com.ridgebotics.ridgescout.types.frcMatch;
|
||||
import com.ridgebotics.ridgescout.types.frcTeam;
|
||||
import com.ridgebotics.ridgescout.types.input.inputType;
|
||||
import com.ridgebotics.ridgescout.types.input.FieldType;
|
||||
import com.ridgebotics.ridgescout.utility.DataManager;
|
||||
import com.ridgebotics.ridgescout.utility.fileEditor;
|
||||
import com.ridgebotics.ridgescout.utility.FileEditor;
|
||||
|
||||
public class CSVExport {
|
||||
private static String[] alliances = {"red", "blue"};
|
||||
@@ -56,14 +56,14 @@ public class CSVExport {
|
||||
data += (teamNum + ",");
|
||||
|
||||
String filename = evcode+"-"+matchNum+"-"+alliance+"-"+alliancePos+"-"+teamNum+".matchscoutdata";
|
||||
if(!fileEditor.fileExist(filename)){
|
||||
if(!FileEditor.fileExist(filename)){
|
||||
data += ("null,".repeat(match_latest_values.length));
|
||||
}else{
|
||||
try {
|
||||
String tempData = "";
|
||||
ScoutingDataWriter.ParsedScoutingDataResult psdr = ScoutingDataWriter.load(filename, DataManager.match_values, DataManager.match_transferValues);
|
||||
dataType[] matchData = psdr.data.array;
|
||||
inputType[] types = psdr.data.values[psdr.data.values.length-1];
|
||||
DataType[] matchData = psdr.data.array;
|
||||
FieldType[] types = psdr.data.values[psdr.data.values.length-1];
|
||||
for (int i = 0; i < types.length; i++) {
|
||||
tempData += (safeCSV(types[i].toString(matchData[i])) + ",");
|
||||
}
|
||||
@@ -108,14 +108,14 @@ public class CSVExport {
|
||||
data += (team.startingYear + ",");
|
||||
|
||||
String filename = evcode+"-"+team.teamNumber+".pitscoutdata";
|
||||
if(!fileEditor.fileExist(filename)){
|
||||
if(!FileEditor.fileExist(filename)){
|
||||
data += ("null,".repeat(pit_latest_values.length));
|
||||
}else{
|
||||
try {
|
||||
String tempData = "";
|
||||
ScoutingDataWriter.ParsedScoutingDataResult psdr = ScoutingDataWriter.load(filename, DataManager.pit_values, DataManager.pit_transferValues);
|
||||
dataType[] teamData = psdr.data.array;
|
||||
inputType[] types = psdr.data.values[psdr.data.values.length-1];
|
||||
DataType[] teamData = psdr.data.array;
|
||||
FieldType[] types = psdr.data.values[psdr.data.values.length-1];
|
||||
for (int i = 0; i < types.length; i++) {
|
||||
tempData += (safeCSV(types[i].toString(teamData[i])) + ",");
|
||||
}
|
||||
|
||||
@@ -2,13 +2,13 @@ package com.ridgebotics.ridgescout.ui.transfer;
|
||||
|
||||
//import static com.ridgebotics.ridgescout.utility.DataManager.evcode;
|
||||
import static com.ridgebotics.ridgescout.utility.DataManager.evcode;
|
||||
import static com.ridgebotics.ridgescout.utility.fileEditor.baseDir;
|
||||
import static com.ridgebotics.ridgescout.utility.FileEditor.baseDir;
|
||||
|
||||
import com.ridgebotics.ridgescout.utility.AlertManager;
|
||||
import com.ridgebotics.ridgescout.utility.BuiltByteParser;
|
||||
import com.ridgebotics.ridgescout.utility.ByteBuilder;
|
||||
import com.ridgebotics.ridgescout.utility.fileEditor;
|
||||
import com.ridgebotics.ridgescout.utility.settingsManager;
|
||||
import com.ridgebotics.ridgescout.utility.FileEditor;
|
||||
import com.ridgebotics.ridgescout.utility.SettingsManager;
|
||||
|
||||
import org.apache.commons.net.ftp.FTP;
|
||||
import org.apache.commons.net.ftp.FTPClient;
|
||||
@@ -116,7 +116,7 @@ public class FTPSync extends Thread {
|
||||
|
||||
public void run() {
|
||||
isRunning = true;
|
||||
boolean sendMetaFiles = settingsManager.getFTPSendMetaFiles();
|
||||
boolean sendMetaFiles = SettingsManager.getFTPSendMetaFiles();
|
||||
|
||||
// Meta files
|
||||
List<String> meta_string_array = Arrays.asList(
|
||||
@@ -128,7 +128,7 @@ public class FTPSync extends Thread {
|
||||
try {
|
||||
// Login to FTP
|
||||
ftpClient = new FTPClient();
|
||||
InetAddress address = InetAddress.getByName(settingsManager.getFTPServer());
|
||||
InetAddress address = InetAddress.getByName(SettingsManager.getFTPServer());
|
||||
ftpClient.connect(address);
|
||||
ftpClient.login("anonymous", null);
|
||||
ftpClient.enterLocalPassiveMode();
|
||||
@@ -229,7 +229,7 @@ public class FTPSync extends Thread {
|
||||
bb.addLong(timestamps.get(filenames[i]).getTime());
|
||||
}
|
||||
|
||||
fileEditor.writeFile(timestampsFilename, bb.build());
|
||||
FileEditor.writeFile(timestampsFilename, bb.build());
|
||||
|
||||
uploadFile(new File(baseDir + timestampsFilename));
|
||||
return true;
|
||||
@@ -243,7 +243,7 @@ public class FTPSync extends Thread {
|
||||
try {
|
||||
downloadFile(timestampsFilename, new File(baseDir + timestampsFilename));
|
||||
|
||||
byte[] data = fileEditor.readFile(timestampsFilename);
|
||||
byte[] data = FileEditor.readFile(timestampsFilename);
|
||||
|
||||
if(data == null || data.length == 0)
|
||||
return new HashMap<>();
|
||||
|
||||
@@ -6,13 +6,13 @@ import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
|
||||
import com.ridgebotics.ridgescout.MainActivity;
|
||||
import com.ridgebotics.ridgescout.types.file;
|
||||
import com.ridgebotics.ridgescout.types.ScoutingFile;
|
||||
import com.ridgebotics.ridgescout.utility.AlertManager;
|
||||
import com.ridgebotics.ridgescout.utility.BuiltByteParser;
|
||||
import com.ridgebotics.ridgescout.utility.ByteBuilder;
|
||||
import com.ridgebotics.ridgescout.utility.DataManager;
|
||||
import com.ridgebotics.ridgescout.utility.SharePrompt;
|
||||
import com.ridgebotics.ridgescout.utility.fileEditor;
|
||||
import com.ridgebotics.ridgescout.utility.FileEditor;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
@@ -28,10 +28,10 @@ public class FileBundle {
|
||||
ByteBuilder b = new ByteBuilder();
|
||||
|
||||
for(int i = 0; i < files.length; i++){
|
||||
if(!fileEditor.fileExist(files[i])) continue;
|
||||
if(!FileEditor.fileExist(files[i])) continue;
|
||||
// byte[] data = fileEditor.readFile(files[i]);
|
||||
file f = new file(files[i]);
|
||||
b.addRaw(file.typecode, f.encode());
|
||||
ScoutingFile f = new ScoutingFile(files[i]);
|
||||
b.addRaw(ScoutingFile.typecode, f.encode());
|
||||
}
|
||||
|
||||
byte[] data = b.build();
|
||||
@@ -91,11 +91,11 @@ public class FileBundle {
|
||||
|
||||
for(int i = 0; i < parsedObjectList.size(); i++){
|
||||
BuiltByteParser.parsedObject pa = parsedObjectList.get(i);
|
||||
if(pa.getType() != file.typecode) continue;
|
||||
file f = file.decode((byte[]) pa.get());
|
||||
if(pa.getType() != ScoutingFile.typecode) continue;
|
||||
ScoutingFile f = ScoutingFile.decode((byte[]) pa.get());
|
||||
if(f == null) continue;
|
||||
filenames.add(f.filename);
|
||||
fileEditor.writeFile(f.filename, f.data);
|
||||
FileEditor.writeFile(f.filename, f.data);
|
||||
}
|
||||
|
||||
AlertManager.alert("Saved",
|
||||
|
||||
@@ -17,11 +17,11 @@ import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.ridgebotics.ridgescout.databinding.FragmentTransferFileSelectorBinding;
|
||||
import com.ridgebotics.ridgescout.types.file;
|
||||
import com.ridgebotics.ridgescout.types.ScoutingFile;
|
||||
import com.ridgebotics.ridgescout.utility.AlertManager;
|
||||
import com.ridgebotics.ridgescout.utility.ByteBuilder;
|
||||
import com.ridgebotics.ridgescout.utility.DataManager;
|
||||
import com.ridgebotics.ridgescout.utility.fileEditor;
|
||||
import com.ridgebotics.ridgescout.utility.FileEditor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -51,7 +51,7 @@ public class FileSelectorFragment extends Fragment {
|
||||
evcode+".eventdata"
|
||||
};
|
||||
|
||||
String[] files = fileEditor.getEventFiles(evcode);
|
||||
String[] files = FileEditor.getEventFiles(evcode);
|
||||
|
||||
Boolean[] selected_arr = new Boolean[files.length];
|
||||
Arrays.fill(selected_arr, Boolean.TRUE);
|
||||
@@ -195,9 +195,9 @@ public class FileSelectorFragment extends Fragment {
|
||||
ByteBuilder b = new ByteBuilder();
|
||||
|
||||
for(int i = 0; i < filenames.size(); i++){
|
||||
file f = new file(filenames.get(i));
|
||||
ScoutingFile f = new ScoutingFile(filenames.get(i));
|
||||
|
||||
if(!fileEditor.fileExist(f.filename)) {
|
||||
if(!FileEditor.fileExist(f.filename)) {
|
||||
AlertManager.addSimpleError("File " + f.filename + " Does not exist!");
|
||||
continue;
|
||||
};
|
||||
@@ -209,7 +209,7 @@ public class FileSelectorFragment extends Fragment {
|
||||
continue;
|
||||
};
|
||||
|
||||
b.addRaw(file.typecode, bytes);
|
||||
b.addRaw(ScoutingFile.typecode, bytes);
|
||||
}
|
||||
|
||||
return b.build();
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.ridgebotics.ridgescout.ui.transfer;
|
||||
|
||||
import static androidx.navigation.fragment.FragmentKt.findNavController;
|
||||
import static com.ridgebotics.ridgescout.utility.fileEditor.TBAAddress;
|
||||
import static com.ridgebotics.ridgescout.utility.fileEditor.TBAHeader;
|
||||
import static com.ridgebotics.ridgescout.utility.FileEditor.TBAAddress;
|
||||
import static com.ridgebotics.ridgescout.utility.FileEditor.TBAHeader;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.os.Bundle;
|
||||
@@ -24,31 +24,26 @@ import com.ridgebotics.ridgescout.databinding.FragmentTransferTbaBinding;
|
||||
import com.ridgebotics.ridgescout.types.frcEvent;
|
||||
import com.ridgebotics.ridgescout.types.frcMatch;
|
||||
import com.ridgebotics.ridgescout.types.frcTeam;
|
||||
import com.ridgebotics.ridgescout.ui.TBAEventOption;
|
||||
import com.ridgebotics.ridgescout.utility.AlertManager;
|
||||
import com.ridgebotics.ridgescout.utility.ImageRequestTask;
|
||||
import com.ridgebotics.ridgescout.utility.JSONUtil;
|
||||
import com.ridgebotics.ridgescout.utility.RequestTask;
|
||||
import com.ridgebotics.ridgescout.utility.fileEditor;
|
||||
import com.ridgebotics.ridgescout.utility.settingsManager;
|
||||
import com.ridgebotics.ridgescout.utility.FileEditor;
|
||||
import com.ridgebotics.ridgescout.utility.SettingsManager;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
|
||||
public class TBAEventFragment extends Fragment {
|
||||
|
||||
private TableLayout Table;
|
||||
private FragmentTransferTbaBinding binding;
|
||||
|
||||
private final int year = settingsManager.getYearNum();
|
||||
private final int year = SettingsManager.getYearNum();
|
||||
|
||||
private ProgressDialog loadingDialog;
|
||||
|
||||
@@ -428,7 +423,7 @@ public class TBAEventFragment extends Fragment {
|
||||
event.teams = teams;
|
||||
event.matches = matchData;
|
||||
|
||||
fileEditor.setEvent(event);
|
||||
FileEditor.setEvent(event);
|
||||
AlertManager.toast("Saved!");
|
||||
|
||||
getActivity().runOnUiThread(() -> findNavController(this).navigate(R.id.action_navigation_tba_event_to_navigation_transfer));
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
package com.ridgebotics.ridgescout.ui.transfer;
|
||||
|
||||
import static androidx.navigation.fragment.FragmentKt.findNavController;
|
||||
import static com.ridgebotics.ridgescout.utility.fileEditor.TBAAddress;
|
||||
import static com.ridgebotics.ridgescout.utility.fileEditor.TBAHeader;
|
||||
import static com.ridgebotics.ridgescout.utility.FileEditor.TBAAddress;
|
||||
import static com.ridgebotics.ridgescout.utility.FileEditor.TBAHeader;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.TableRow;
|
||||
import android.widget.TextView;
|
||||
|
||||
@@ -22,14 +20,8 @@ import com.ridgebotics.ridgescout.R;
|
||||
import com.ridgebotics.ridgescout.databinding.FragmentTransferTbaBinding;
|
||||
import com.ridgebotics.ridgescout.ui.TBAEventOption;
|
||||
import com.ridgebotics.ridgescout.utility.AlertManager;
|
||||
import com.ridgebotics.ridgescout.utility.ImageRequestTask;
|
||||
import com.ridgebotics.ridgescout.utility.RequestTask;
|
||||
import com.ridgebotics.ridgescout.types.frcEvent;
|
||||
import com.ridgebotics.ridgescout.types.frcMatch;
|
||||
import com.ridgebotics.ridgescout.types.frcTeam;
|
||||
import com.ridgebotics.ridgescout.utility.fileEditor;
|
||||
import com.ridgebotics.ridgescout.utility.JSONUtil;
|
||||
import com.ridgebotics.ridgescout.utility.settingsManager;
|
||||
import com.ridgebotics.ridgescout.utility.SettingsManager;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
@@ -38,10 +30,7 @@ import org.json.JSONObject;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@@ -50,7 +39,7 @@ public class TBASelectorFragment extends Fragment {
|
||||
private android.widget.TableLayout Table;
|
||||
private FragmentTransferTbaBinding binding;
|
||||
|
||||
private final int year = settingsManager.getYearNum();
|
||||
private final int year = SettingsManager.getYearNum();
|
||||
|
||||
private ProgressDialog loadingDialog;
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.ridgebotics.ridgescout.ui.transfer;
|
||||
import static androidx.navigation.fragment.FragmentKt.findNavController;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -15,15 +14,11 @@ import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.ridgebotics.ridgescout.R;
|
||||
import com.ridgebotics.ridgescout.utility.AlertManager;
|
||||
import com.ridgebotics.ridgescout.utility.settingsManager;
|
||||
import com.ridgebotics.ridgescout.utility.SettingsManager;
|
||||
import com.ridgebotics.ridgescout.databinding.FragmentTransferBinding;
|
||||
import com.ridgebotics.ridgescout.ui.transfer.bluetooth.BluetoothSenderFragment;
|
||||
import com.ridgebotics.ridgescout.ui.transfer.codes.CodeGeneratorView;
|
||||
|
||||
import org.apache.commons.net.ftp.FTP;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class TransferFragment extends Fragment {
|
||||
private FragmentTransferBinding binding;
|
||||
|
||||
@@ -50,7 +45,7 @@ public class TransferFragment extends Fragment {
|
||||
|
||||
binding = FragmentTransferBinding.inflate(inflater, container, false);
|
||||
|
||||
evcode = settingsManager.getEVCode();
|
||||
evcode = SettingsManager.getEVCode();
|
||||
|
||||
binding.downloadButton.setOnClickListener(v -> {
|
||||
start_download();
|
||||
@@ -61,12 +56,12 @@ public class TransferFragment extends Fragment {
|
||||
});
|
||||
|
||||
|
||||
if(!settingsManager.getWifiMode()) {
|
||||
if(!SettingsManager.getWifiMode()) {
|
||||
binding.TBAButton.setEnabled(false);
|
||||
binding.SyncButton.setEnabled(false);
|
||||
}
|
||||
|
||||
if(!settingsManager.getFTPEnabled()) {
|
||||
if(!SettingsManager.getFTPEnabled()) {
|
||||
binding.SyncButton.setEnabled(false);
|
||||
}
|
||||
|
||||
|
||||
+7
-7
@@ -12,10 +12,10 @@ import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.ridgebotics.ridgescout.databinding.FragmentTransferBluetoothReceiverBinding;
|
||||
import com.ridgebotics.ridgescout.types.file;
|
||||
import com.ridgebotics.ridgescout.types.ScoutingFile;
|
||||
import com.ridgebotics.ridgescout.utility.AlertManager;
|
||||
import com.ridgebotics.ridgescout.utility.BuiltByteParser;
|
||||
import com.ridgebotics.ridgescout.utility.fileEditor;
|
||||
import com.ridgebotics.ridgescout.utility.FileEditor;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@@ -115,7 +115,7 @@ public class BluetoothReceiverFragment extends Fragment {
|
||||
private List<byte[]> recievedBytes;
|
||||
|
||||
private void receiveData(byte[] data, int bytes) {
|
||||
byte[] newBytes = fileEditor.getByteBlock(data, 0, bytes);
|
||||
byte[] newBytes = FileEditor.getByteBlock(data, 0, bytes);
|
||||
System.out.println("Recieved " + bytes + " Bytes over bluetooth!");
|
||||
recievedBytes.add(newBytes);
|
||||
}
|
||||
@@ -125,16 +125,16 @@ public class BluetoothReceiverFragment extends Fragment {
|
||||
String result_filenames = "";
|
||||
try {
|
||||
|
||||
byte[] resultBytes = fileEditor.combineByteArrays(recievedBytes);
|
||||
resultBytes = fileEditor.blockUncompress(resultBytes);
|
||||
byte[] resultBytes = FileEditor.combineByteArrays(recievedBytes);
|
||||
resultBytes = FileEditor.blockUncompress(resultBytes);
|
||||
|
||||
|
||||
BuiltByteParser bbp = new BuiltByteParser(resultBytes);
|
||||
ArrayList<BuiltByteParser.parsedObject> result = bbp.parse();
|
||||
|
||||
for (int i = 0; i < result.size(); i++) {
|
||||
if (result.get(i).getType() != file.typecode) continue;
|
||||
file f = file.decode((byte[]) result.get(i).get());
|
||||
if (result.get(i).getType() != ScoutingFile.typecode) continue;
|
||||
ScoutingFile f = ScoutingFile.decode((byte[]) result.get(i).get());
|
||||
|
||||
if (f != null) {
|
||||
System.out.println(f.filename);
|
||||
|
||||
+3
-3
@@ -17,7 +17,7 @@ import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.ridgebotics.ridgescout.databinding.FragmentTransferBluetoothSenderBinding;
|
||||
import com.ridgebotics.ridgescout.utility.AlertManager;
|
||||
import com.ridgebotics.ridgescout.utility.fileEditor;
|
||||
import com.ridgebotics.ridgescout.utility.FileEditor;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@@ -101,10 +101,10 @@ public class BluetoothSenderFragment extends Fragment {
|
||||
|
||||
private void sendData() {
|
||||
try {
|
||||
byte[] compressed = fileEditor.blockCompress(data_to_send);
|
||||
byte[] compressed = FileEditor.blockCompress(data_to_send);
|
||||
|
||||
for(int i = 0; i < Math.ceil((double) compressed.length/1024); i++){
|
||||
bluetoothSender.sendData(fileEditor.getByteBlock(compressed, i*1024, (i+1)*1024));
|
||||
bluetoothSender.sendData(FileEditor.getByteBlock(compressed, i*1024, (i+1)*1024));
|
||||
}
|
||||
|
||||
bluetoothSender.close();
|
||||
|
||||
+6
-6
@@ -17,7 +17,7 @@ import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.ridgebotics.ridgescout.databinding.FragmentTransferCodeSenderBinding;
|
||||
import com.ridgebotics.ridgescout.utility.AlertManager;
|
||||
import com.ridgebotics.ridgescout.utility.fileEditor;
|
||||
import com.ridgebotics.ridgescout.utility.FileEditor;
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.EncodeHintType;
|
||||
import com.google.zxing.MultiFormatWriter;
|
||||
@@ -76,7 +76,7 @@ public class CodeGeneratorView extends Fragment {
|
||||
qrIndexN = binding.qrIndexN;
|
||||
qrIndexD = binding.qrIndexD;
|
||||
|
||||
String compressed = new String(fileEditor.blockCompress(data), StandardCharsets.ISO_8859_1);
|
||||
String compressed = new String(FileEditor.blockCompress(data), StandardCharsets.ISO_8859_1);
|
||||
|
||||
if(compressed.isEmpty()){
|
||||
AlertManager.alert("Error!", "Empty data!");
|
||||
@@ -190,10 +190,10 @@ public class CodeGeneratorView extends Fragment {
|
||||
try {
|
||||
// alert("test", ""+Math.ceil((double)data.length()/(double)qrSize));
|
||||
qrBitmaps.add(generateQrCode(
|
||||
fileEditor.byteToChar(fileEditor.internalDataVersion) +
|
||||
String.valueOf(fileEditor.byteToChar(randID)) +
|
||||
fileEditor.byteToChar(i) +
|
||||
fileEditor.byteToChar(qrCount - 1) +
|
||||
FileEditor.byteToChar(FileEditor.internalDataVersion) +
|
||||
String.valueOf(FileEditor.byteToChar(randID)) +
|
||||
FileEditor.byteToChar(i) +
|
||||
FileEditor.byteToChar(qrCount - 1) +
|
||||
data.substring(start, end)
|
||||
));
|
||||
// alert("title", ""+(qrCount-1));
|
||||
|
||||
+11
-12
@@ -33,11 +33,10 @@ import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
|
||||
import com.ridgebotics.ridgescout.databinding.FragmentTransferCodeReceiverBinding;
|
||||
import com.ridgebotics.ridgescout.databinding.FragmentTransferCodeSenderBinding;
|
||||
import com.ridgebotics.ridgescout.types.file;
|
||||
import com.ridgebotics.ridgescout.types.ScoutingFile;
|
||||
import com.ridgebotics.ridgescout.utility.AlertManager;
|
||||
import com.ridgebotics.ridgescout.utility.BuiltByteParser;
|
||||
import com.ridgebotics.ridgescout.utility.fileEditor;
|
||||
import com.ridgebotics.ridgescout.utility.FileEditor;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
@@ -120,10 +119,10 @@ public class CodeScannerView extends Fragment {
|
||||
if(data != null){
|
||||
// alert("test", ""+fileEditor.byteFromChar(data.charAt(0)));
|
||||
compileData(
|
||||
fileEditor.byteFromChar(data.charAt(0)),
|
||||
fileEditor.byteFromChar(data.charAt(1)),
|
||||
fileEditor.byteFromChar(data.charAt(2)),
|
||||
(fileEditor.byteFromChar(data.charAt(3))+1),
|
||||
FileEditor.byteFromChar(data.charAt(0)),
|
||||
FileEditor.byteFromChar(data.charAt(1)),
|
||||
FileEditor.byteFromChar(data.charAt(2)),
|
||||
(FileEditor.byteFromChar(data.charAt(3))+1),
|
||||
data.substring(4)
|
||||
);
|
||||
}
|
||||
@@ -284,8 +283,8 @@ public class CodeScannerView extends Fragment {
|
||||
private int randID;
|
||||
private int prevQrIndex;
|
||||
private void compileData(int dataVersion, int randID, int qrIndex, int qrCount, String qrData){
|
||||
if(dataVersion != fileEditor.internalDataVersion){
|
||||
alert("Error", "Incorrect data version ("+dataVersion+" != "+fileEditor.internalDataVersion+")");
|
||||
if(dataVersion != FileEditor.internalDataVersion){
|
||||
alert("Error", "Incorrect data version ("+dataVersion+" != "+ FileEditor.internalDataVersion+")");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -321,7 +320,7 @@ public class CodeScannerView extends Fragment {
|
||||
|
||||
try {
|
||||
byte[] compiledBytes = compiledString.getBytes(StandardCharsets.ISO_8859_1);
|
||||
byte[] resultBytes = fileEditor.blockUncompress(compiledBytes);
|
||||
byte[] resultBytes = FileEditor.blockUncompress(compiledBytes);
|
||||
|
||||
|
||||
String result_filenames = "";
|
||||
@@ -330,8 +329,8 @@ public class CodeScannerView extends Fragment {
|
||||
ArrayList<BuiltByteParser.parsedObject> result = bbp.parse();
|
||||
|
||||
for(int i = 0; i < result.size(); i++){
|
||||
if(result.get(i).getType() != file.typecode) continue;
|
||||
file f = file.decode((byte[]) result.get(i).get());
|
||||
if(result.get(i).getType() != ScoutingFile.typecode) continue;
|
||||
ScoutingFile f = ScoutingFile.decode((byte[]) result.get(i).get());
|
||||
|
||||
if(f != null)
|
||||
if(f.write())
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package com.ridgebotics.ridgescout.utility;
|
||||
|
||||
import static com.ridgebotics.ridgescout.utility.fileEditor.lengthHeaderBytes;
|
||||
import static com.ridgebotics.ridgescout.utility.FileEditor.lengthHeaderBytes;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class BuiltByteParser {
|
||||
public static final Integer boolType = 0;
|
||||
@@ -86,7 +85,7 @@ public class BuiltByteParser {
|
||||
int curIndex = 0;
|
||||
while(true){
|
||||
// Log.i("t", String.valueOf(curIndex));
|
||||
final int length = fileEditor.fromBytes(fileEditor.getByteBlock(bytes, curIndex, curIndex+lengthHeaderBytes), lengthHeaderBytes);
|
||||
final int length = FileEditor.fromBytes(FileEditor.getByteBlock(bytes, curIndex, curIndex+lengthHeaderBytes), lengthHeaderBytes);
|
||||
final int type = bytes[curIndex+lengthHeaderBytes] & 0xFF;
|
||||
|
||||
if(length == 0){
|
||||
@@ -97,7 +96,7 @@ public class BuiltByteParser {
|
||||
final byte[] block;
|
||||
|
||||
try {
|
||||
block = fileEditor.getByteBlock(bytes, curIndex + lengthHeaderBytes + 1, curIndex + length + lengthHeaderBytes + 1);
|
||||
block = FileEditor.getByteBlock(bytes, curIndex + lengthHeaderBytes + 1, curIndex + length + lengthHeaderBytes + 1);
|
||||
} catch(Exception e){
|
||||
throw new byteParsingExeption("Array out of bounds");
|
||||
}
|
||||
@@ -110,7 +109,7 @@ public class BuiltByteParser {
|
||||
break;
|
||||
case 1:
|
||||
intObject io = new intObject();
|
||||
io.num = fileEditor.fromBytes(block, length);
|
||||
io.num = FileEditor.fromBytes(block, length);
|
||||
objects.add(io);
|
||||
break;
|
||||
case 2:
|
||||
@@ -150,7 +149,7 @@ public class BuiltByteParser {
|
||||
break;
|
||||
case 5:
|
||||
longObject lo = new longObject();
|
||||
lo.num = fileEditor.fromBytesLong(block, length);
|
||||
lo.num = FileEditor.fromBytesLong(block, length);
|
||||
objects.add(lo);
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.ridgebotics.ridgescout.utility;
|
||||
|
||||
import static com.ridgebotics.ridgescout.utility.fileEditor.lengthHeaderBytes;
|
||||
import static com.ridgebotics.ridgescout.utility.FileEditor.lengthHeaderBytes;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
@@ -58,7 +58,7 @@ public class ByteBuilder {
|
||||
public byte getType(){return int_id;}
|
||||
public int length(){return precision;}
|
||||
public byte[] build(){
|
||||
return fileEditor.toBytes(num, precision);
|
||||
return FileEditor.toBytes(num, precision);
|
||||
}
|
||||
}
|
||||
private int getLeastBytePrecision(int num){
|
||||
@@ -162,7 +162,7 @@ public class ByteBuilder {
|
||||
public byte getType(){return long_id;}
|
||||
public int length(){return precision;}
|
||||
public byte[] build(){
|
||||
return fileEditor.toBytes(num, precision);
|
||||
return FileEditor.toBytes(num, precision);
|
||||
}
|
||||
}
|
||||
private int getLeastBytePrecision(long num){
|
||||
@@ -225,7 +225,7 @@ public class ByteBuilder {
|
||||
|
||||
for(byteType bt : bytesToBuild){
|
||||
|
||||
byte[] blockLength = fileEditor.toBytes(bt.length(), lengthHeaderBytes + 1);
|
||||
byte[] blockLength = FileEditor.toBytes(bt.length(), lengthHeaderBytes + 1);
|
||||
|
||||
for(int i = 0; i < lengthHeaderBytes; i++) {
|
||||
bytes[bytesFilled] = blockLength[i];
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
package com.ridgebotics.ridgescout.utility;
|
||||
|
||||
import com.ridgebotics.ridgescout.scoutingData.fields;
|
||||
import com.ridgebotics.ridgescout.scoutingData.transfer.transferType;
|
||||
import com.ridgebotics.ridgescout.scoutingData.Fields;
|
||||
import com.ridgebotics.ridgescout.scoutingData.transfer.TransferType;
|
||||
import com.ridgebotics.ridgescout.types.frcEvent;
|
||||
import com.ridgebotics.ridgescout.types.input.inputType;
|
||||
import com.ridgebotics.ridgescout.types.input.FieldType;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -19,11 +18,11 @@ public class DataManager {
|
||||
|
||||
if(evcode.equals("unset")) return;
|
||||
|
||||
event = frcEvent.decode(fileEditor.readFile(evcode + ".eventdata"));
|
||||
event = frcEvent.decode(FileEditor.readFile(evcode + ".eventdata"));
|
||||
|
||||
if(event == null) {
|
||||
AlertManager.addSimpleError("Failed to load event!");
|
||||
settingsManager.setEVCode("unset");
|
||||
SettingsManager.setEVCode("unset");
|
||||
evcode = "unset";
|
||||
}else{
|
||||
AlertManager.toast("Reloaded event!");
|
||||
@@ -32,30 +31,30 @@ public class DataManager {
|
||||
}
|
||||
|
||||
public static String getevcode() {
|
||||
return settingsManager.getEVCode();
|
||||
return SettingsManager.getEVCode();
|
||||
}
|
||||
|
||||
public static inputType[][] match_values;
|
||||
public static inputType[] match_latest_values;
|
||||
public static transferType[][] match_transferValues;
|
||||
public static FieldType[][] match_values;
|
||||
public static FieldType[] match_latest_values;
|
||||
public static TransferType[][] match_transferValues;
|
||||
public static void reload_match_fields(){
|
||||
try {
|
||||
match_values = fields.load(fields.matchFieldsFilename);
|
||||
match_values = Fields.load(Fields.matchFieldsFilename);
|
||||
match_latest_values = match_values[match_values.length - 1];
|
||||
match_transferValues = transferType.get_transfer_values(match_values);
|
||||
match_transferValues = TransferType.get_transfer_values(match_values);
|
||||
} catch (Exception e){
|
||||
AlertManager.error("Error reading match fields", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static inputType[][] pit_values;
|
||||
public static inputType[] pit_latest_values;
|
||||
public static transferType[][] pit_transferValues;
|
||||
public static FieldType[][] pit_values;
|
||||
public static FieldType[] pit_latest_values;
|
||||
public static TransferType[][] pit_transferValues;
|
||||
public static void reload_pit_fields(){
|
||||
try {
|
||||
pit_values = fields.load(fields.pitsFieldsFilename);
|
||||
pit_values = Fields.load(Fields.pitsFieldsFilename);
|
||||
pit_latest_values = pit_values[pit_values.length-1];
|
||||
pit_transferValues = transferType.get_transfer_values(pit_values);
|
||||
pit_transferValues = TransferType.get_transfer_values(pit_values);
|
||||
} catch (Exception e){
|
||||
AlertManager.error("Error reading pit fields", e);
|
||||
}
|
||||
@@ -63,8 +62,8 @@ public class DataManager {
|
||||
|
||||
public static List<String> rescout_list = new ArrayList<>();
|
||||
public static void reload_rescout_list(){
|
||||
if(!fileEditor.fileExist(evcode + ".rescout")) {rescout_list = new ArrayList<>(); return;}
|
||||
byte[] file = fileEditor.readFile(evcode + ".rescout");
|
||||
if(!FileEditor.fileExist(evcode + ".rescout")) {rescout_list = new ArrayList<>(); return;}
|
||||
byte[] file = FileEditor.readFile(evcode + ".rescout");
|
||||
if(file == null) {rescout_list = new ArrayList<>(); return;}
|
||||
|
||||
try {
|
||||
@@ -80,13 +79,13 @@ public class DataManager {
|
||||
public static void save_rescout_list() {
|
||||
try {
|
||||
if(rescout_list.size() == 0){
|
||||
fileEditor.deleteFile(evcode + ".rescout");
|
||||
FileEditor.deleteFile(evcode + ".rescout");
|
||||
return;
|
||||
}
|
||||
|
||||
ByteBuilder bb = new ByteBuilder();
|
||||
bb.addStringArray(rescout_list.toArray(new String[0]));
|
||||
fileEditor.writeFile(evcode + ".rescout", bb.build());
|
||||
FileEditor.writeFile(evcode + ".rescout", bb.build());
|
||||
} catch (Exception e){
|
||||
AlertManager.error("Error saving scout fields", e);
|
||||
}
|
||||
|
||||
+11
-17
@@ -1,8 +1,6 @@
|
||||
package com.ridgebotics.ridgescout.utility;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
|
||||
import com.ridgebotics.ridgescout.types.frcEvent;
|
||||
import com.ridgebotics.ridgescout.types.frcTeam;
|
||||
@@ -17,21 +15,17 @@ import java.io.IOException;
|
||||
import java.nio.BufferOverflowException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.TimeZone;
|
||||
import java.util.zip.DataFormatException;
|
||||
import java.util.zip.Deflater;
|
||||
import java.util.zip.Inflater;
|
||||
|
||||
public final class fileEditor {
|
||||
public final class FileEditor {
|
||||
public final static String baseDir = "/data/data/com.ridgebotics.ridgescout/";
|
||||
public static final byte internalDataVersion = 0x01;
|
||||
public static final int maxCompressedBlockSize = 4096;
|
||||
@@ -142,18 +136,18 @@ public final class fileEditor {
|
||||
public static byte[] blockCompress(byte[] inputData) {
|
||||
List<byte[]> compiledData = new ArrayList<>();
|
||||
|
||||
for(int i=0;i<Math.ceil((double) inputData.length / fileEditor.maxCompressedBlockSize);i++){
|
||||
final int start = i*fileEditor.maxCompressedBlockSize;
|
||||
int end = ((i+1)*fileEditor.maxCompressedBlockSize);
|
||||
for(int i = 0; i<Math.ceil((double) inputData.length / FileEditor.maxCompressedBlockSize); i++){
|
||||
final int start = i* FileEditor.maxCompressedBlockSize;
|
||||
int end = ((i+1)* FileEditor.maxCompressedBlockSize);
|
||||
if(end > inputData.length) {
|
||||
end = inputData.length;
|
||||
}
|
||||
|
||||
byte[] dataBlock = fileEditor.getByteBlock(inputData, start, end);
|
||||
byte[] dataBlock = FileEditor.getByteBlock(inputData, start, end);
|
||||
|
||||
final byte[] compressedBlock = fileEditor.compress(dataBlock);
|
||||
final byte[] compressedBlock = FileEditor.compress(dataBlock);
|
||||
|
||||
compiledData.add(fileEditor.toBytes(compressedBlock.length, 2));
|
||||
compiledData.add(FileEditor.toBytes(compressedBlock.length, 2));
|
||||
compiledData.add(compressedBlock);
|
||||
}
|
||||
return combineByteArrays(compiledData);
|
||||
@@ -164,11 +158,11 @@ public final class fileEditor {
|
||||
int curIndex = 0;
|
||||
while (curIndex < data.length) {
|
||||
|
||||
final int blockLength = fileEditor.fromBytes(fileEditor.getByteBlock(data, curIndex, curIndex + 2), 2);
|
||||
final int blockLength = FileEditor.fromBytes(FileEditor.getByteBlock(data, curIndex, curIndex + 2), 2);
|
||||
|
||||
uncompressedData.add(
|
||||
decompress(
|
||||
fileEditor.getByteBlock(data, curIndex + 2, curIndex + blockLength + 2)
|
||||
FileEditor.getByteBlock(data, curIndex + 2, curIndex + blockLength + 2)
|
||||
)
|
||||
);
|
||||
|
||||
@@ -324,8 +318,8 @@ public final class fileEditor {
|
||||
public static boolean setEvent(frcEvent event){
|
||||
final String filename = (event.eventCode + ".eventdata");
|
||||
|
||||
if(settingsManager.getEVCode().equals("unset")){
|
||||
settingsManager.setEVCode(event.eventCode);
|
||||
if(SettingsManager.getEVCode().equals("unset")){
|
||||
SettingsManager.setEVCode(event.eventCode);
|
||||
}
|
||||
|
||||
return writeFile(filename, event.encode());
|
||||
+1
-2
@@ -2,12 +2,11 @@ package com.ridgebotics.ridgescout.utility;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class settingsManager {
|
||||
public class SettingsManager {
|
||||
public static SharedPreferences prefs;
|
||||
public static SharedPreferences.Editor editor;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ui.settings.settingsFragment">
|
||||
tools:context=".ui.settings.SettingsFragment">
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/scrollView2"
|
||||
|
||||
@@ -53,14 +53,15 @@
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/scrollView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TableLayout
|
||||
android:id="@+id/fieldsArea"
|
||||
android:paddingBottom="60dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"
|
||||
android:paddingBottom="60dp">
|
||||
|
||||
</TableLayout>
|
||||
</ScrollView>
|
||||
|
||||
@@ -250,7 +250,7 @@
|
||||
|
||||
<fragment
|
||||
android:id="@+id/navigation_settings"
|
||||
android:name="com.ridgebotics.ridgescout.ui.settings.settingsFragment"
|
||||
android:name="com.ridgebotics.ridgescout.ui.settings.SettingsFragment"
|
||||
android:label="@string/title_settings"
|
||||
tools:layout="@layout/fragment_settings">
|
||||
<action
|
||||
|
||||
Reference in New Issue
Block a user