Rework some UI elements

This commit is contained in:
Michael Mikovsky
2025-02-17 22:47:39 -07:00
parent ff84760ab2
commit cf3856805b
32 changed files with 352 additions and 312 deletions
@@ -23,27 +23,32 @@ public class fields {
public static final inputType[][] default_match_fields = new inputType[][] {
{
new fieldposType("Auto start pos", new int[]{0,0}),
new tallyType("Auto Notes", 0),
new sliderType("Auto Performance", 5, 0, 10),
new textType("Auto Comments", ""),
new tallyType("Teleop Notes", 0),
new sliderType("Teleop Performance", 5, 0, 10),
new textType("Teleop Comments", ""),
new sliderType("Overall Driving Performance", 5, 0, 10),
new textType("Overall Driving Comments", ""),
new sliderType("Score area (AMP <-> Speaker)", 5, 0, 10),
new dropdownType("End Condition", new String[]{"Nothing", "Attempted Climb", "Successful Climbed", "Climbed with multiple robots", "Climbed with trap"}, 0),
new dropdownType("Robot Condition", new String[]{"Everything was working", "Something was maybe broken", "Something was broken", "Robot was disabled for part of the match", "Missing robot (Joe Johnson)"}, 0),
new textType("Other Comments", "")
new fieldposType("Auto start pos", "Where does the robot start its auto?", new int[]{0,0}),
new tallyType("Auto Coral", "How many coral did this robot score in auto?", 0),
new tallyType("Auto Algae", "How many algae did this robot score in auto?", 0),
new sliderType("Auto Performance", "How well did you think this robot did in auto?", 5, 0, 10),
new textType("Auto Comments", "Anything interesting about auto", ""),
new tallyType("Teleop Coral", "How many coral did this robot score in teleop?", 0),
new tallyType("Teleop Algae", "How many algae did this robot score in teleop?", 0),
new checkboxType("Coral Removal", "Did the robot remove coral?", 0),
new checkboxType("L4 Scoring", "Did the robot score in Layer 4?", 0),
new checkboxType("L3 Scoring", "Did the robot score in Layer 3?", 0),
new checkboxType("L2 Scoring", "Did the robot score in Layer 3?", 0),
new checkboxType("L1 Scoring", "Did the robot score in Layer 1?", 0),
new checkboxType("Processor Scoring", "Did the robot score in the processor?", 0),
new sliderType("Teleop Performance", "How well did the robot drive around?", 5, 0, 10),
new textType("Teleop Notes", "Anything intresting about Teleop", ""),
new dropdownType("End Condition", "What was the final condition of the robot?", new String[]{"Nothing", "Park", "Attempted Shallow", "Shallow", "Attempted Deep", "Deep"}, 0),
new dropdownType("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 (Joe Johnson)"}, 0),
new textType("Other Comments", "Any other comments you have", "")
}
};
public static final inputType[][] default_pit_fields = new inputType[][] {
{
new sliderType("How good is robot", 5, 0, 10),
new sliderType("Test", 1, 0, 10),
new textType("notes", ""),
new sliderType("How good is robot", "How good, in fact, is this robot?", 5, 0, 10),
new sliderType("Test", "Testy", 1, 0, 10),
new textType("notes", "Write text about robot here", ""),
}
};
@@ -41,8 +41,8 @@ public class checkboxType extends inputType {
public Object get_fallback_value(){return 0;}
public checkboxType(){};
public String get_type_name(){return "Checkbox";}
public checkboxType(String name, int isChecked){
super(name);
public checkboxType(String name, String description, int isChecked){
super(name, description);
this.default_value = isChecked;
}
@@ -50,6 +50,7 @@ public class checkboxType extends inputType {
public byte[] encode() throws ByteBuilder.buildingException {
ByteBuilder bb = new ByteBuilder();
bb.addString(name);
bb.addString(description);
bb.addInt((int)default_value);
return bb.build();
}
@@ -58,7 +59,8 @@ public class checkboxType extends inputType {
ArrayList<BuiltByteParser.parsedObject> objects = bbp.parse();
name = (String) objects.get(0).get();
default_value = objects.get(1).get();
description = (String) objects.get(1).get();
default_value = objects.get(2).get();
}
// public PowerSpinnerView dropdown = null;
@@ -68,7 +70,7 @@ public class checkboxType extends inputType {
public View createView(Context context, Function<dataType, Integer> onUpdate){
checkBox = new CheckBox(context);
checkBox.setText(name);
checkBox.setTextSize(24);
setViewValue(default_value);
checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
@@ -110,6 +112,7 @@ public class checkboxType extends inputType {
public void add_individual_view(LinearLayout parent, dataType data){
if(data.isNull()) return;
CheckBox cb = new CheckBox(parent.getContext());
cb.setTextAppearance(com.google.android.material.R.style.TextAppearance_MaterialComponents_Headline1);
cb.setText(name);
cb.setChecked((int) data.get() == 1);
cb.setEnabled(false);
@@ -42,8 +42,8 @@ public class dropdownType extends inputType {
public Object get_fallback_value(){return 0;}
public dropdownType(){};
public String get_type_name(){return "Dropdown";}
public dropdownType(String name, String[] text_options, int defaultSelIndex){
super(name);
public dropdownType(String name, String description, String[] text_options, int defaultSelIndex){
super(name, description);
this.text_options = text_options;
this.default_value = defaultSelIndex;
}
@@ -52,6 +52,7 @@ public class dropdownType extends inputType {
public byte[] encode() throws ByteBuilder.buildingException {
ByteBuilder bb = new ByteBuilder();
bb.addString(name);
bb.addString(description);
bb.addInt((int)default_value);
bb.addStringArray(text_options);
return bb.build();
@@ -61,8 +62,9 @@ public class dropdownType extends inputType {
ArrayList<BuiltByteParser.parsedObject> objects = bbp.parse();
name = (String) objects.get(0).get();
default_value = objects.get(1).get();
text_options = (String[]) objects.get(2).get();
description = (String) objects.get(1).get();
default_value = objects.get(2).get();
text_options = (String[]) objects.get(3).get();
}
public CustomSpinnerView dropdown = null;
@@ -73,7 +75,7 @@ public class dropdownType extends inputType {
ArrayList<String> iconSpinnerItems = new ArrayList<>(Arrays.asList(text_options));
dropdown.setTitle(name);
dropdown.setOptions(iconSpinnerItems);
dropdown.setOptions(iconSpinnerItems, (int) default_value);
onUpdate.apply(getViewValue());
dropdown.setOnClickListener((item, index) -> onUpdate.apply(getViewValue()));
@@ -40,8 +40,8 @@ public class fieldposType extends inputType {
public Object get_fallback_value(){return 0;}
public fieldposType(){}
public String get_type_name(){return "Field Pos";}
public fieldposType(String name, int[] default_value){
super(name);
public fieldposType(String name, String description, int[] default_value){
super(name, description);
this.default_value = default_value;
}
@@ -52,6 +52,7 @@ public class fieldposType extends inputType {
public byte[] encode() throws ByteBuilder.buildingException {
ByteBuilder bb = new ByteBuilder();
bb.addString(name);
bb.addString(description);
bb.addIntArray((int[]) default_value);
return bb.build();
}
@@ -61,8 +62,8 @@ public class fieldposType extends inputType {
ArrayList<BuiltByteParser.parsedObject> objects = bbp.parse();
name = (String) objects.get(0).get();
default_value = objects.get(1).get();
System.out.println("Defalt value!!!!!" + default_value);
description = (String) objects.get(1).get();
default_value = objects.get(2).get();
}
@@ -30,14 +30,16 @@ public abstract class inputType {
FIELDPOS
}
public String name;
public String description;
public Object default_value;
public abstract inputTypes getInputType();
public abstract dataType.valueTypes getValueType();
public abstract Object get_fallback_value();
public abstract int get_byte_id();
public inputType(){}
public inputType(String name){
public inputType(String name, String description){
this.name = name;
this.description = description;
}
public abstract String get_type_name();
@@ -36,8 +36,8 @@ public class numberType extends inputType {
public Object get_fallback_value(){return 0;}
public numberType(){}
public String get_type_name(){return "Number";}
public numberType(String name, int default_value){
super(name);
public numberType(String name, String description, int default_value){
super(name, description);
this.default_value = default_value;
}
@@ -48,6 +48,7 @@ public class numberType extends inputType {
public byte[] encode() throws ByteBuilder.buildingException {
ByteBuilder bb = new ByteBuilder();
bb.addString(name);
bb.addString(description);
bb.addInt((int)default_value);
return bb.build();
}
@@ -56,7 +57,8 @@ public class numberType extends inputType {
ArrayList<BuiltByteParser.parsedObject> objects = bbp.parse();
name = (String) objects.get(0).get();
default_value = objects.get(1).get();
description = (String) objects.get(1).get();
default_value = objects.get(2).get();
}
@@ -36,8 +36,8 @@ public class sliderType extends inputType {
public Object get_fallback_value(){return 0;}
public sliderType(){};
public String get_type_name(){return "Slider";}
public sliderType(String name, int defaultValue, int min, int max){
super(name);
public sliderType(String name, String description, int defaultValue, int min, int max){
super(name, description);
this.default_value = defaultValue;
this.min = min;
this.max = max;
@@ -49,6 +49,7 @@ public class sliderType extends inputType {
public byte[] encode() throws ByteBuilder.buildingException {
ByteBuilder bb = new ByteBuilder();
bb.addString(name);
bb.addString(description);
bb.addInt((int)default_value);
bb.addInt(min);
bb.addInt(max);
@@ -58,10 +59,11 @@ public class sliderType extends inputType {
BuiltByteParser bbp = new BuiltByteParser(bytes);
ArrayList<BuiltByteParser.parsedObject> objects = bbp.parse();
name = (String) objects.get(0).get();
default_value = objects.get(1).get();
min = (int) objects.get(2).get();
max = (int) objects.get(3).get();
name = (String) objects.get(0).get();
description = (String) objects.get(1).get();
default_value = objects.get(2).get();
min = (int) objects.get(3).get();
max = (int) objects.get(4).get();
}
@@ -32,8 +32,8 @@ public class tallyType extends inputType {
public Object get_fallback_value(){return 0;}
public tallyType(){}
public String get_type_name(){return "Tally";}
public tallyType(String name, int default_value){
super(name);
public tallyType(String name, String description, int default_value){
super(name, description);
this.default_value = default_value;
}
@@ -44,6 +44,7 @@ public class tallyType extends inputType {
public byte[] encode() throws ByteBuilder.buildingException {
ByteBuilder bb = new ByteBuilder();
bb.addString(name);
bb.addString(description);
bb.addInt((int)default_value);
return bb.build();
}
@@ -52,7 +53,8 @@ public class tallyType extends inputType {
ArrayList<BuiltByteParser.parsedObject> objects = bbp.parse();
name = (String) objects.get(0).get();
default_value = objects.get(1).get();
description = (String) objects.get(1).get();
default_value = objects.get(2).get();
}
@@ -35,8 +35,8 @@ public class textType extends inputType {
public dataType.valueTypes getValueType(){return dataType.valueTypes.STRING;}
public Object get_fallback_value(){return "<no-notes>";}
public textType(){}
public textType(String name, String default_text){
super(name);
public textType(String name, String description, String default_text){
super(name, description);
this.default_value = default_text;
}
public String get_type_name(){return "Text";}
@@ -50,6 +50,7 @@ public class textType extends inputType {
public byte[] encode() throws ByteBuilder.buildingException {
ByteBuilder bb = new ByteBuilder();
bb.addString(name);
bb.addString(description);
bb.addString((String) default_value);
return bb.build();
}
@@ -57,8 +58,9 @@ public class textType extends inputType {
BuiltByteParser bbp = new BuiltByteParser(bytes);
ArrayList<BuiltByteParser.parsedObject> objects = bbp.parse();
name = (String) objects.get(0).get();
default_value = objects.get(1).get();
name = (String) objects.get(0).get();
description = (String) objects.get(1).get();
default_value = objects.get(2).get();
}
@@ -1,56 +0,0 @@
package com.ridgebotics.ridgescout.ui;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.ridgebotics.ridgescout.R;
import java.util.List;
public class CustomSpinnerOptionsAdapter extends RecyclerView.Adapter<CustomSpinnerOptionsAdapter.ViewHolder> {
private List<String> options;
private OnItemClickListener listener;
public interface OnItemClickListener {
void onItemClick(String option);
}
public CustomSpinnerOptionsAdapter(List<String> options, OnItemClickListener listener) {
this.options = options;
this.listener = listener;
}
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.view_custom_spinner_option, parent, false);
return new ViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
String option = options.get(position);
holder.textView.setText(option);
holder.itemView.setOnClickListener(v -> listener.onItemClick(option));
}
@Override
public int getItemCount() {
return options.size();
}
static class ViewHolder extends RecyclerView.ViewHolder {
TextView textView;
ViewHolder(View itemView) {
super(itemView);
textView = itemView.findViewById(R.id.textView);
}
}
}
@@ -25,10 +25,6 @@ import java.util.ArrayList;
import java.util.List;
public class CustomSpinnerPopup extends TableLayout {
private List<String> options;
private OnOptionSelectedListener listener;
private RecyclerView recyclerView;
private CustomSpinnerOptionsAdapter adapter;
public CustomSpinnerPopup(Context context) {
super(context);
@@ -42,20 +38,17 @@ public class CustomSpinnerPopup extends TableLayout {
void onOptionSelected(String option);
}
// private int selectedIndex = -1;
// public void setValue()
public CustomSpinnerPopup init(List<String> options, OnOptionSelectedListener onOptionSelectedListener){
public CustomSpinnerPopup init(List<String> options, OnOptionSelectedListener onOptionSelectedListener, int defaultOption){
CheckBox[] checkBoxes = new CheckBox[options.size()];
setPadding(16, 16, 16, 16);
for(int i = 0; i < options.size(); i++){
final CheckBox cb = new CheckBox(getContext());
cb.setText(options.get(i));
cb.setTextAppearance(com.google.android.material.R.style.TextAppearance_MaterialComponents_Headline5);
cb.setChecked(i == defaultOption);
addView(new MaterialDivider(getContext()));
// cb.margin
if(i > 0)
addView(new MaterialDivider(getContext()));
addView(cb);
checkBoxes[i] = cb;
@@ -66,8 +59,6 @@ public class CustomSpinnerPopup extends TableLayout {
for (CheckBox checkBox : checkBoxes)
checkBox.setChecked(false);
cb.setChecked(true);
});
}
@@ -119,9 +110,6 @@ public class CustomSpinnerPopup extends TableLayout {
// return view;
// }
//
public void setOnOptionSelectedListener(OnOptionSelectedListener listener) {
this.listener = listener;
}
@@ -39,10 +39,7 @@ public class CustomSpinnerView extends LinearLayout {
init(context);
}
private ViewCustomSpinnerBinding binding;
private List<String> options;
private CustomSpinnerPopup dialog;
private onClickListener onClickListener;
private TextView title;
@@ -61,9 +58,17 @@ public class CustomSpinnerView extends LinearLayout {
this.onClickListener = listener;
}
public void setOptions(List<String> options){
public void setOptions(List<String> options, String defaultOption){
setOptions(options, options.indexOf(defaultOption));
}
public void setOptions(List<String> options, int defaultOption){
this.options = options;
// dialog = CustomSpinnerPopup.newInstance(options);
this.index = defaultOption;
if(defaultOption != -1)
this.item.setText(options.get(defaultOption));
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
@@ -76,7 +81,7 @@ public class CustomSpinnerView extends LinearLayout {
onClickListener.onClick(option, options.indexOf(option));
index = options.indexOf(option);
}
});
}, index);
popup.setLayoutDirection(0);
builder.setView(popup);
AlertDialog dialog = builder.create();
@@ -96,10 +101,12 @@ public class CustomSpinnerView extends LinearLayout {
public void setOption(String option) {
item.setText(option);
index = options.indexOf(option);
}
public void setOption(int index) {
setOption(options.get(index));
item.setText(options.get(index));
this.index = index;
}
public int getIndex(){
@@ -0,0 +1,88 @@
package com.ridgebotics.ridgescout.ui;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout;
import com.ridgebotics.ridgescout.R;
public class ToggleTitleView extends ConstraintLayout {
public ToggleTitleView(@NonNull Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
init(context);
}
public ToggleTitleView(@NonNull Context context) {
super(context);
init(context);
}
public interface OnToggleListener {
void onToggle(boolean enabled);
}
TextView titleView;
CheckBox toggle_title_checkbox;
TextView toggle_title_description;
OnToggleListener onToggleListener;
private static final int default_text_color = 0xffffffff;
public void init(Context context){
LayoutInflater.from(context).inflate(R.layout.view_toggle_title, this, true);
titleView = findViewById(R.id.toggle_title);
toggle_title_checkbox = findViewById(R.id.toggle_title_checkbox);
toggle_title_description = findViewById(R.id.toggle_title_description);
toggle_title_checkbox.setOnCheckedChangeListener((compoundButton, checked) -> {
if(checked)
enable();
else
disable();
onToggleListener.onToggle(!checked);
});
}
public void setTitle(String title){
titleView.setText(title);
}
public void setDescription(String description){
toggle_title_description.setText(description);
}
public void setOnToggleListener(OnToggleListener onToggleListener){
this.onToggleListener = onToggleListener;
}
public boolean enabled = true;
public boolean isEnabled(){return enabled;}
public void disable(){
enabled = false;
toggle_title_checkbox.setChecked(false);
toggle_title_description.setVisibility(View.GONE);
setBackgroundColor(0xffff0000);
titleView.setTextColor(0xff000000);
}
public void enable(){
enabled = true;
toggle_title_checkbox.setChecked(true);
toggle_title_description.setVisibility(View.VISIBLE);
setBackgroundColor(0x00000000);
titleView.setTextAppearance(com.google.android.material.R.style.TextAppearance_MaterialComponents_Headline5);
// titleView.setTextAppearance(com.google.android.material.R.style.TextAppearance_MaterialComponents_Headline5);
}
}
@@ -68,27 +68,34 @@ public class FieldEditorHelper {
// }
public static final parameterType[] defaultSliderParams = new parameterType[]{
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("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("Description", ""),
new paramString("Default Value", "")
};
public static final parameterType[] defaultTallyParams = new parameterType[]{
new paramString("Description", ""),
new paramNumber("Default Value", 0)
};
public static final parameterType[] defaultNumberParams = new parameterType[]{
new paramString("Description", ""),
new paramNumber("Default Value", 0)
};
public static final parameterType[] defaultCheckboxParam = new parameterType[]{
new paramString("Description", ""),
new paramNumber("Default Value ( 1 or 0 )", 0)
};
public static final parameterType[] defaultFieldPosParam = new parameterType[]{
new paramString("Description", ""),
new paramNumber("Default X", 0),
new paramNumber("Default Y", 0)
};
@@ -96,6 +103,7 @@ public class FieldEditorHelper {
private static parameterType[] getSliderParams(sliderType s){
return new parameterType[]{
new paramString("Description", s.description),
new paramNumber("Min", s.min),
new paramNumber("Max", s.max),
new paramNumber("Default Value", (int) s.default_value)
@@ -104,6 +112,7 @@ public class FieldEditorHelper {
private static parameterType[] getDropdownParams(dropdownType s){
return new parameterType[]{
new paramString("Description", s.description),
new paramStringArray("Default Value",s.text_options),
new paramNumber("Default Option", (int) s.default_value),
};
@@ -111,30 +120,35 @@ public class FieldEditorHelper {
private static parameterType[] getTextParams(textType s){
return new parameterType[]{
new paramString("Description", s.description),
new paramString("Default Value", (String) s.default_value)
};
}
private static parameterType[] getTallyParams(tallyType s){
return new parameterType[]{
new paramString("Description", s.description),
new paramNumber("Default Value", (int) s.default_value)
};
}
private static parameterType[] getNumberParams(numberType s){
return new parameterType[]{
new paramString("Description", s.description),
new paramNumber("Default Value", (int) s.default_value)
};
}
private static parameterType[] getCheckboxParam(checkboxType s){
return new parameterType[]{
new paramString("Description", s.description),
new paramNumber("Default Value ( 1 or 0 )", (int) s.default_value)
};
}
private static parameterType[] getFieldPosParam(fieldposType s){
return new parameterType[]{
new paramString("Description", s.description),
new paramNumber("Default X", ((int[]) s.default_value)[0]),
new paramNumber("Default Y", ((int[]) s.default_value)[1])
};
@@ -143,36 +157,43 @@ public class FieldEditorHelper {
public static void setSliderParams(sliderType s, parameterType[] types){
s.min = ((paramNumber) types[0]).val;
s.max = ((paramNumber) types[1]).val;
s.default_value = ((paramNumber) types[2]).val;
s.description = ((paramString) types[0]).val;
s.min = ((paramNumber) types[1]).val;
s.max = ((paramNumber) types[2]).val;
s.default_value = ((paramNumber) types[3]).val;
}
public static void setDropdownParams(dropdownType s, parameterType[] types){
s.text_options = ((paramStringArray) types[0]).val;
s.default_value = ((paramNumber) types[1]).val;
s.description = ((paramString) types[0]).val;
s.text_options = ((paramStringArray) types[1]).val;
s.default_value = ((paramNumber) types[2]).val;
}
public static void setTextParams(textType s, parameterType[] types){
s.default_value = ((paramString) types[0]).val;
s.description = ((paramString) types[0]).val;
s.default_value = ((paramString) types[1]).val;
}
public static void setTallyParams(tallyType s, parameterType[] types){
s.default_value = ((paramNumber) types[0]).val;
s.description = ((paramString) types[0]).val;
s.default_value = ((paramNumber) types[1]).val;
}
public static void setNumberParams(numberType s, parameterType[] types){
s.default_value = ((paramNumber) types[0]).val;
s.description = ((paramString) types[0]).val;
s.default_value = ((paramNumber) types[1]).val;
}
public static void setCheckboxParam(checkboxType s, parameterType[] types){
s.default_value = ((paramNumber) types[0]).val;
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;
s.default_value = new int[]{
((paramNumber) types[0]).val,
((paramNumber) types[1]).val
((paramNumber) types[1]).val,
((paramNumber) types[2]).val
};
}
@@ -411,9 +411,8 @@ public class FieldsFragment extends Fragment {
options.add("Checkbox");
options.add("Field Position");
dropdown.setOptions(options);
dropdown.setOptions(options, 0);
dropdown.setTitle("Type");
dropdown.setOption(0);
builder.setView(dropdown);
@@ -22,6 +22,7 @@ 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.databinding.FragmentDataTeamsBinding;
@@ -78,48 +79,23 @@ public class TeamsFragment extends Fragment {
// PowerSpinnerView dropdown = new PowerSpinnerView(getContext());
//
// List<IconSpinnerItem> iconSpinnerItems = new ArrayList<>();
//
// iconSpinnerItems.add(new IconSpinnerItem("Individual"));
// iconSpinnerItems.add(new IconSpinnerItem("Compiled"));
// iconSpinnerItems.add(new IconSpinnerItem("History"));
//
// IconSpinnerAdapter iconSpinnerAdapter = new IconSpinnerAdapter(dropdown);
// dropdown.setSpinnerAdapter(iconSpinnerAdapter);
// dropdown.setItems(iconSpinnerItems);
//
// dropdown.selectItemByIndex(0);
//
// dropdown.setPadding(10,20,10,20);
// dropdown.setBackgroundColor(0xf0000000);
// dropdown.setTextColor(0xff00ff00);
// dropdown.setTextSize(15);
// dropdown.setArrowGravity(SpinnerGravity.END);
// dropdown.setArrowPadding(8);
//// dropdown.setSpinnerItemHeight(46);
// dropdown.setSpinnerPopupElevation(14);
//
//
// dropdown.selectItemByIndex(mode);
//
//
// dropdown.setOnSpinnerItemSelectedListener(new OnSpinnerItemSelectedListener<IconSpinnerItem>() {
// @Override
// public void onItemSelected(int oldIndex, @Nullable IconSpinnerItem oldItem, int newIndex,
// IconSpinnerItem newItem) {
//
// settingsManager.setDataMode(newIndex);
// loadTeam(newIndex);
// }
// });
//
// ll.addView(dropdown);
CustomSpinnerView dropdown = new CustomSpinnerView(getContext());
dropdown.setTitle("Data Mode");
List<String> options = new ArrayList<>();
options.add("Individual");
options.add("Compiled");
options.add("History");
dropdown.setOptions(options, mode);
dropdown.setOnClickListener((item, index) -> {
System.out.println(index);
settingsManager.setDataMode(index);
loadTeam(index);
});
ll.addView(dropdown);
@@ -14,7 +14,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.ridgebotics.ridgescout.databinding.FragmentScoutingStatusBinding;
import com.ridgebotics.ridgescout.databinding.FragmentScoutingEventBinding;
import com.ridgebotics.ridgescout.utility.DataManager;
import com.ridgebotics.ridgescout.utility.fileEditor;
import com.ridgebotics.ridgescout.types.frcEvent;
@@ -22,13 +22,13 @@ import com.ridgebotics.ridgescout.types.frcMatch;
import java.util.Arrays;
public class StatusFragment extends Fragment {
FragmentScoutingStatusBinding binding;
public class EventFragment extends Fragment {
FragmentScoutingEventBinding binding;
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
binding = FragmentScoutingStatusBinding.inflate(inflater, container, false);
binding = FragmentScoutingEventBinding.inflate(inflater, container, false);
DataManager.reload_event();
binding.matchTable.removeAllViews();
@@ -56,7 +56,7 @@ public class StatusFragment extends Fragment {
ViewGroup.LayoutParams.WRAP_CONTENT
));
tv.setGravity(Gravity.CENTER_HORIZONTAL);
tv.setText("Pit Scouting");
tv.setText("Teams");
tv.setTextSize(28);
binding.matchTable.addView(tv);
@@ -104,7 +104,7 @@ public class StatusFragment extends Fragment {
ViewGroup.LayoutParams.WRAP_CONTENT
));
tv.setGravity(Gravity.CENTER_HORIZONTAL);
tv.setText("Match Scouting");
tv.setText("Matches");
tv.setTextSize(28);
binding.matchTable.addView(tv);
@@ -14,6 +14,8 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.google.android.material.divider.MaterialDivider;
import com.ridgebotics.ridgescout.ui.ToggleTitleView;
import com.ridgebotics.ridgescout.utility.settingsManager;
import com.ridgebotics.ridgescout.databinding.FragmentScoutingMatchBinding;
import com.ridgebotics.ridgescout.scoutingData.ScoutingDataWriter;
@@ -137,7 +139,7 @@ public class MatchScoutingFragment extends Fragment {
boolean edited = false;
TextView[] titles;
ToggleTitleView[] titles;
AutoSaveManager asm = new AutoSaveManager(this::save);
@@ -186,17 +188,22 @@ public class MatchScoutingFragment extends Fragment {
asm.stop();
}
titles = new TextView[DataManager.match_latest_values.length];
titles = new ToggleTitleView[DataManager.match_latest_values.length];
for(int i = 0 ; i < DataManager.match_latest_values.length; i++) {
final TextView tv = new TextView(getContext());
tv.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
tv.setText(DataManager.match_latest_values[i].name);
tv.setPadding(8,8,8,8);
tv.setTextSize(24);
titles[i] = tv;
binding.MatchScoutArea.addView(new MaterialDivider(getContext()));
final ToggleTitleView ttv = new ToggleTitleView(getContext());
ttv.setTitle(DataManager.match_latest_values[i].name);
ttv.setDescription(DataManager.match_latest_values[i].description);
// final TextView tv = new TextView(getContext());
// tv.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
// tv.setText(DataManager.match_latest_values[i].name);
// tv.setPadding(8,8,8,8);
// tv.setTextSize(24);
titles[i] = ttv;
default_text_color = tv.getCurrentTextColor();
final View v = DataManager.match_latest_values[i].createView(getContext(), dataType -> {
// edited = true;
@@ -205,26 +212,27 @@ public class MatchScoutingFragment extends Fragment {
return 0;
});
binding.MatchScoutArea.addView(tv);
binding.MatchScoutArea.addView(ttv);
int fi = i;
tv.setOnClickListener(p -> {
// boolean blank = !latest_values[fi].getViewValue().isNull();
// System.out.println(blank);
ttv.setOnToggleListener(enabled -> {
if(asm.isRunning)
update_asm();
if(!DataManager.match_latest_values[fi].isBlank){
tv.setBackgroundColor(0xffff0000);
tv.setTextColor(0xff000000);
if(enabled){
DataManager.match_latest_values[fi].nullify();
}else{
tv.setBackgroundColor(0x00000000);
tv.setTextColor(default_text_color);
DataManager.match_latest_values[fi].setViewValue(DataManager.match_latest_values[fi].default_value);
}
});
ttv.setOnClickListener(p -> {
// boolean blank = !latest_values[fi].getViewValue().isNull();
// System.out.println(blank);
});
binding.MatchScoutArea.addView(v);
}
}
@@ -328,8 +336,7 @@ public class MatchScoutingFragment extends Fragment {
inputType input = DataManager.match_latest_values[i];
input.setViewValue(input.default_value);
titles[i].setBackgroundColor(0x00000000);
titles[i].setTextColor(default_text_color);
titles[i].enable();
}
}
@@ -351,11 +358,9 @@ public class MatchScoutingFragment extends Fragment {
if(DataManager.match_latest_values[i].isBlank){
titles[i].setBackgroundColor(0xffff0000);
titles[i].setTextColor(0xff000000);
titles[i].disable();
}else{
titles[i].setBackgroundColor(0x00000000);
titles[i].setTextColor(default_text_color);
titles[i].enable();
}
}
}
@@ -15,6 +15,8 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.google.android.material.divider.MaterialDivider;
import com.ridgebotics.ridgescout.ui.ToggleTitleView;
import com.ridgebotics.ridgescout.utility.AlertManager;
import com.ridgebotics.ridgescout.utility.settingsManager;
import com.ridgebotics.ridgescout.databinding.FragmentScoutingPitBinding;
@@ -59,7 +61,7 @@ public class PitScoutingFragment extends Fragment {
String filename;
String username;
TextView[] titles;
ToggleTitleView[] titles;
AutoSaveManager asm = new AutoSaveManager(this::save);
@@ -133,38 +135,31 @@ public class PitScoutingFragment extends Fragment {
}
private int default_text_color = 0;
private void create_fields() {
if(asm.isRunning){
asm.stop();
}
titles = new TextView[pit_latest_values.length];
titles = new ToggleTitleView[pit_latest_values.length];
for(int i = 0 ; i < pit_latest_values.length; i++) {
TextView tv = new TextView(getContext());
tv.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
tv.setText(pit_latest_values[i].name);
tv.setTextSize(24);
tv.setPadding(8,8,8,8);
titles[i] = tv;
binding.pitScoutArea.addView(tv);
binding.pitScoutArea.addView(new MaterialDivider(getContext()));
ToggleTitleView ttv = new ToggleTitleView(getContext());
ttv.setTitle(pit_latest_values[i].name);
ttv.setDescription(pit_latest_values[i].description);
titles[i] = ttv;
binding.pitScoutArea.addView(ttv);
default_text_color = tv.getCurrentTextColor();
int fi = i;
tv.setOnClickListener(p -> {
ttv.setOnToggleListener(enabled -> {
update_asm();
if(!pit_latest_values[fi].isBlank){
tv.setBackgroundColor(0xffff0000);
tv.setTextColor(0xff000000);
if(enabled){
pit_latest_values[fi].nullify();
}else{
tv.setBackgroundColor(0x00000000);
tv.setTextColor(default_text_color);
pit_latest_values[fi].setViewValue(pit_latest_values[fi].default_value);
}
});
@@ -187,9 +182,7 @@ public class PitScoutingFragment extends Fragment {
for(int i = 0; i < pit_latest_values.length; i++){
inputType input = pit_latest_values[i];
input.setViewValue(input.default_value);
titles[i].setBackgroundColor(0x00000000);
titles[i].setTextColor(default_text_color);
titles[i].enable();
}
}
@@ -199,15 +192,12 @@ public class PitScoutingFragment extends Fragment {
dataType[] types = psdr.data.array;
for(int i = 0; i < pit_latest_values.length; i++){
// types[i] = latest_values[i].getViewValue();
pit_latest_values[i].setViewValue(types[i]);
if(pit_latest_values[i].isBlank){
titles[i].setBackgroundColor(0xffff0000);
titles[i].setTextColor(0xff000000);
titles[i].disable();
}else{
titles[i].setBackgroundColor(0x00000000);
titles[i].setTextColor(default_text_color);
titles[i].enable();
}
}
}
@@ -16,7 +16,6 @@ import androidx.annotation.Nullable;
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.databinding.FragmentScoutingBinding;
import com.ridgebotics.ridgescout.types.frcTeam;
@@ -43,7 +42,7 @@ public class ScoutingFragment extends Fragment {
binding.noEventError.setVisibility(View.VISIBLE);
binding.matchScoutingButton.setEnabled(false);
binding.pitScoutingButton.setEnabled(false);
binding.statusButton.setEnabled(false);
binding.eventButton.setEnabled(false);
is_main_page = false;
return binding.getRoot();
}
@@ -64,8 +63,8 @@ public class ScoutingFragment extends Fragment {
findNavController(this).navigate(R.id.action_navigation_scouting_to_navigation_team_selector);
});
binding.statusButton.setOnClickListener(v -> {
findNavController(this).navigate(R.id.action_navigation_scouting_to_navigation_scouting_status);
binding.eventButton.setOnClickListener(v -> {
findNavController(this).navigate(R.id.action_navigation_scouting_to_navigation_scouting_event);
});
return binding.getRoot();
@@ -81,23 +80,17 @@ public class ScoutingFragment extends Fragment {
getView().setFocusableInTouchMode(true);
getView().requestFocus();
getView().setOnKeyListener(new View.OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
getView().setOnKeyListener((v, keyCode, event) -> {
if (event.getAction() == KeyEvent.ACTION_UP
&& keyCode == KeyEvent.KEYCODE_BACK
&& !is_main_page){
if (event.getAction() == KeyEvent.ACTION_UP
&& keyCode == KeyEvent.KEYCODE_BACK
&& !is_main_page){
// binding.buttons.setVisibility(View.VISIBLE);
// binding.matchScoutingView.setVisibility(View.GONE);
// binding.pitScoutingView.setVisibility(View.GONE);
is_main_page = true;
is_main_page = true;
return true;
}
return false;
return true;
}
return false;
});
}
@@ -250,7 +250,7 @@ public class settingsFragment extends Fragment {
ArrayList<String> optionsList = new ArrayList<>(Arrays.asList(options));
dropdown.setTitle(getTitle());
dropdown.setOptions(optionsList);
dropdown.setOptions(optionsList, getValue());
dropdown.setOption(getValue());
dropdown.setOnClickListener((item, index) -> {
@@ -36,13 +36,13 @@ import java.util.Comparator;
import java.util.Date;
public class TBAFragment extends Fragment {
private final String TBAAddress = "https://www.thebluealliance.com/api/v3/";
private final String TBAHeader = "X-TBA-Auth-Key: tjEKSZojAU2pgbs2mBt06SKyOakVhLutj3NwuxLTxPKQPLih11aCIwRIVFXKzY4e";
private static final String TBAAddress = "https://www.thebluealliance.com/api/v3/";
private static final String TBAHeader = "X-TBA-Auth-Key: tjEKSZojAU2pgbs2mBt06SKyOakVhLutj3NwuxLTxPKQPLih11aCIwRIVFXKzY4e";
private android.widget.TableLayout Table;
private FragmentTransferTbaBinding binding;
private static final int year = settingsManager.getYearNum();
private final int year = settingsManager.getYearNum();
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
@@ -30,17 +30,25 @@ public class DataManager {
public static inputType[] match_latest_values;
public static transferType[][] match_transferValues;
public static void reload_match_fields(){
match_values = fields.load(fields.matchFieldsFilename);
match_latest_values = match_values[match_values.length-1];
match_transferValues = transferType.get_transfer_values(match_values);
try {
match_values = fields.load(fields.matchFieldsFilename);
match_latest_values = match_values[match_values.length - 1];
match_transferValues = transferType.get_transfer_values(match_values);
} catch (Exception e){
AlertManager.error(e);
}
}
public static inputType[][] pit_values;
public static inputType[] pit_latest_values;
public static transferType[][] pit_transferValues;
public static void reload_pit_fields(){
pit_values = fields.load(fields.pitsFieldsFilename);
pit_latest_values = pit_values[pit_values.length-1];
pit_transferValues = transferType.get_transfer_values(pit_values);
try {
pit_values = fields.load(fields.pitsFieldsFilename);
pit_latest_values = pit_values[pit_values.length-1];
pit_transferValues = transferType.get_transfer_values(pit_values);
} catch (Exception e){
AlertManager.error(e);
}
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 570 B

After

Width:  |  Height:  |  Size: 997 B

@@ -50,21 +50,21 @@
android:layout_height="wrap_content"
android:text="@string/pit_n_scouting"
android:textSize="34sp"
app:layout_constraintBottom_toTopOf="@id/status_button"
app:layout_constraintBottom_toTopOf="@id/event_button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/matchScoutingButton" />
<Button
android:id="@+id/status_button"
android:id="@+id/event_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Status"
android:text="event"
android:textSize="34sp"
app:layout_constraintTop_toBottomOf="@+id/pitScoutingButton"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/pitScoutingButton"
app:layout_constraintVertical_bias="0.307" />
@@ -1,19 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="8dp"
android:layout_marginVertical="4dp"
app:cardCornerRadius="8dp"
app:cardElevation="2dp">
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:padding="16dp"
android:textSize="16sp" />
</com.google.android.material.card.MaterialCardView>
@@ -1,25 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.MaterialComponents.Dark.ActionBar"
app:titleTextColor="@android:color/white" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:clipToPadding="false"
android:padding="8dp" />
</LinearLayout>
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/toggle_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:textAlignment="center"
android:textAppearance="@style/TextAppearance.MaterialComponents.Headline5"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<CheckBox
android:id="@+id/toggle_title_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/toggle_title_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Description"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/toggle_title"
android:textAppearance="@style/TextAppearance.MaterialComponents.Caption"/>
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -25,7 +25,7 @@
app:popEnterAnim="@anim/enter_anim"
app:popExitAnim="@anim/pop_exit_anim" />
<action
android:id="@+id/action_navigation_scouting_to_navigation_scouting_status"
android:id="@+id/action_navigation_scouting_to_navigation_scouting_event"
app:destination="@id/navigation_scouting_status"
app:enterAnim="@anim/enter_anim"
app:exitAnim="@anim/exit_anim"
@@ -92,8 +92,8 @@
<fragment
android:id="@+id/navigation_scouting_status"
android:name="com.ridgebotics.ridgescout.ui.scouting.StatusFragment"
tools:layout="@layout/fragment_scouting_status">
android:name="com.ridgebotics.ridgescout.ui.scouting.EventFragment"
tools:layout="@layout/fragment_scouting_event">
</fragment>
<fragment