mirror of
https://github.com/Team4388/RidgeScout.git
synced 2026-06-09 00:37:59 -06:00
Rework some UI elements
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
|
||||
|
||||
+6
-6
@@ -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);
|
||||
|
||||
+29
-24
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user