mirror of
https://github.com/Team4388/RidgeScout.git
synced 2026-06-09 08:38:03 -06:00
Field selector, Field back button, TBA popup
This commit is contained in:
@@ -89,18 +89,16 @@ public class MainActivity extends AppCompatActivity {
|
||||
NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration);
|
||||
NavigationUI.setupWithNavController(navView, navController);
|
||||
|
||||
navView.setOnItemSelectedListener(new NavigationBarView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
|
||||
clearBackStack();
|
||||
navController.navigate(item.getItemId(), savedInstanceState, new NavOptions.Builder()
|
||||
.setEnterAnim(R.anim.enter_anim)
|
||||
.setExitAnim(R.anim.exit_anim)
|
||||
.setPopEnterAnim(R.anim.pop_enter_anim)
|
||||
.setPopExitAnim(R.anim.pop_exit_anim).build()
|
||||
);
|
||||
return true;
|
||||
}
|
||||
navView.setOnItemSelectedListener(item -> {
|
||||
backPressed = null;
|
||||
clearBackStack();
|
||||
navController.navigate(item.getItemId(), savedInstanceState, new NavOptions.Builder()
|
||||
.setEnterAnim(R.anim.enter_anim)
|
||||
.setExitAnim(R.anim.exit_anim)
|
||||
.setPopEnterAnim(R.anim.pop_enter_anim)
|
||||
.setPopExitAnim(R.anim.pop_exit_anim).build()
|
||||
);
|
||||
return true;
|
||||
});
|
||||
|
||||
}
|
||||
@@ -116,11 +114,9 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
|
||||
|
||||
|
||||
public interface activityResultRelay {
|
||||
void onActivityResult(int requestCode, int resultCode, Intent data);
|
||||
}
|
||||
|
||||
public static activityResultRelay resultRelay = null;
|
||||
public static void setResultRelay(activityResultRelay tmpresultRelay){
|
||||
resultRelay = tmpresultRelay;
|
||||
@@ -135,4 +131,25 @@ public class MainActivity extends AppCompatActivity {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public interface onBackPressed {
|
||||
boolean onBackPressed();
|
||||
}
|
||||
|
||||
public onBackPressed backPressed = null;
|
||||
public void setOnBackPressed(onBackPressed onBackPressed){
|
||||
this.backPressed = onBackPressed;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if(backPressed != null) {
|
||||
if (backPressed.onBackPressed()) {
|
||||
super.onBackPressed();
|
||||
}
|
||||
} else {super.onBackPressed();}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -59,7 +59,8 @@ public class fields {
|
||||
public static final inputType[][] default_pit_fields = new inputType[][] {
|
||||
{
|
||||
new dropdownType("Drivetrain type", "What type of drivetrain does this team have?", new String[]{"Swerve Drive", "Tank Drive (Differential)", "Other, Info in comments"}, 0),
|
||||
new dropdownType("Intake type", "What type of intake does this team have?", new String[]{"Swerve Drive", "Tank Drive (Differential)", "Other, Info in comments"}, 0),
|
||||
new dropdownType("Intake type", "What type of intake does this team have?", new String[]{"Ground only", "Player Station only", "Both", "Other, Info in comments"}, 0),
|
||||
new dropdownType("Intake Consistency", "How consistent is the robot at intakeing?", new String[]{"Does not work", "Worked a few times during testing", "Works most of the time", "Fails sometimes", "Never fails"}, 0),
|
||||
|
||||
new dropdownType("Score Area", "What does this robot score?", new String[]{"Only Algae", "Mostly Algae", "Both", "Mostly Coral", "Only Coral"}, 0),
|
||||
|
||||
@@ -67,16 +68,18 @@ public class fields {
|
||||
new checkboxType("L3 Scoring", "Will the robot score in Layer 3?", 0),
|
||||
new checkboxType("L2 Scoring", "Will the robot score in Layer 3?", 0),
|
||||
new checkboxType("L1/Trough Scoring", "Will the robot score in Layer 1?", 0),
|
||||
new checkboxType("Processor Scoring", "Will the robot score in the processor?", 0),
|
||||
new checkboxType("Processor Scoring", "Will the robot score in the Processor?", 0),
|
||||
new checkboxType("Barge Scoring", "Will the robot score algae in the Barge?", 0),
|
||||
new dropdownType("Scoring Consistency", "How consistent is the robot at Scoring?", new String[]{"Does not work", "Worked a few times during testing", "Works most of the time", "Fails sometimes", "Never fails"}, 0),
|
||||
|
||||
new dropdownType("Auto type", "What autos does this team have?", new String[]{"No auto", "Simple Coral", "Simple Algae", "Complex Coral", "Complex Algae", "Other, Info in comments"}, 0),
|
||||
new textType("Auto Capability", "What autos does this team have?", ""),
|
||||
new dropdownType("Auto Consistency", "How consistent is the robot at Auto?", new String[]{"Does not work", "Worked a few times during testing", "Works most of the time", "Fails sometimes", "Never fails"}, 0),
|
||||
|
||||
new dropdownType("Climb type", "What does the robot do to climb?", new String[]{"No Climb", "Only Shallow", "Only Deep", "Both Shallow and Deep"}, 0),
|
||||
new dropdownType("Climb Consistency", "How consistent is the robot at climbing?", new String[]{"Does not work", "Worked a few times during testing", "Works most of the time", "Fails sometimes", "Never fails"}, 0),
|
||||
|
||||
new textType("Cool Comments", "Is there anything cool about the robot?", ""),
|
||||
|
||||
new textType("Comments", "Things go here", "Day 1:\n\nDay 2:\n\nDay 3:\n")
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.ridgebotics.ridgescout.ui.data;
|
||||
|
||||
|
||||
import static android.view.View.VISIBLE;
|
||||
import static androidx.navigation.fragment.FragmentKt.findNavController;
|
||||
|
||||
import android.os.Bundle;
|
||||
@@ -14,6 +15,7 @@ import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.ridgebotics.ridgescout.R;
|
||||
import com.ridgebotics.ridgescout.scoutingData.fields;
|
||||
import com.ridgebotics.ridgescout.utility.settingsManager;
|
||||
import com.ridgebotics.ridgescout.databinding.FragmentDataBinding;
|
||||
import com.ridgebotics.ridgescout.types.frcTeam;
|
||||
@@ -36,15 +38,26 @@ public class DataFragment extends Fragment {
|
||||
String evcode = settingsManager.getEVCode();
|
||||
|
||||
binding.fieldsButton.setOnClickListener(v -> {
|
||||
findNavController(this).navigate(R.id.action_navigation_data_to_navigation_data_fields_chooser);
|
||||
binding.fieldsButton.setEnabled(false);
|
||||
binding.fieldsButtons.setVisibility(VISIBLE);
|
||||
});
|
||||
|
||||
binding.fieldsMatchesButton.setOnClickListener(v -> {
|
||||
FieldsFragment.set_filename(fields.matchFieldsFilename);
|
||||
findNavController(this).navigate(R.id.action_navigation_data_to_navigation_data_fields);
|
||||
});
|
||||
|
||||
binding.fieldsPitsButton.setOnClickListener(v -> {
|
||||
FieldsFragment.set_filename(fields.pitsFieldsFilename);
|
||||
findNavController(this).navigate(R.id.action_navigation_data_to_navigation_data_fields);
|
||||
});
|
||||
|
||||
if(evcode.equals("unset")){
|
||||
binding.noEventError.setVisibility(View.VISIBLE);
|
||||
binding.noEventError.setVisibility(VISIBLE);
|
||||
|
||||
binding.buttons.setVisibility(View.VISIBLE);
|
||||
binding.buttons.setVisibility(VISIBLE);
|
||||
binding.teamsButton.setEnabled(false);
|
||||
binding.fieldsButton.setVisibility(View.VISIBLE);
|
||||
binding.fieldsButton.setVisibility(VISIBLE);
|
||||
|
||||
|
||||
return root;
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
package com.ridgebotics.ridgescout.ui.data;
|
||||
|
||||
import static androidx.navigation.fragment.FragmentKt.findNavController;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.ridgebotics.ridgescout.R;
|
||||
import com.ridgebotics.ridgescout.databinding.FragmentDataFieldsChooserBinding;
|
||||
import com.ridgebotics.ridgescout.scoutingData.fields;
|
||||
|
||||
public class FieldsChooserFragment extends Fragment {
|
||||
|
||||
FragmentDataFieldsChooserBinding binding;
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
|
||||
binding = FragmentDataFieldsChooserBinding.inflate(inflater, container, false);
|
||||
|
||||
binding.matchScoutingButton.setOnClickListener(v -> {
|
||||
FieldsFragment.set_filename(fields.matchFieldsFilename);
|
||||
findNavController(this).navigate(R.id.action_navigation_data_fields_chooser_to_navigation_data_fields);
|
||||
});
|
||||
|
||||
binding.pitScoutingButton.setOnClickListener(v -> {
|
||||
FieldsFragment.set_filename(fields.pitsFieldsFilename);
|
||||
findNavController(this).navigate(R.id.action_navigation_data_fields_chooser_to_navigation_data_fields);
|
||||
});
|
||||
|
||||
return binding.getRoot();
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,7 @@ import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.navigation.Navigation;
|
||||
|
||||
import com.ridgebotics.ridgescout.MainActivity;
|
||||
import com.ridgebotics.ridgescout.R;
|
||||
import com.ridgebotics.ridgescout.databinding.FragmentDataFieldsBinding;
|
||||
import com.ridgebotics.ridgescout.scoutingData.fields;
|
||||
@@ -66,6 +67,25 @@ public class FieldsFragment extends Fragment {
|
||||
|
||||
load_field_menu();
|
||||
|
||||
((MainActivity) getActivity()).setOnBackPressed(() -> {
|
||||
if(binding.saveButton.getVisibility() == View.GONE) return true;
|
||||
|
||||
AlertDialog.Builder alert = new AlertDialog.Builder(getContext());
|
||||
alert.setTitle("Warning!");
|
||||
alert.setMessage("You have not saved your progress!");
|
||||
alert.setPositiveButton("Return", null);
|
||||
alert.setNeutralButton("Quit without saving", (dialogInterface, i) -> {
|
||||
binding.saveButton.setVisibility(View.GONE);
|
||||
if(getActivity() != null)
|
||||
getActivity().onBackPressed();
|
||||
});
|
||||
alert.setCancelable(true);
|
||||
|
||||
alert.create().show();
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
return binding.getRoot();
|
||||
}
|
||||
|
||||
@@ -223,7 +243,7 @@ public class FieldsFragment extends Fragment {
|
||||
if(fields.save(filename, newValues))
|
||||
AlertManager.toast("Saved");
|
||||
|
||||
Navigation.findNavController((Activity) getContext(), R.id.nav_host_fragment_activity_main).navigate(R.id.action_navigation_data_fields_to_navigation_data_fields_chooser);
|
||||
Navigation.findNavController((Activity) getContext(), R.id.nav_host_fragment_activity_main).navigate(R.id.action_navigation_data_fields_to_navigation_data);
|
||||
});
|
||||
alert.setNegativeButton("Cancel", null);
|
||||
alert.setCancelable(true);
|
||||
|
||||
@@ -57,18 +57,7 @@ public class TransferFragment extends Fragment {
|
||||
});
|
||||
|
||||
binding.TBAButton.setOnClickListener(v -> {
|
||||
binding.noEventError.setVisibility(View.GONE);
|
||||
AlertDialog.Builder alert = new AlertDialog.Builder(getContext());
|
||||
alert.setTitle("Warning");
|
||||
alert.setMessage("This action requires internet.");
|
||||
alert.setCancelable(true);
|
||||
|
||||
alert.setPositiveButton("Ok", (dialog, which) -> {
|
||||
findNavController(this).navigate(R.id.action_navigation_transfer_to_navigation_tba);
|
||||
});
|
||||
|
||||
alert.setNegativeButton("Cancel", null);
|
||||
alert.create().show();
|
||||
findNavController(this).navigate(R.id.action_navigation_transfer_to_navigation_tba);
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user