mirror of
https://github.com/Team4388/RidgeScout.git
synced 2026-06-08 16:28:00 -06:00
Start using the fields in scouting
This commit is contained in:
@@ -2,6 +2,7 @@ package com.astatin3.scoutingapp2025;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.astatin3.scoutingapp2025.scoutingData.fields;
|
||||
import com.google.android.material.bottomnavigation.BottomNavigationView;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
@@ -21,7 +22,13 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
latestSettings.update();
|
||||
|
||||
if(!fileEditor.fileExist(fields.fieldsFilename)){
|
||||
fields.save();
|
||||
}
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
binding = ActivityMainBinding.inflate(getLayoutInflater());
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
package com.astatin3.scoutingapp2025.ScoutingDataVersion;
|
||||
package com.astatin3.scoutingapp2025.scoutingData;
|
||||
|
||||
import com.astatin3.scoutingapp2025.BuiltByteParser;
|
||||
import com.astatin3.scoutingapp2025.ByteBuilder;
|
||||
import com.astatin3.scoutingapp2025.utility.BuiltByteParser;
|
||||
import com.astatin3.scoutingapp2025.utility.ByteBuilder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
+25
-23
@@ -1,8 +1,8 @@
|
||||
package com.astatin3.scoutingapp2025.ScoutingDataVersion;
|
||||
package com.astatin3.scoutingapp2025.scoutingData;
|
||||
|
||||
import com.astatin3.scoutingapp2025.BuiltByteParser;
|
||||
import com.astatin3.scoutingapp2025.ByteBuilder;
|
||||
import com.astatin3.scoutingapp2025.fileEditor;
|
||||
import com.astatin3.scoutingapp2025.utility.BuiltByteParser;
|
||||
import com.astatin3.scoutingapp2025.utility.ByteBuilder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -10,26 +10,26 @@ public class fields {
|
||||
public static ScoutingVersion sv = new ScoutingVersion();
|
||||
public static final String fieldsFilename = "data.fields";
|
||||
|
||||
public static ScoutingVersion.inputType[][] values = new ScoutingVersion.inputType[][]{};
|
||||
// public static ScoutingVersion.inputType[][] values = new ScoutingVersion.inputType[][]{};
|
||||
|
||||
// public static ScoutingVersion.inputType[][] values = new ScoutingVersion.inputType[][] {
|
||||
// {
|
||||
// sv.new notesType("name", "Unset-Username"),
|
||||
// sv.new sliderType("How good is robot", 5, 0, 10)
|
||||
// }, {
|
||||
// sv.new notesType("name", "Unset-Username"),
|
||||
// sv.new sliderType("How good is robot", 5, 0, 10),
|
||||
// sv.new notesType("notes", "No-Notes")
|
||||
// }, {
|
||||
// sv.new notesType("name", "Unset-Username"),
|
||||
// sv.new notesType("notes", "No-Notes")
|
||||
// }, {
|
||||
// sv.new notesType("name", "Unset-Username")
|
||||
// }, {
|
||||
// sv.new notesType("name", "Unset-Username"),
|
||||
// sv.new sliderType("How good is robot", 5, 0, 10)
|
||||
// }
|
||||
// };
|
||||
public static ScoutingVersion.inputType[][] values = new ScoutingVersion.inputType[][] {
|
||||
{
|
||||
sv.new notesType("name", "Unset-Username"),
|
||||
sv.new sliderType("How good is robot", 5, 0, 10)
|
||||
}, {
|
||||
sv.new notesType("name", "Unset-Username"),
|
||||
sv.new sliderType("How good is robot", 5, 0, 10),
|
||||
sv.new notesType("notes", "No-Notes")
|
||||
}, {
|
||||
sv.new notesType("name", "Unset-Username"),
|
||||
sv.new notesType("notes", "No-Notes")
|
||||
}, {
|
||||
sv.new notesType("name", "Unset-Username")
|
||||
}, {
|
||||
sv.new notesType("name", "Unset-Username"),
|
||||
sv.new sliderType("How good is robot", 5, 0, 10)
|
||||
}
|
||||
};
|
||||
|
||||
public static boolean save(){
|
||||
try {
|
||||
@@ -57,6 +57,8 @@ public class fields {
|
||||
public static boolean load(){
|
||||
byte[] bytes = fileEditor.readFile(fieldsFilename);
|
||||
|
||||
System.out.println(bytes);
|
||||
|
||||
try {
|
||||
BuiltByteParser bbp = new BuiltByteParser(bytes);
|
||||
ArrayList<BuiltByteParser.parsedObject> objects = bbp.parse();
|
||||
@@ -67,7 +69,7 @@ public class fields {
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (BuiltByteParser.byteParsingExeption e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
@@ -1,11 +1,9 @@
|
||||
package com.astatin3.scoutingapp2025.types;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.astatin3.scoutingapp2025.BuiltByteParser;
|
||||
import com.astatin3.scoutingapp2025.ByteBuilder;
|
||||
import com.astatin3.scoutingapp2025.utility.BuiltByteParser;
|
||||
import com.astatin3.scoutingapp2025.utility.ByteBuilder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@ package com.astatin3.scoutingapp2025.types;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.astatin3.scoutingapp2025.BuiltByteParser;
|
||||
import com.astatin3.scoutingapp2025.ByteBuilder;
|
||||
import com.astatin3.scoutingapp2025.utility.BuiltByteParser;
|
||||
import com.astatin3.scoutingapp2025.utility.ByteBuilder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -2,11 +2,10 @@ package com.astatin3.scoutingapp2025.types;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.astatin3.scoutingapp2025.BuiltByteParser;
|
||||
import com.astatin3.scoutingapp2025.ByteBuilder;
|
||||
import com.astatin3.scoutingapp2025.utility.BuiltByteParser;
|
||||
import com.astatin3.scoutingapp2025.utility.ByteBuilder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class frcTeam {
|
||||
public static final int typecode = 252;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.astatin3.scoutingapp2025.ui.scouting;
|
||||
|
||||
import static com.astatin3.scoutingapp2025.ScoutingDataVersion.fields.sv;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.RelativeLayout;
|
||||
@@ -11,14 +11,18 @@ import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
|
||||
import com.astatin3.scoutingapp2025.ScoutingDataVersion.ScoutingVersion;
|
||||
import com.astatin3.scoutingapp2025.ScoutingDataVersion.fields;
|
||||
import com.astatin3.scoutingapp2025.scoutingData.ScoutingVersion;
|
||||
import com.astatin3.scoutingapp2025.scoutingData.fields;
|
||||
import com.astatin3.scoutingapp2025.SettingsVersionStack.latestSettings;
|
||||
import com.astatin3.scoutingapp2025.databinding.FragmentScoutingBinding;
|
||||
import com.astatin3.scoutingapp2025.fileEditor;
|
||||
import com.astatin3.scoutingapp2025.types.frcEvent;
|
||||
import com.astatin3.scoutingapp2025.types.frcMatch;
|
||||
import com.astatin3.scoutingapp2025.types.frcTeam;
|
||||
import com.astatin3.scoutingapp2025.utility.AutoSaveManager;
|
||||
import com.google.android.material.slider.Slider;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class matchScoutingView extends ConstraintLayout {
|
||||
public matchScoutingView(Context context) {
|
||||
@@ -33,6 +37,11 @@ public class matchScoutingView extends ConstraintLayout {
|
||||
String evcode;
|
||||
int cur_match_num;
|
||||
frcEvent event;
|
||||
AutoSaveManager asm = new AutoSaveManager(this::save);
|
||||
|
||||
public void save(){
|
||||
System.out.println("Saved!");
|
||||
}
|
||||
|
||||
public void init(FragmentScoutingBinding tmp_binding){
|
||||
binding = tmp_binding;
|
||||
@@ -82,8 +91,7 @@ public class matchScoutingView extends ConstraintLayout {
|
||||
update_scouting_data();
|
||||
}
|
||||
|
||||
public void update_scouting_data(){
|
||||
frcMatch match = event.matches.get(cur_match_num);
|
||||
private frcTeam get_team(frcMatch match){
|
||||
|
||||
// Get team number
|
||||
String[] split = alliance_position.split("-");
|
||||
@@ -109,40 +117,85 @@ public class matchScoutingView extends ConstraintLayout {
|
||||
}
|
||||
}
|
||||
|
||||
return team;
|
||||
}
|
||||
|
||||
ArrayList<View> views = new ArrayList<>();
|
||||
|
||||
public void update_scouting_data(){
|
||||
|
||||
asm.start();
|
||||
|
||||
frcMatch match = event.matches.get(cur_match_num);
|
||||
frcTeam team = get_team(match);
|
||||
|
||||
binding.teamName.setText(team.teamName);
|
||||
binding.teamDescription.setText(team.getDescription());
|
||||
|
||||
fields.load();
|
||||
for(int i = 0; i < views.size(); i++){
|
||||
binding.MatchScoutArea.removeView(views.get(i));
|
||||
}
|
||||
|
||||
views = new ArrayList<>();
|
||||
|
||||
boolean success = fields.load();
|
||||
|
||||
if(!success){
|
||||
TextView tv = new TextView(getContext());
|
||||
tv.setText("Failed to load fields.\nTry to either download or create match scouting fields.");
|
||||
tv.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
|
||||
binding.MatchScoutArea.addView(tv);
|
||||
views.add(tv);
|
||||
return;
|
||||
}
|
||||
|
||||
if(fields.values.length == 0){
|
||||
return;
|
||||
}
|
||||
|
||||
ScoutingVersion.inputType[] values = fields.values[fields.values.length-1];
|
||||
|
||||
int prev_text = binding.teamDescription.getId();
|
||||
// int prev_text = binding.teamDescription.getId();
|
||||
|
||||
for(int i = 0 ; i < values.length; i++){
|
||||
TextView tv = new TextView(getContext());
|
||||
tv.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
|
||||
tv.setTextSize(24);
|
||||
binding.MatchScoutArea.addView(tv);
|
||||
views.add(tv);
|
||||
|
||||
// RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
|
||||
//// params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
|
||||
// params.addRule(RelativeLayout.ALIGN_LEFT, prev_text);
|
||||
// tv.setLayoutParams(params);
|
||||
|
||||
|
||||
String text = "Fallback";
|
||||
switch (values[i].getInputType()){
|
||||
case SLIDER:
|
||||
text = "Slider";
|
||||
ScoutingVersion.sliderType sliderType = (ScoutingVersion.sliderType) values[i];
|
||||
tv.setText(sliderType.name);
|
||||
|
||||
Slider slider = new Slider(getContext());
|
||||
|
||||
slider.setStepSize((float) 1 / sliderType.max);
|
||||
slider.setValue((int) sliderType.default_value / (float) sliderType.max);
|
||||
|
||||
slider.addOnChangeListener(new Slider.OnChangeListener() {
|
||||
@Override
|
||||
public void onValueChange(@NonNull Slider slider, float value, boolean fromUser) {
|
||||
System.out.println(value * sliderType.max);
|
||||
asm.update();
|
||||
}
|
||||
});
|
||||
|
||||
binding.MatchScoutArea.addView(slider);
|
||||
views.add(slider);
|
||||
break;
|
||||
case DROPDOWN:
|
||||
text = "Dropdown";
|
||||
ScoutingVersion.dropdownType dropdownType = (ScoutingVersion.dropdownType) values[i];
|
||||
tv.setText(dropdownType.name);
|
||||
break;
|
||||
case NOTES_INPUT:
|
||||
text = "Notes";
|
||||
ScoutingVersion.notesType notesType = (ScoutingVersion.notesType) values[i];
|
||||
tv.setText(notesType.name);
|
||||
break;
|
||||
}
|
||||
System.out.println(text);
|
||||
tv.setText(text);
|
||||
|
||||
binding.MatchScoutArea.addView(tv);
|
||||
prev_text = tv.getId();
|
||||
// prev_text = tv.getId();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,14 +10,9 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.astatin3.scoutingapp2025.BuiltByteParser;
|
||||
import com.astatin3.scoutingapp2025.ByteBuilder;
|
||||
import com.astatin3.scoutingapp2025.ScoutingDataVersion.fields;
|
||||
import com.astatin3.scoutingapp2025.SettingsVersionStack.latestSettings;
|
||||
import com.astatin3.scoutingapp2025.databinding.FragmentScoutingBinding;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class scoutingFragment extends Fragment {
|
||||
|
||||
private FragmentScoutingBinding binding;
|
||||
|
||||
@@ -12,25 +12,23 @@ import android.widget.TableLayout;
|
||||
import android.widget.TableRow;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.astatin3.scoutingapp2025.RequestTask;
|
||||
import com.astatin3.scoutingapp2025.utility.RequestTask;
|
||||
import com.astatin3.scoutingapp2025.types.frcEvent;
|
||||
import com.astatin3.scoutingapp2025.types.frcMatch;
|
||||
import com.astatin3.scoutingapp2025.types.frcTeam;
|
||||
import com.astatin3.scoutingapp2025.databinding.FragmentTransferBinding;
|
||||
import com.astatin3.scoutingapp2025.fileEditor;
|
||||
import com.astatin3.scoutingapp2025.ui.JSONUtil;
|
||||
import com.astatin3.scoutingapp2025.utility.JSONUtil;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
public class TBAView extends ScrollView {
|
||||
private final String TBAAddress = "https://www.thebluealliance.com/api/v3/";
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.astatin3.scoutingapp2025;
|
||||
package com.astatin3.scoutingapp2025.ui.transfer;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.AsyncTask;
|
||||
@@ -27,7 +27,6 @@ import androidx.lifecycle.LifecycleOwner;
|
||||
|
||||
import com.astatin3.scoutingapp2025.databinding.FragmentTransferBinding;
|
||||
import com.astatin3.scoutingapp2025.fileEditor;
|
||||
import com.astatin3.scoutingapp2025.codeScanTask;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.astatin3.scoutingapp2025.utility;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
|
||||
public class AutoSaveManager {
|
||||
private static final long AUTO_SAVE_DELAY = 5000; // 5 seconds
|
||||
|
||||
private final Handler handler;
|
||||
private final Runnable autoSaveRunnable;
|
||||
private boolean isAutoSaveScheduled = false;
|
||||
private final AutoSaveFunction autoSaveFunction;
|
||||
private boolean isRunning = false;
|
||||
|
||||
// Functional interface for the auto-save function
|
||||
@FunctionalInterface
|
||||
public interface AutoSaveFunction {
|
||||
void save();
|
||||
}
|
||||
|
||||
public AutoSaveManager(AutoSaveFunction autoSaveFunction) {
|
||||
this.autoSaveFunction = autoSaveFunction;
|
||||
handler = new Handler(Looper.getMainLooper());
|
||||
autoSaveRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
performAutoSave();
|
||||
isAutoSaveScheduled = false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void start() {
|
||||
isRunning = true;
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
isRunning = false;
|
||||
handler.removeCallbacks(autoSaveRunnable);
|
||||
isAutoSaveScheduled = false;
|
||||
}
|
||||
|
||||
public void update() {
|
||||
if (!isRunning) {
|
||||
return; // Don't schedule auto-saves when not running
|
||||
}
|
||||
|
||||
// Cancel any previously scheduled auto-save
|
||||
handler.removeCallbacks(autoSaveRunnable);
|
||||
|
||||
// Schedule a new auto-save
|
||||
handler.postDelayed(autoSaveRunnable, AUTO_SAVE_DELAY);
|
||||
isAutoSaveScheduled = true;
|
||||
}
|
||||
|
||||
private void performAutoSave() {
|
||||
if (isRunning) {
|
||||
// Call the provided auto-save function
|
||||
autoSaveFunction.save();
|
||||
}
|
||||
}
|
||||
|
||||
public void onDestroy() {
|
||||
// Remove any pending auto-save tasks when the activity or fragment is destroyed
|
||||
stop();
|
||||
}
|
||||
|
||||
public boolean isAutoSaveScheduled() {
|
||||
return isAutoSaveScheduled;
|
||||
}
|
||||
|
||||
public boolean isRunning() {
|
||||
return isRunning;
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package com.astatin3.scoutingapp2025;
|
||||
package com.astatin3.scoutingapp2025.utility;
|
||||
|
||||
import android.util.Log;
|
||||
import com.astatin3.scoutingapp2025.fileEditor;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
+2
-4
@@ -1,9 +1,7 @@
|
||||
package com.astatin3.scoutingapp2025;
|
||||
package com.astatin3.scoutingapp2025.utility;
|
||||
|
||||
import android.util.Log;
|
||||
import com.astatin3.scoutingapp2025.fileEditor;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.astatin3.scoutingapp2025.ui;
|
||||
package com.astatin3.scoutingapp2025.utility;
|
||||
|
||||
import org.json.JSONArray;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.astatin3.scoutingapp2025;
|
||||
package com.astatin3.scoutingapp2025.utility;
|
||||
|
||||
import android.os.AsyncTask;
|
||||
|
||||
Reference in New Issue
Block a user