mirror of
https://github.com/Team4388/RidgeScout.git
synced 2026-06-08 16:28:00 -06:00
Add TextViewBuilder.java
This commit is contained in:
@@ -29,6 +29,7 @@ import com.github.mikephil.charting.data.LineDataSet;
|
|||||||
import com.github.mikephil.charting.data.PieData;
|
import com.github.mikephil.charting.data.PieData;
|
||||||
import com.github.mikephil.charting.data.PieDataSet;
|
import com.github.mikephil.charting.data.PieDataSet;
|
||||||
import com.github.mikephil.charting.data.PieEntry;
|
import com.github.mikephil.charting.data.PieEntry;
|
||||||
|
import com.ridgebotics.ridgescout.utility.builders.TextViewBuilder;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -105,16 +106,14 @@ public class DropdownType extends FieldType {
|
|||||||
|
|
||||||
public void add_individual_view(LinearLayout parent, RawDataType data){
|
public void add_individual_view(LinearLayout parent, RawDataType data){
|
||||||
if(data.isNull()) return;
|
if(data.isNull()) return;
|
||||||
TextView tv = new TextView(parent.getContext());
|
|
||||||
tv.setLayoutParams(new FrameLayout.LayoutParams(
|
parent.addView(
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
new TextViewBuilder(parent.getContext(), text_options[(int) data.get()])
|
||||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
.layout_match_wrap()
|
||||||
));
|
.padding(20)
|
||||||
tv.setPadding(20,20,20,20);
|
.size(18)
|
||||||
tv.setGravity(Gravity.CENTER_HORIZONTAL);
|
.align_center()
|
||||||
tv.setText(text_options[(int) data.get()]);
|
.build());
|
||||||
tv.setTextSize(18);
|
|
||||||
parent.addView(tv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import com.ridgebotics.ridgescout.types.data.RawDataType;
|
|||||||
import com.ridgebotics.ridgescout.types.data.IntType;
|
import com.ridgebotics.ridgescout.types.data.IntType;
|
||||||
import com.ridgebotics.ridgescout.utility.BuiltByteParser;
|
import com.ridgebotics.ridgescout.utility.BuiltByteParser;
|
||||||
import com.ridgebotics.ridgescout.utility.ByteBuilder;
|
import com.ridgebotics.ridgescout.utility.ByteBuilder;
|
||||||
|
import com.ridgebotics.ridgescout.utility.builders.TextViewBuilder;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -118,16 +119,11 @@ public class NumberType extends FieldType {
|
|||||||
|
|
||||||
public void add_individual_view(LinearLayout parent, RawDataType data){
|
public void add_individual_view(LinearLayout parent, RawDataType data){
|
||||||
if(data.isNull()) return;
|
if(data.isNull()) return;
|
||||||
|
parent.addView(new TextViewBuilder(parent.getContext(), String.valueOf((int) data.get()))
|
||||||
TextView tv = new TextView(parent.getContext());
|
.layout_match_wrap()
|
||||||
tv.setLayoutParams(new FrameLayout.LayoutParams(
|
.align_center()
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
.size(24)
|
||||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
.build());
|
||||||
));
|
|
||||||
tv.setGravity(Gravity.CENTER_HORIZONTAL);
|
|
||||||
tv.setText(String.valueOf((int) data.get()));
|
|
||||||
tv.setTextSize(24);
|
|
||||||
parent.addView(tv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import com.github.mikephil.charting.components.Legend;
|
|||||||
import com.github.mikephil.charting.data.Entry;
|
import com.github.mikephil.charting.data.Entry;
|
||||||
import com.github.mikephil.charting.data.LineData;
|
import com.github.mikephil.charting.data.LineData;
|
||||||
import com.github.mikephil.charting.data.LineDataSet;
|
import com.github.mikephil.charting.data.LineDataSet;
|
||||||
|
import com.ridgebotics.ridgescout.utility.builders.TextViewBuilder;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -103,16 +104,11 @@ public class TallyType extends FieldType {
|
|||||||
|
|
||||||
public void add_individual_view(LinearLayout parent, RawDataType data){
|
public void add_individual_view(LinearLayout parent, RawDataType data){
|
||||||
if(data.isNull()) return;
|
if(data.isNull()) return;
|
||||||
|
parent.addView(new TextViewBuilder(parent.getContext(), String.valueOf((int) data.get()))
|
||||||
TextView tv = new TextView(parent.getContext());
|
.layout_match_wrap()
|
||||||
tv.setLayoutParams(new FrameLayout.LayoutParams(
|
.align_center()
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
.size(24)
|
||||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
.build());
|
||||||
));
|
|
||||||
tv.setGravity(Gravity.CENTER_HORIZONTAL);
|
|
||||||
tv.setText(String.valueOf((int) data.get()));
|
|
||||||
tv.setTextSize(24);
|
|
||||||
parent.addView(tv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -344,16 +340,12 @@ public class TallyType extends FieldType {
|
|||||||
row = new TableRow(parent.getContext());
|
row = new TableRow(parent.getContext());
|
||||||
CandlestickView view = views.get(i);
|
CandlestickView view = views.get(i);
|
||||||
|
|
||||||
TextView teamNum = new TextView(parent.getContext());
|
row.addView(new TextViewBuilder(parent.getContext(), String.valueOf(view.teamNum))
|
||||||
TableRow.LayoutParams params = new TableRow.LayoutParams();
|
.align_center()
|
||||||
params.gravity = Gravity.CENTER;
|
.padding(10)
|
||||||
teamNum.setLayoutParams(params);
|
.h6()
|
||||||
teamNum.setPadding(10,10,10,10);
|
.build());
|
||||||
teamNum.setTextAppearance(com.google.android.material.R.style.TextAppearance_MaterialComponents_Headline6);
|
|
||||||
teamNum.setText(String.valueOf(view.teamNum));
|
|
||||||
|
|
||||||
|
|
||||||
row.addView(teamNum);
|
|
||||||
row.addView(view);
|
row.addView(view);
|
||||||
|
|
||||||
parent.addView(row);
|
parent.addView(row);
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import com.github.mikephil.charting.components.Legend;
|
|||||||
import com.github.mikephil.charting.data.Entry;
|
import com.github.mikephil.charting.data.Entry;
|
||||||
import com.github.mikephil.charting.data.LineData;
|
import com.github.mikephil.charting.data.LineData;
|
||||||
import com.github.mikephil.charting.data.LineDataSet;
|
import com.github.mikephil.charting.data.LineDataSet;
|
||||||
|
import com.ridgebotics.ridgescout.utility.builders.TextViewBuilder;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -112,15 +113,11 @@ public class TextType extends FieldType {
|
|||||||
|
|
||||||
public void add_individual_view(LinearLayout parent, RawDataType data){
|
public void add_individual_view(LinearLayout parent, RawDataType data){
|
||||||
if(data.isNull()) return;
|
if(data.isNull()) return;
|
||||||
TextView tv = new TextView(parent.getContext());
|
parent.addView(new TextViewBuilder(parent.getContext(), (String) data.get())
|
||||||
tv.setLayoutParams(new FrameLayout.LayoutParams(
|
.layout_match_wrap()
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
.align_center()
|
||||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
.size(18)
|
||||||
));
|
.build());
|
||||||
tv.setGravity(Gravity.CENTER_HORIZONTAL);
|
|
||||||
tv.setText((String) data.get());
|
|
||||||
tv.setTextSize(18);
|
|
||||||
parent.addView(tv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -144,25 +141,20 @@ public class TextType extends FieldType {
|
|||||||
positive_mean = 0;
|
positive_mean = 0;
|
||||||
count = 0;
|
count = 0;
|
||||||
|
|
||||||
positive_text = new TextView(parent.getContext());
|
positive_text = new TextViewBuilder(parent.getContext())
|
||||||
positive_text.setLayoutParams(new FrameLayout.LayoutParams(
|
.align_center()
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
.size(20)
|
||||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
.build();
|
||||||
));
|
|
||||||
positive_text.setGravity(Gravity.CENTER_HORIZONTAL);
|
|
||||||
positive_text.setTextSize(20);
|
|
||||||
parent.addView(positive_text);
|
parent.addView(positive_text);
|
||||||
|
|
||||||
for (int i = 0; i < data.length; i++){
|
for (int i = 0; i < data.length; i++){
|
||||||
if (!data[i].isNull()) {
|
if (!data[i].isNull()) {
|
||||||
SentimentAnalysis.analyse((String) data[i].get(), new SentimentAnalysis.resultCallback() {
|
SentimentAnalysis.analyse((String) data[i].get(), sentiment -> {
|
||||||
@Override
|
positive_mean += sentiment;
|
||||||
public void onFinish(float sentiment) {
|
count++;
|
||||||
positive_mean += sentiment;
|
|
||||||
count++;
|
|
||||||
|
|
||||||
positive_text.setText("Sentiment: " + (positive_mean / count));
|
positive_text.setText("Sentiment: " + (positive_mean / count));
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import com.ridgebotics.ridgescout.types.data.RawDataType;
|
|||||||
import com.ridgebotics.ridgescout.types.frcTeam;
|
import com.ridgebotics.ridgescout.types.frcTeam;
|
||||||
import com.ridgebotics.ridgescout.utility.DataManager;
|
import com.ridgebotics.ridgescout.utility.DataManager;
|
||||||
import com.ridgebotics.ridgescout.utility.FileEditor;
|
import com.ridgebotics.ridgescout.utility.FileEditor;
|
||||||
|
import com.ridgebotics.ridgescout.utility.builders.TextViewBuilder;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -119,49 +120,34 @@ public class TeamsFragment extends Fragment {
|
|||||||
// ll.addView(new MaterialDivider(getContext()));
|
// ll.addView(new MaterialDivider(getContext()));
|
||||||
|
|
||||||
if(!FileEditor.fileExist(filename)){
|
if(!FileEditor.fileExist(filename)){
|
||||||
TextView tv = new TextView(getContext());
|
binding.pitArea.addView(new TextViewBuilder(getContext(), "No pit data has been collected!")
|
||||||
tv.setLayoutParams(new FrameLayout.LayoutParams(
|
.layout_match_wrap().align_center().size(23).build());
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
|
||||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
|
||||||
));
|
|
||||||
tv.setGravity(Gravity.CENTER_HORIZONTAL);
|
|
||||||
tv.setText("No pit data has been collected!");
|
|
||||||
tv.setTextSize(23);
|
|
||||||
binding.pitArea.addView(tv);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ScoutingDataWriter.ParsedScoutingDataResult psda = ScoutingDataWriter.load(filename, pit_values, pit_transferValues);
|
ScoutingDataWriter.ParsedScoutingDataResult psda = ScoutingDataWriter.load(filename, pit_values, pit_transferValues);
|
||||||
|
|
||||||
TextView tv = new TextView(getContext());
|
|
||||||
tv.setLayoutParams(new FrameLayout.LayoutParams(
|
binding.pitArea.addView(new TextViewBuilder(getContext(), "Pit scouting by " + psda.username)
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
.layout_match_wrap()
|
||||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
.padding(0, 20, 0, 5)
|
||||||
));
|
.align_center()
|
||||||
tv.setPadding(0, 20, 0, 5);
|
.size(30)
|
||||||
tv.setGravity(Gravity.CENTER_HORIZONTAL);
|
.build()
|
||||||
tv.setText("Pit scouting by " + psda.username);
|
);
|
||||||
tv.setTextSize(30);
|
|
||||||
binding.pitArea.addView(tv);
|
|
||||||
|
|
||||||
for (int a = 0; a < psda.data.array.length; a++) {
|
for (int a = 0; a < psda.data.array.length; a++) {
|
||||||
tv = new TextView(getContext());
|
TextViewBuilder tvb = new TextViewBuilder(getContext(), pit_latest_values[a].name)
|
||||||
tv.setLayoutParams(new FrameLayout.LayoutParams(
|
.align_center()
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
.layout_match_wrap()
|
||||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
.size(25);
|
||||||
));
|
|
||||||
tv.setGravity(Gravity.CENTER_HORIZONTAL);
|
|
||||||
tv.setText(pit_latest_values[a].name);
|
|
||||||
tv.setTextSize(25);
|
|
||||||
|
|
||||||
if(psda.data.array[a].isNull()){
|
if(psda.data.array[a].isNull()){
|
||||||
tv.setBackgroundColor(toggletitle_unselected);
|
tvb.tv.setBackgroundColor(toggletitle_unselected);
|
||||||
tv.setTextColor(toggletitle_black_background);
|
tvb.tv.setTextColor(toggletitle_black_background);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
binding.pitArea.addView(tvb.build());
|
||||||
|
|
||||||
binding.pitArea.addView(tv);
|
|
||||||
|
|
||||||
|
|
||||||
pit_latest_values[a].add_individual_view(binding.pitArea, psda.data.array[a]);
|
pit_latest_values[a].add_individual_view(binding.pitArea, psda.data.array[a]);
|
||||||
@@ -177,15 +163,11 @@ public class TeamsFragment extends Fragment {
|
|||||||
String[] files = FileEditor.getMatchesByTeamNum(evcode, team.teamNumber);
|
String[] files = FileEditor.getMatchesByTeamNum(evcode, team.teamNumber);
|
||||||
|
|
||||||
if(files.length == 0){
|
if(files.length == 0){
|
||||||
TextView tv = new TextView(getContext());
|
binding.matchArea.addView(new TextViewBuilder(getContext(), "No match data has been collected!")
|
||||||
tv.setLayoutParams(new FrameLayout.LayoutParams(
|
.layout_match_wrap()
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
.align_center()
|
||||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
.size(23)
|
||||||
));
|
.build());
|
||||||
tv.setGravity(Gravity.CENTER_HORIZONTAL);
|
|
||||||
tv.setText("No match data has been collected!");
|
|
||||||
tv.setTextSize(23);
|
|
||||||
binding.matchArea.addView(tv);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -238,33 +220,28 @@ public class TeamsFragment extends Fragment {
|
|||||||
|
|
||||||
ScoutingDataWriter.ParsedScoutingDataResult psda = ScoutingDataWriter.load(files[matchIndex], match_values, match_transferValues);
|
ScoutingDataWriter.ParsedScoutingDataResult psda = ScoutingDataWriter.load(files[matchIndex], match_values, match_transferValues);
|
||||||
|
|
||||||
TextView tv = new TextView(getContext());
|
|
||||||
tv.setLayoutParams(new FrameLayout.LayoutParams(
|
binding.matchArea.addView(
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
new TextViewBuilder(getContext(), "M" + (match_num) + " " + split[2] + "-" + split[3] + " by " + psda.username)
|
||||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
.align_center()
|
||||||
));
|
.size(30)
|
||||||
tv.setPadding(0, 40, 0, 5);
|
.padding(0,0,40,5)
|
||||||
tv.setGravity(Gravity.CENTER_HORIZONTAL);
|
.build()
|
||||||
tv.setText("M" + (match_num) + " " + split[2] + "-" + split[3] + " by " + psda.username);
|
|
||||||
tv.setTextSize(30);
|
);
|
||||||
binding.matchArea.addView(tv);
|
|
||||||
|
|
||||||
for (int i = 0; i < psda.data.array.length; i++) {
|
for (int i = 0; i < psda.data.array.length; i++) {
|
||||||
tv = new TextView(getContext());
|
TextViewBuilder tv = new TextViewBuilder(getContext(), match_latest_values[i].name)
|
||||||
tv.setLayoutParams(new FrameLayout.LayoutParams(
|
.align_center()
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
.size(25);
|
||||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
|
||||||
));
|
|
||||||
tv.setGravity(Gravity.CENTER_HORIZONTAL);
|
|
||||||
tv.setText(match_latest_values[i].name);
|
|
||||||
tv.setTextSize(25);
|
|
||||||
|
|
||||||
if (psda.data.array[i].isNull()) {
|
if (psda.data.array[i].isNull()) {
|
||||||
tv.setBackgroundColor(toggletitle_unselected);
|
tv.tv.setBackgroundColor(toggletitle_unselected);
|
||||||
tv.setTextColor(toggletitle_black_background);
|
tv.tv.setTextColor(toggletitle_black_background);
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.matchArea.addView(tv);
|
binding.matchArea.addView(tv.build());
|
||||||
|
|
||||||
|
|
||||||
if(psda.data.array[i] != null)
|
if(psda.data.array[i] != null)
|
||||||
@@ -296,16 +273,14 @@ public class TeamsFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 0; i < match_latest_values.length; i++){
|
for(int i = 0; i < match_latest_values.length; i++){
|
||||||
TextView tv = new TextView(getContext());
|
|
||||||
tv.setLayoutParams(new FrameLayout.LayoutParams(
|
binding.matchArea.addView(
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
new TextViewBuilder(getContext(), match_latest_values[i].name)
|
||||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
.align_center()
|
||||||
));
|
.padding(0, 0, 20, 5)
|
||||||
tv.setPadding(0, 20, 0, 5);
|
.size(30)
|
||||||
tv.setGravity(Gravity.CENTER_HORIZONTAL);
|
.build()
|
||||||
tv.setText(match_latest_values[i].name);
|
);
|
||||||
tv.setTextSize(30);
|
|
||||||
binding.matchArea.addView(tv);
|
|
||||||
|
|
||||||
if(data[i] != null)
|
if(data[i] != null)
|
||||||
match_latest_values[i].add_compiled_view(binding.matchArea, data[i]);
|
match_latest_values[i].add_compiled_view(binding.matchArea, data[i]);
|
||||||
@@ -331,16 +306,14 @@ public class TeamsFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 0; i < match_latest_values.length; i++){
|
for(int i = 0; i < match_latest_values.length; i++){
|
||||||
TextView tv = new TextView(getContext());
|
|
||||||
tv.setLayoutParams(new FrameLayout.LayoutParams(
|
binding.matchArea.addView(
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
new TextViewBuilder(getContext(), match_latest_values[i].name)
|
||||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
.align_center()
|
||||||
));
|
.size(30)
|
||||||
tv.setPadding(0, 20, 0, 5);
|
.padding(0,0,20,5)
|
||||||
tv.setGravity(Gravity.CENTER_HORIZONTAL);
|
.build()
|
||||||
tv.setText(match_latest_values[i].name);
|
);
|
||||||
tv.setTextSize(30);
|
|
||||||
binding.matchArea.addView(tv);
|
|
||||||
|
|
||||||
if(data[i] != null)
|
if(data[i] != null)
|
||||||
match_latest_values[i].add_history_view(binding.matchArea, data[i]);
|
match_latest_values[i].add_history_view(binding.matchArea, data[i]);
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import com.ridgebotics.ridgescout.utility.FileEditor;
|
|||||||
import com.ridgebotics.ridgescout.types.frcEvent;
|
import com.ridgebotics.ridgescout.types.frcEvent;
|
||||||
import com.ridgebotics.ridgescout.types.frcMatch;
|
import com.ridgebotics.ridgescout.types.frcMatch;
|
||||||
import com.ridgebotics.ridgescout.utility.SettingsManager;
|
import com.ridgebotics.ridgescout.utility.SettingsManager;
|
||||||
|
import com.ridgebotics.ridgescout.utility.builders.TextViewBuilder;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -59,11 +60,10 @@ public class EventFragment extends Fragment {
|
|||||||
add_match_scouting(event);
|
add_match_scouting(event);
|
||||||
}
|
}
|
||||||
private void addTableText(TableRow tr, String textStr){
|
private void addTableText(TableRow tr, String textStr){
|
||||||
TextView text = new TextView(getContext());
|
tr.addView(new TextViewBuilder(getContext(), textStr)
|
||||||
text.setTextSize(18);
|
.align_center()
|
||||||
text.setTextAlignment(View.TEXT_ALIGNMENT_CENTER); // Text align center
|
.size(18)
|
||||||
text.setText(textStr);
|
.build());
|
||||||
tr.addView(text);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void add_pit_scouting(frcEvent event){
|
public void add_pit_scouting(frcEvent event){
|
||||||
@@ -94,33 +94,32 @@ public class EventFragment extends Fragment {
|
|||||||
tr = new TableRow(getContext());
|
tr = new TableRow(getContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
TextView text = new TextView(getContext());
|
TextViewBuilder text = new TextViewBuilder(getContext(), String.valueOf(num))
|
||||||
text.setTextSize(18);
|
.size(18)
|
||||||
text.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
|
.align_center();
|
||||||
|
|
||||||
text.setText(String.valueOf(num));
|
|
||||||
final String filename = event.eventCode + "-" + num + ".pitscoutdata";
|
final String filename = event.eventCode + "-" + num + ".pitscoutdata";
|
||||||
if(FileEditor.fileExist(filename)){
|
if(FileEditor.fileExist(filename)){
|
||||||
final boolean[] rescout = {DataManager.rescout_list.contains(filename)};
|
final boolean[] rescout = {DataManager.rescout_list.contains(filename)};
|
||||||
|
|
||||||
text.setBackgroundColor(rescout[0] ? color_rescout : color_found);
|
text.tv.setBackgroundColor(rescout[0] ? color_rescout : color_found);
|
||||||
|
|
||||||
text.setOnLongClickListener(view -> {
|
text.tv.setOnLongClickListener(view -> {
|
||||||
rescout[0] = !rescout[0];
|
rescout[0] = !rescout[0];
|
||||||
if(rescout[0]) {
|
if(rescout[0]) {
|
||||||
text.setBackgroundColor(color_rescout);
|
text.tv.setBackgroundColor(color_rescout);
|
||||||
DataManager.rescout_list.add(filename);
|
DataManager.rescout_list.add(filename);
|
||||||
}else{
|
}else{
|
||||||
text.setBackgroundColor(color_found);
|
text.tv.setBackgroundColor(color_found);
|
||||||
DataManager.rescout_list.remove(filename);
|
DataManager.rescout_list.remove(filename);
|
||||||
}
|
}
|
||||||
DataManager.save_rescout_list();
|
DataManager.save_rescout_list();
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
}else{
|
}else{
|
||||||
text.setBackgroundColor(color_not_found);
|
text.tv.setBackgroundColor(color_not_found);
|
||||||
}
|
}
|
||||||
tr.addView(text);
|
tr.addView(text.build());
|
||||||
}
|
}
|
||||||
if(tr != null)
|
if(tr != null)
|
||||||
binding.teamsTable.addView(tr);
|
binding.teamsTable.addView(tr);
|
||||||
@@ -153,10 +152,6 @@ public class EventFragment extends Fragment {
|
|||||||
addTableText(tr, String.valueOf(match.matchIndex));
|
addTableText(tr, String.valueOf(match.matchIndex));
|
||||||
//
|
//
|
||||||
for(int i=0;i<6;i++){
|
for(int i=0;i<6;i++){
|
||||||
TextView text = new TextView(getContext());
|
|
||||||
text.setTextSize(18);
|
|
||||||
text.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
|
|
||||||
|
|
||||||
int team_num;
|
int team_num;
|
||||||
String alliance_position;
|
String alliance_position;
|
||||||
|
|
||||||
@@ -168,20 +163,23 @@ public class EventFragment extends Fragment {
|
|||||||
alliance_position = "blue-"+(i-2);
|
alliance_position = "blue-"+(i-2);
|
||||||
}
|
}
|
||||||
|
|
||||||
text.setText(String.valueOf(team_num));
|
TextViewBuilder text = new TextViewBuilder(getContext(), String.valueOf(team_num))
|
||||||
|
.size(18)
|
||||||
|
.align_center();
|
||||||
|
|
||||||
final String filename = event.eventCode + "-" + match.matchIndex + "-" + alliance_position + "-" + team_num + ".matchscoutdata";
|
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)};
|
final boolean[] rescout = {DataManager.rescout_list.contains(filename)};
|
||||||
|
|
||||||
text.setBackgroundColor(rescout[0] ? color_rescout : color_found);
|
text.tv.setBackgroundColor(rescout[0] ? color_rescout : color_found);
|
||||||
|
|
||||||
text.setOnLongClickListener(view -> {
|
text.tv.setOnLongClickListener(view -> {
|
||||||
rescout[0] = !rescout[0];
|
rescout[0] = !rescout[0];
|
||||||
if(rescout[0]) {
|
if(rescout[0]) {
|
||||||
text.setBackgroundColor(color_rescout);
|
text.tv.setBackgroundColor(color_rescout);
|
||||||
DataManager.rescout_list.add(filename);
|
DataManager.rescout_list.add(filename);
|
||||||
}else{
|
}else{
|
||||||
text.setBackgroundColor(color_found);
|
text.tv.setBackgroundColor(color_found);
|
||||||
DataManager.rescout_list.remove(filename);
|
DataManager.rescout_list.remove(filename);
|
||||||
}
|
}
|
||||||
DataManager.save_rescout_list();
|
DataManager.save_rescout_list();
|
||||||
@@ -189,9 +187,9 @@ public class EventFragment extends Fragment {
|
|||||||
});
|
});
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
text.setBackgroundColor(color_not_found);
|
text.tv.setBackgroundColor(color_not_found);
|
||||||
}
|
}
|
||||||
tr.addView(text);
|
tr.addView(text.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.matchTable.addView(tr);
|
binding.matchTable.addView(tr);
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import com.ridgebotics.ridgescout.utility.AlertManager;
|
|||||||
import com.ridgebotics.ridgescout.utility.AutoSaveManager;
|
import com.ridgebotics.ridgescout.utility.AutoSaveManager;
|
||||||
import com.ridgebotics.ridgescout.utility.DataManager;
|
import com.ridgebotics.ridgescout.utility.DataManager;
|
||||||
import com.ridgebotics.ridgescout.utility.FileEditor;
|
import com.ridgebotics.ridgescout.utility.FileEditor;
|
||||||
|
import com.ridgebotics.ridgescout.utility.builders.TextViewBuilder;
|
||||||
|
|
||||||
// Fragment for match scouting data editing.
|
// Fragment for match scouting data editing.
|
||||||
public class MatchScoutingFragment extends Fragment {
|
public class MatchScoutingFragment extends Fragment {
|
||||||
@@ -59,10 +60,12 @@ public class MatchScoutingFragment extends Fragment {
|
|||||||
binding.matchTeamCard.setVisibility(View.VISIBLE);
|
binding.matchTeamCard.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
if(DataManager.match_values == null || DataManager.match_values.length == 0){
|
if(DataManager.match_values == null || DataManager.match_values.length == 0){
|
||||||
TextView tv = new TextView(getContext());
|
|
||||||
tv.setText("Failed to load fields.\nTry to either download or create match scouting fields.");
|
binding.MatchScoutArea.addView(
|
||||||
tv.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
|
new TextViewBuilder(getContext(), "Failed to load fields.\nTry to either download or create match scouting fields.")
|
||||||
binding.MatchScoutArea.addView(tv);
|
.align_center()
|
||||||
|
.build());
|
||||||
|
|
||||||
return binding.getRoot();
|
return binding.getRoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import com.ridgebotics.ridgescout.utility.FileEditor;
|
|||||||
import com.ridgebotics.ridgescout.utility.SettingsManager;
|
import com.ridgebotics.ridgescout.utility.SettingsManager;
|
||||||
import com.ridgebotics.ridgescout.databinding.FragmentScoutingBinding;
|
import com.ridgebotics.ridgescout.databinding.FragmentScoutingBinding;
|
||||||
import com.ridgebotics.ridgescout.utility.DataManager;
|
import com.ridgebotics.ridgescout.utility.DataManager;
|
||||||
|
import com.ridgebotics.ridgescout.utility.builders.TextViewBuilder;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -169,16 +170,15 @@ public class ScoutingFragment extends Fragment {
|
|||||||
binding.textMatchAlliance.setText("Match: " + (curMatchNum+1) + ", " + SettingsManager.getAllyPos());
|
binding.textMatchAlliance.setText("Match: " + (curMatchNum+1) + ", " + SettingsManager.getAllyPos());
|
||||||
binding.textRescoutIndicator.setText("Things to rescout: " + DataManager.rescout_list.size());
|
binding.textRescoutIndicator.setText("Things to rescout: " + DataManager.rescout_list.size());
|
||||||
|
|
||||||
TextView nextMatchText = new TextView(getContext());
|
binding.infoBox.addView(new TextViewBuilder(getContext(), "Our next match: Match " + nextMatch)
|
||||||
nextMatchText.setText("Our next match: Match " + nextMatch);
|
.body1()
|
||||||
nextMatchText.setTextAppearance(com.google.android.material.R.style.TextAppearance_MaterialComponents_Body1);
|
.build());
|
||||||
binding.infoBox.addView(nextMatchText);
|
|
||||||
|
|
||||||
int informedBy = event.getMostInformedBy(teamNum, curMatchNum);
|
int informedBy = event.getMostInformedBy(teamNum, curMatchNum);
|
||||||
|
|
||||||
TextView mostInformedText = new TextView(getContext());
|
|
||||||
mostInformedText.setText("Most informed by: Match " + informedBy);
|
binding.infoBox.addView(new TextViewBuilder(getContext(), "Most informed by: Match " + informedBy)
|
||||||
mostInformedText.setTextAppearance(com.google.android.material.R.style.TextAppearance_MaterialComponents_Body1);
|
.body1()
|
||||||
binding.infoBox.addView(mostInformedText);
|
.build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -19,6 +19,7 @@ import com.ridgebotics.ridgescout.types.input.SliderType;
|
|||||||
import com.ridgebotics.ridgescout.types.input.TallyType;
|
import com.ridgebotics.ridgescout.types.input.TallyType;
|
||||||
import com.ridgebotics.ridgescout.types.input.TextType;
|
import com.ridgebotics.ridgescout.types.input.TextType;
|
||||||
import com.ridgebotics.ridgescout.utility.AlertManager;
|
import com.ridgebotics.ridgescout.utility.AlertManager;
|
||||||
|
import com.ridgebotics.ridgescout.utility.builders.TextViewBuilder;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@@ -397,11 +398,11 @@ public class FieldEditorHelper {
|
|||||||
this.t = t;
|
this.t = t;
|
||||||
views = new View[types.length];
|
views = new View[types.length];
|
||||||
for(int i = 0; i < types.length; i++){
|
for(int i = 0; i < types.length; i++){
|
||||||
TextView tv = new TextView(c);
|
|
||||||
tv.setText(types[i].name);
|
parentView.addView(new TextViewBuilder(c, types[i].name)
|
||||||
tv.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
|
.align_center()
|
||||||
tv.setTextSize(20);
|
.size(20)
|
||||||
parentView.addView(tv);
|
.build());
|
||||||
|
|
||||||
views[i] = createEdit(c, types[i]);
|
views[i] = createEdit(c, types[i]);
|
||||||
parentView.addView(views[i]);
|
parentView.addView(views[i]);
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import com.ridgebotics.ridgescout.types.input.FieldType;
|
|||||||
import com.ridgebotics.ridgescout.ui.views.CustomSpinnerView;
|
import com.ridgebotics.ridgescout.ui.views.CustomSpinnerView;
|
||||||
import com.ridgebotics.ridgescout.ui.views.FieldDisplay;
|
import com.ridgebotics.ridgescout.ui.views.FieldDisplay;
|
||||||
import com.ridgebotics.ridgescout.utility.AlertManager;
|
import com.ridgebotics.ridgescout.utility.AlertManager;
|
||||||
|
import com.ridgebotics.ridgescout.utility.builders.TextViewBuilder;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -196,10 +197,9 @@ public class FieldsFragment extends Fragment {
|
|||||||
|
|
||||||
sv.addView(table);
|
sv.addView(table);
|
||||||
|
|
||||||
TextView UUID = new TextView(getContext());
|
|
||||||
UUID.setText("Type: " + field.get_type_name() + "\nUUID: " + field.UUID);
|
|
||||||
|
|
||||||
table.addView(UUID);
|
table.addView(new TextViewBuilder(getContext(), "Type: " + field.get_type_name() + "\nUUID: " + field.UUID)
|
||||||
|
.build());
|
||||||
|
|
||||||
FieldEditorHelper f = new FieldEditorHelper(getContext(), field, table);
|
FieldEditorHelper f = new FieldEditorHelper(getContext(), field, table);
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ import com.ridgebotics.ridgescout.utility.AlertManager;
|
|||||||
import com.ridgebotics.ridgescout.utility.DataManager;
|
import com.ridgebotics.ridgescout.utility.DataManager;
|
||||||
import com.ridgebotics.ridgescout.utility.FileEditor;
|
import com.ridgebotics.ridgescout.utility.FileEditor;
|
||||||
import com.ridgebotics.ridgescout.utility.ToDelete;
|
import com.ridgebotics.ridgescout.utility.ToDelete;
|
||||||
|
import com.ridgebotics.ridgescout.utility.builders.TextViewBuilder;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -253,10 +254,8 @@ public class SettingsFragment extends Fragment {
|
|||||||
|
|
||||||
|
|
||||||
private TextView createText(String title) {
|
private TextView createText(String title) {
|
||||||
TextView tv = new TextView(getContext());
|
return new TextViewBuilder(getContext(), title)
|
||||||
tv.setTextAppearance(com.google.android.material.R.style.TextAppearance_MaterialComponents_Body1);
|
.body1().build();
|
||||||
tv.setText(title);
|
|
||||||
return tv;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showAppInfo() {
|
private void showAppInfo() {
|
||||||
@@ -395,9 +394,8 @@ public class SettingsFragment extends Fragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View createView(Context context) {
|
public View createView(Context context) {
|
||||||
TextView titleView = new TextView(context);
|
TextView titleView = new TextViewBuilder(context, getTitle())
|
||||||
titleView.setText(getTitle());
|
.sub1().build();
|
||||||
titleView.setTextAppearance(com.google.android.material.R.style.TextAppearance_MaterialComponents_Subtitle1);
|
|
||||||
|
|
||||||
TextInputLayout textInputLayout = new TextInputLayout(context);
|
TextInputLayout textInputLayout = new TextInputLayout(context);
|
||||||
editText = new TextInputEditText(context);
|
editText = new TextInputEditText(context);
|
||||||
@@ -477,11 +475,10 @@ public class SettingsFragment extends Fragment {
|
|||||||
});
|
});
|
||||||
tally.setEnabled(enabled);
|
tally.setEnabled(enabled);
|
||||||
|
|
||||||
TextView tv = new TextView(getContext());
|
|
||||||
tv.setText(getTitle());
|
ll.addView(new TextViewBuilder(getContext(), getTitle())
|
||||||
tv.setTextAppearance(com.google.android.material.R.style.TextAppearance_MaterialComponents_Headline6);
|
.h6()
|
||||||
tv.setGravity(Gravity.CENTER);
|
.build());
|
||||||
ll.addView(tv);
|
|
||||||
|
|
||||||
ll.addView(tally);
|
ll.addView(tally);
|
||||||
|
|
||||||
@@ -605,10 +602,9 @@ public class SettingsFragment extends Fragment {
|
|||||||
ll.setOrientation(VERTICAL);
|
ll.setOrientation(VERTICAL);
|
||||||
ll.setPadding(0, 20,0,0);
|
ll.setPadding(0, 20,0,0);
|
||||||
|
|
||||||
TextView tv = new TextView(context);
|
ll.addView(new TextViewBuilder(context, title)
|
||||||
tv.setText(title);
|
.h4()
|
||||||
tv.setTextAppearance(com.google.android.material.R.style.TextAppearance_MaterialComponents_Headline4);
|
.build());
|
||||||
ll.addView(tv);
|
|
||||||
|
|
||||||
ll.addView(new MaterialDivider(context));
|
ll.addView(new MaterialDivider(context));
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import com.ridgebotics.ridgescout.utility.AlertManager;
|
|||||||
import com.ridgebotics.ridgescout.utility.ByteBuilder;
|
import com.ridgebotics.ridgescout.utility.ByteBuilder;
|
||||||
import com.ridgebotics.ridgescout.utility.DataManager;
|
import com.ridgebotics.ridgescout.utility.DataManager;
|
||||||
import com.ridgebotics.ridgescout.utility.FileEditor;
|
import com.ridgebotics.ridgescout.utility.FileEditor;
|
||||||
|
import com.ridgebotics.ridgescout.utility.builders.TextViewBuilder;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -77,10 +78,12 @@ public class FileSelectorFragment extends Fragment {
|
|||||||
checkBox.setChecked(true);
|
checkBox.setChecked(true);
|
||||||
tr.addView(checkBox);
|
tr.addView(checkBox);
|
||||||
|
|
||||||
TextView tv = new TextView(getContext());
|
// Filename
|
||||||
tv.setText(String.valueOf(files[i]));
|
tr.addView(
|
||||||
tv.setTextSize(20);
|
new TextViewBuilder(getContext(), files[i])
|
||||||
tr.addView(tv);
|
.size(20)
|
||||||
|
.build()
|
||||||
|
);
|
||||||
|
|
||||||
final int fi = i;
|
final int fi = i;
|
||||||
tr.setOnClickListener(view -> {
|
tr.setOnClickListener(view -> {
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ import com.ridgebotics.ridgescout.utility.JSONUtil;
|
|||||||
import com.ridgebotics.ridgescout.utility.RequestTask;
|
import com.ridgebotics.ridgescout.utility.RequestTask;
|
||||||
import com.ridgebotics.ridgescout.utility.FileEditor;
|
import com.ridgebotics.ridgescout.utility.FileEditor;
|
||||||
import com.ridgebotics.ridgescout.utility.SettingsManager;
|
import com.ridgebotics.ridgescout.utility.SettingsManager;
|
||||||
|
import com.ridgebotics.ridgescout.utility.builders.TextViewBuilder;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
@@ -76,23 +77,14 @@ public class TBAEventFragment extends Fragment {
|
|||||||
|
|
||||||
Table = binding.matchTable;
|
Table = binding.matchTable;
|
||||||
|
|
||||||
Table.setStretchAllColumns(true);
|
|
||||||
|
|
||||||
AlertManager.startLoading("Loading Teams and Matches...");
|
AlertManager.startLoading("Loading Teams and Matches...");
|
||||||
Table.removeAllViews();
|
|
||||||
|
// Table.removeAllViews();
|
||||||
Table.setStretchAllColumns(true);
|
Table.setStretchAllColumns(true);
|
||||||
Table.bringToFront();
|
Table.bringToFront();
|
||||||
|
|
||||||
TableRow tr1 = new TableRow(getContext());
|
|
||||||
addTableText(tr1, "Downloading Teams...");
|
|
||||||
Table.addView(tr1);
|
|
||||||
|
|
||||||
final RequestTask rq = new RequestTask();
|
final RequestTask rq = new RequestTask();
|
||||||
rq.onResult(teamsStr -> {
|
rq.onResult(teamsStr -> {
|
||||||
TableRow tr11 = new TableRow(getContext());
|
|
||||||
addTableText(tr11, "Downloading Matches...");
|
|
||||||
Table.addView(tr11);
|
|
||||||
|
|
||||||
final RequestTask rq1 = new RequestTask();
|
final RequestTask rq1 = new RequestTask();
|
||||||
rq1.onResult(matchesStr -> {
|
rq1.onResult(matchesStr -> {
|
||||||
matchTable(matchesStr, teamsStr, eventData);
|
matchTable(matchesStr, teamsStr, eventData);
|
||||||
@@ -108,18 +100,13 @@ public class TBAEventFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addTableText(TableRow tr, String textStr){
|
private void addTableText(TableRow tr, String textStr){
|
||||||
TextView text = new TextView(getContext());
|
tr.addView(new TextViewBuilder(getContext(), textStr)
|
||||||
text.setTextSize(18);
|
.size(18)
|
||||||
text.setTextAlignment(View.TEXT_ALIGNMENT_CENTER); // Text align center
|
// .align_center()
|
||||||
text.setText(textStr);
|
.build());
|
||||||
tr.addView(text);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void matchTable(String matchesString, String teamsString, JSONObject eventData){
|
public void matchTable(String matchesString, String teamsString, JSONObject eventData){
|
||||||
Table.removeAllViews();
|
|
||||||
Table.setStretchAllColumns(true);
|
|
||||||
Table.bringToFront();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final JSONArray matchData = new JSONArray(matchesString);
|
final JSONArray matchData = new JSONArray(matchesString);
|
||||||
// final JSONArray matchData = new JSONArray();
|
// final JSONArray matchData = new JSONArray();
|
||||||
@@ -134,27 +121,16 @@ public class TBAEventFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Event code at top
|
// Event code at top
|
||||||
TextView tv = new TextView(getContext());
|
Table.addView(new TextViewBuilder(getContext(), matchKey)
|
||||||
tv.setLayoutParams(new TableRow.LayoutParams(
|
.align_center()
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
.size(18)
|
||||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
.build());
|
||||||
));
|
|
||||||
tv.setText(matchKey);
|
|
||||||
tv.setTextSize(18);
|
|
||||||
Table.addView(tv);
|
|
||||||
|
|
||||||
// Event Name
|
// Event Name
|
||||||
tv = new TextView(getContext());
|
Table.addView(new TextViewBuilder(getContext(), matchName)
|
||||||
tv.setLayoutParams(new TableRow.LayoutParams(
|
.align_center()
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
.size(28)
|
||||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
.build());
|
||||||
));
|
|
||||||
tv.setGravity(Gravity.CENTER_HORIZONTAL);
|
|
||||||
tv.setText(matchName);
|
|
||||||
tv.setTextSize(28);
|
|
||||||
Table.addView(tv);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Save button
|
// Save button
|
||||||
MaterialButton btn = new MaterialButton(getContext());
|
MaterialButton btn = new MaterialButton(getContext());
|
||||||
@@ -169,68 +145,42 @@ public class TBAEventFragment extends Fragment {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// If there are no matches, add the error.
|
||||||
|
// If there are no teams, don't allow the user to save the event and set the button to be invisible
|
||||||
if(teamData.length() == 0){
|
if(teamData.length() == 0){
|
||||||
tv = new TextView(getContext());
|
Table.addView(new TextViewBuilder(getContext(), "This event has no teams released yet...")
|
||||||
tv.setLayoutParams(new TableRow.LayoutParams(
|
.align_center()
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
.size(18)
|
||||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
.build());
|
||||||
));
|
|
||||||
tv.setGravity(Gravity.CENTER_HORIZONTAL);
|
|
||||||
tv.setText("This event has no teams released yet...");
|
|
||||||
tv.setTextSize(18);
|
|
||||||
Table.addView(tv);
|
|
||||||
|
|
||||||
tv = new TextView(getContext());
|
|
||||||
tv.setLayoutParams(new TableRow.LayoutParams(
|
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
|
||||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
|
||||||
));
|
|
||||||
tv.setGravity(Gravity.CENTER_HORIZONTAL);
|
|
||||||
tv.setText("This event has no teams released yet...");
|
|
||||||
tv.setTextSize(18);
|
|
||||||
Table.addView(tv);
|
|
||||||
|
|
||||||
btn.setVisibility(View.GONE);
|
btn.setVisibility(View.GONE);
|
||||||
return;
|
return;
|
||||||
}else if(matchData.length() == 0){
|
}else if(matchData.length() == 0){
|
||||||
tv = new TextView(getContext());
|
Table.addView(new TextViewBuilder(getContext(), "This event has no matches released yet...")
|
||||||
tv.setLayoutParams(new TableRow.LayoutParams(
|
.align_center()
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
.size(18)
|
||||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
.build());
|
||||||
));
|
|
||||||
tv.setGravity(Gravity.CENTER_HORIZONTAL);
|
|
||||||
tv.setText("This event has no matches released yet...");
|
|
||||||
tv.setTextSize(18);
|
|
||||||
Table.addView(tv);
|
|
||||||
|
|
||||||
tv = new TextView(getContext());
|
Table.addView(new TextViewBuilder(getContext(), "Try manually adding practice matches.")
|
||||||
tv.setLayoutParams(new TableRow.LayoutParams(
|
.align_center()
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
.size(18)
|
||||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
.build());
|
||||||
));
|
|
||||||
tv.setGravity(Gravity.CENTER_HORIZONTAL);
|
|
||||||
tv.setText("Try manually adding practice matches.");
|
|
||||||
tv.setTextSize(18);
|
|
||||||
Table.addView(tv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
tv = new TextView(getContext());
|
Table.addView(
|
||||||
tv.setLayoutParams(new TableRow.LayoutParams(
|
new TextViewBuilder(getContext(), "Teams")
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
.align_center()
|
||||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
.size(28)
|
||||||
));
|
.build()
|
||||||
tv.setGravity(Gravity.CENTER_HORIZONTAL);
|
);
|
||||||
tv.setText("Teams");
|
|
||||||
tv.setTextSize(28);
|
|
||||||
Table.addView(tv);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Sort the teams into numerical order
|
||||||
int[] teams = new int[teamData.length()];
|
int[] teams = new int[teamData.length()];
|
||||||
|
|
||||||
for(int i = 0 ; i < teamData.length(); i++){
|
for(int i = 0 ; i < teamData.length(); i++){
|
||||||
@@ -239,28 +189,26 @@ public class TBAEventFragment extends Fragment {
|
|||||||
|
|
||||||
Arrays.sort(teams);
|
Arrays.sort(teams);
|
||||||
|
|
||||||
|
|
||||||
|
// Loop through each match
|
||||||
TableRow tr = null;
|
TableRow tr = null;
|
||||||
for(int i=0; i < teamData.length(); i++){
|
for(int i=0; i < teamData.length(); i++){
|
||||||
// frcTeam team = event.teams.get(i);
|
|
||||||
int num = teams[i];
|
int num = teams[i];
|
||||||
|
|
||||||
|
// If this is every 7th row, add the new row.
|
||||||
if(i % 7 == 0){
|
if(i % 7 == 0){
|
||||||
if(i != 0)
|
if(i != 0)
|
||||||
Table.addView(tr);
|
Table.addView(tr);
|
||||||
tr = new TableRow(getContext());
|
tr = new TableRow(getContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
TextView text = new TextView(getContext());
|
|
||||||
text.setTextSize(18);
|
|
||||||
text.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
|
|
||||||
|
|
||||||
text.setText(String.valueOf(num));
|
tr.addView(
|
||||||
// if(fileEditor.fileExist(event.eventCode + "-" + num + ".pitscoutdata")){
|
new TextViewBuilder(getContext(), String.valueOf(num))
|
||||||
// text.setBackgroundColor(0x3000FF00);
|
.align_center()
|
||||||
// }else{
|
.size(18)
|
||||||
// text.setBackgroundColor(0x30FF0000);
|
.build()
|
||||||
// }
|
);
|
||||||
tr.addView(text);
|
|
||||||
}
|
}
|
||||||
if(tr != null)
|
if(tr != null)
|
||||||
Table.addView(tr);
|
Table.addView(tr);
|
||||||
@@ -273,19 +221,13 @@ public class TBAEventFragment extends Fragment {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
tv = new TextView(getContext());
|
Table.addView(
|
||||||
tv.setLayoutParams(new TableRow.LayoutParams(
|
new TextViewBuilder(getContext(), "Matches")
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
.align_center()
|
||||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
.size(28)
|
||||||
));
|
.build()
|
||||||
tv.setGravity(Gravity.CENTER_HORIZONTAL);
|
);
|
||||||
tv.setText("Matches");
|
|
||||||
tv.setTextSize(28);
|
|
||||||
Table.addView(tv);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
tr = new TableRow(getContext());
|
tr = new TableRow(getContext());
|
||||||
addTableText(tr, "#");
|
addTableText(tr, "#");
|
||||||
addTableText(tr, "Red-1");
|
addTableText(tr, "Red-1");
|
||||||
@@ -339,22 +281,24 @@ public class TBAEventFragment extends Fragment {
|
|||||||
int[] redKeys = new int[3];
|
int[] redKeys = new int[3];
|
||||||
|
|
||||||
for(int b=0;b<6;b++){
|
for(int b=0;b<6;b++){
|
||||||
TextView text = new TextView(getContext());
|
TextViewBuilder text = new TextViewBuilder(getContext())
|
||||||
text.setTextSize(18);
|
.size(18)
|
||||||
text.setTextAlignment(View.TEXT_ALIGNMENT_CENTER); // Text align center
|
.align_center();
|
||||||
tr.addView(text);
|
|
||||||
|
|
||||||
if(b < 3){
|
if(b < 3){
|
||||||
String str = redAlliance.getString(b).substring(3);
|
String str = redAlliance.getString(b).substring(3);
|
||||||
redKeys[b] = Integer.parseInt(str);
|
redKeys[b] = Integer.parseInt(str);
|
||||||
text.setText(str);
|
text.text(str);
|
||||||
text.setBackgroundColor(tba_red);
|
text.tv.setBackgroundColor(tba_red);
|
||||||
}else{
|
}else{
|
||||||
String str = blueAlliance.getString(b-3).substring(3);
|
String str = blueAlliance.getString(b-3).substring(3);
|
||||||
blueKeys[b-3] = Integer.parseInt(str);
|
blueKeys[b-3] = Integer.parseInt(str);
|
||||||
text.setText(str);
|
text.text(str);
|
||||||
text.setBackgroundColor(tba_blue);
|
text.tv.setBackgroundColor(tba_blue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
tr.addView(text.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
Table.addView(tr);
|
Table.addView(tr);
|
||||||
@@ -369,14 +313,6 @@ public class TBAEventFragment extends Fragment {
|
|||||||
toggle = !toggle;
|
toggle = !toggle;
|
||||||
}
|
}
|
||||||
|
|
||||||
// btn.setOnClickListener(v -> {
|
|
||||||
// if(saveData(matchesOBJ, teamData, eventData)){
|
|
||||||
// alert("Info", "Saved!");
|
|
||||||
// }else{
|
|
||||||
// alert("Error", "Error saving files.");
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
}catch (JSONException j){
|
}catch (JSONException j){
|
||||||
AlertManager.error("Failed Downloading", j);
|
AlertManager.error("Failed Downloading", j);
|
||||||
AlertManager.stopLoading();
|
AlertManager.stopLoading();
|
||||||
@@ -384,7 +320,7 @@ public class TBAEventFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean saveData(ArrayList<frcMatch> matchData, JSONArray teamData, JSONObject eventData){
|
private boolean saveData(ArrayList<frcMatch> matchData, JSONArray teamData, JSONObject eventData){
|
||||||
AlertManager.startLoading("Saving data...");
|
AlertManager.startLoading("Downloading team data...");
|
||||||
|
|
||||||
Thread t = new Thread(() -> {
|
Thread t = new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import com.ridgebotics.ridgescout.ui.views.TBAEventOption;
|
|||||||
import com.ridgebotics.ridgescout.utility.AlertManager;
|
import com.ridgebotics.ridgescout.utility.AlertManager;
|
||||||
import com.ridgebotics.ridgescout.utility.RequestTask;
|
import com.ridgebotics.ridgescout.utility.RequestTask;
|
||||||
import com.ridgebotics.ridgescout.utility.SettingsManager;
|
import com.ridgebotics.ridgescout.utility.SettingsManager;
|
||||||
|
import com.ridgebotics.ridgescout.utility.builders.TextViewBuilder;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
@@ -54,12 +55,6 @@ public class TBASelectorFragment extends Fragment {
|
|||||||
|
|
||||||
Table = binding.matchTable;
|
Table = binding.matchTable;
|
||||||
|
|
||||||
Table.setStretchAllColumns(true);
|
|
||||||
|
|
||||||
TableRow tr = new TableRow(getContext());
|
|
||||||
addTableText(tr, "Loading Events...");
|
|
||||||
Table.addView(tr);
|
|
||||||
|
|
||||||
startLoading("Loading Events...");
|
startLoading("Loading Events...");
|
||||||
|
|
||||||
final RequestTask rq = new RequestTask();
|
final RequestTask rq = new RequestTask();
|
||||||
@@ -77,14 +72,6 @@ public class TBASelectorFragment extends Fragment {
|
|||||||
return binding.getRoot();
|
return binding.getRoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addTableText(TableRow tr, String textStr){
|
|
||||||
TextView text = new TextView(getContext());
|
|
||||||
text.setTextSize(18);
|
|
||||||
text.setTextAlignment(View.TEXT_ALIGNMENT_CENTER); // Text align center
|
|
||||||
text.setText(textStr);
|
|
||||||
tr.addView(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getEventTypeWeight(String type){
|
public static int getEventTypeWeight(String type){
|
||||||
switch(type){
|
switch(type){
|
||||||
case "Preseason": return -3;
|
case "Preseason": return -3;
|
||||||
@@ -103,7 +90,7 @@ public class TBASelectorFragment extends Fragment {
|
|||||||
public void eventTable(String dataString){
|
public void eventTable(String dataString){
|
||||||
|
|
||||||
Table.removeAllViews();
|
Table.removeAllViews();
|
||||||
Table.setStretchAllColumns(true);
|
// Table.setStretchAllColumns(true);
|
||||||
Table.bringToFront();
|
Table.bringToFront();
|
||||||
|
|
||||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import android.widget.ScrollView;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.ridgebotics.ridgescout.types.ColabArray;
|
import com.ridgebotics.ridgescout.types.ColabArray;
|
||||||
|
import com.ridgebotics.ridgescout.utility.builders.TextViewBuilder;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -60,9 +61,7 @@ public class ToDelete {
|
|||||||
|
|
||||||
AlertDialog.Builder confirm = new AlertDialog.Builder(c);
|
AlertDialog.Builder confirm = new AlertDialog.Builder(c);
|
||||||
alert.setTitle("Confirm");
|
alert.setTitle("Confirm");
|
||||||
TextView tv = new TextView(c);
|
alert.setView(new TextViewBuilder(c, "Are you sure you want to delete " + delete_files.size() + " files?").build());
|
||||||
tv.setText("Are you sure you want to delete " + delete_files.size() + " files?");
|
|
||||||
alert.setView(tv);
|
|
||||||
alert.setNeutralButton("Cancel", null);
|
alert.setNeutralButton("Cancel", null);
|
||||||
alert.setPositiveButton("Delete", (dialogInterface, i) -> {
|
alert.setPositiveButton("Delete", (dialogInterface, i) -> {
|
||||||
deleteFiles(delete_files);
|
deleteFiles(delete_files);
|
||||||
|
|||||||
@@ -0,0 +1,161 @@
|
|||||||
|
package com.ridgebotics.ridgescout.utility.builders;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.view.Gravity;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
|
import android.widget.TableRow;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
public class TextViewBuilder {
|
||||||
|
public TextView tv;
|
||||||
|
public TextViewBuilder(Context c) {
|
||||||
|
tv = new TextView(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextViewBuilder(Context c, String str) {
|
||||||
|
tv = new TextView(c);
|
||||||
|
tv.setText(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextViewBuilder size(float size) {
|
||||||
|
tv.setTextSize(size);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextViewBuilder text(String str) {
|
||||||
|
tv.setText(str);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextViewBuilder padding(int borders) {
|
||||||
|
tv.setPadding(borders,borders,borders,borders);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextViewBuilder padding(int horisontal, int vertical) {
|
||||||
|
tv.setPadding(horisontal,vertical,horisontal,vertical);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextViewBuilder padding(int left, int right, int top, int bottom) {
|
||||||
|
tv.setPadding(left,top,right,bottom);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextViewBuilder align_left() {
|
||||||
|
tv.setGravity(Gravity.START);
|
||||||
|
tv.setTextAlignment(View.TEXT_ALIGNMENT_TEXT_START);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextViewBuilder align_center() {
|
||||||
|
tv.setGravity(Gravity.CENTER_HORIZONTAL);
|
||||||
|
// FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
|
||||||
|
// ViewGroup.LayoutParams.MATCH_PARENT,
|
||||||
|
// ViewGroup.LayoutParams.WRAP_CONTENT
|
||||||
|
// );
|
||||||
|
// params.gravity = Gravity.CENTER;
|
||||||
|
// tv.setLayoutParams(params);
|
||||||
|
//
|
||||||
|
//
|
||||||
|
tv.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// public TextViewBuilder center_xy() {
|
||||||
|
// TableRow.LayoutParams params = new TableRow.LayoutParams();
|
||||||
|
// params.gravity = Gravity.CENTER;
|
||||||
|
// tv.setLayoutParams(params);
|
||||||
|
// return this;
|
||||||
|
// }
|
||||||
|
|
||||||
|
public TextViewBuilder align_right() {
|
||||||
|
tv.setGravity(Gravity.END);
|
||||||
|
tv.setTextAlignment(View.TEXT_ALIGNMENT_TEXT_END);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextViewBuilder layout_wrap_wrap() {
|
||||||
|
tv.setLayoutParams(new FrameLayout.LayoutParams(
|
||||||
|
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||||
|
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||||
|
));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextViewBuilder layout_wrap_match() {
|
||||||
|
tv.setLayoutParams(new FrameLayout.LayoutParams(
|
||||||
|
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||||
|
ViewGroup.LayoutParams.MATCH_PARENT
|
||||||
|
));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextViewBuilder layout_match_wrap() {
|
||||||
|
tv.setLayoutParams(new FrameLayout.LayoutParams(
|
||||||
|
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||||
|
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||||
|
));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextViewBuilder layout_match_match() {
|
||||||
|
tv.setLayoutParams(new FrameLayout.LayoutParams(
|
||||||
|
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||||
|
ViewGroup.LayoutParams.MATCH_PARENT
|
||||||
|
));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextViewBuilder h1() {
|
||||||
|
tv.setTextAppearance(com.google.android.material.R.style.TextAppearance_MaterialComponents_Headline1);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public TextViewBuilder h2() {
|
||||||
|
tv.setTextAppearance(com.google.android.material.R.style.TextAppearance_MaterialComponents_Headline2);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public TextViewBuilder h3() {
|
||||||
|
tv.setTextAppearance(com.google.android.material.R.style.TextAppearance_MaterialComponents_Headline3);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public TextViewBuilder h4() {
|
||||||
|
tv.setTextAppearance(com.google.android.material.R.style.TextAppearance_MaterialComponents_Headline4);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public TextViewBuilder h5() {
|
||||||
|
tv.setTextAppearance(com.google.android.material.R.style.TextAppearance_MaterialComponents_Headline5);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public TextViewBuilder h6() {
|
||||||
|
tv.setTextAppearance(com.google.android.material.R.style.TextAppearance_MaterialComponents_Headline6);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextViewBuilder sub1() {
|
||||||
|
tv.setTextAppearance(com.google.android.material.R.style.TextAppearance_MaterialComponents_Subtitle1);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public TextViewBuilder sub2() {
|
||||||
|
tv.setTextAppearance(com.google.android.material.R.style.TextAppearance_MaterialComponents_Subtitle2);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextViewBuilder body1() {
|
||||||
|
tv.setTextAppearance(com.google.android.material.R.style.TextAppearance_MaterialComponents_Body1);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public TextViewBuilder body2() {
|
||||||
|
tv.setTextAppearance(com.google.android.material.R.style.TextAppearance_MaterialComponents_Body2);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public TextView build() {
|
||||||
|
return tv;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user