Skip to content

Commit

Permalink
Add team selector to main screen
Browse files Browse the repository at this point in the history
Switches the student list, upload sheet and tab

Sheet ID's censored
  • Loading branch information
deadman96385 committed Feb 29, 2024
1 parent 794b8bb commit 5c31b81
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 15 deletions.
15 changes: 5 additions & 10 deletions app/src/main/java/com/databits/androidscouting/fragment/Crowd.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;

Expand Down Expand Up @@ -115,17 +114,13 @@ public boolean onMenuItemSelected(@NonNull MenuItem menuItem) {
})
.create();

ArrayList<String> student_list = debugPreference.getObject("student_list",
ArrayList.class);

if (student_list == null) {
scouterList = new LinkedList<>(Arrays.asList(getResources().
getStringArray(R.array.student_names)));
if (configPreference.getBoolean("altMode", false)) {
scouterList = new ArrayList<>(Arrays.asList(getResources()
.getStringArray(R.array.royal_students)));
} else {
scouterList = student_list;
scouterList = new ArrayList<>(Arrays.asList(getResources()
.getStringArray(R.array.databits_students)));
}
//scouterList = new LinkedList<>(Arrays.asList(getResources().
// getStringArray(R.array.student_names)));
ArrayAdapter<String> adapter = new ArrayAdapter<>(requireContext(),
R.layout.ui_list_item,
scouterList);
Expand Down
22 changes: 22 additions & 0 deletions app/src/main/java/com/databits/androidscouting/fragment/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,28 @@ public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
}
});

binding.buttonGroupSelector.setOnPositionChangedListener(position -> {
switch (position) {
case 0:
configPreference.remove("altMode");
break;
case 1:
configPreference.setBoolean("altMode",false);
break;
case 2:
configPreference.setBoolean("altMode",true);
break;
}
});

boolean alt = configPreference.getBoolean("altMode");
if (alt) {
binding.buttonGroupSelector.setPosition(1,false);
} else {
binding.buttonGroupSelector.setPosition(2,false);
}


if (lock) {
role_selector(controller);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public boolean onMenuItemSelected(@NonNull MenuItem menuItem) {
.create();

scouterList = new LinkedList<>(Arrays.asList(getResources().
getStringArray(R.array.student_names)));
getStringArray(R.array.databits_students)));
ArrayAdapter<String> adapter = new ArrayAdapter<>(requireContext(),
R.layout.ui_list_item,
scouterList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,13 @@ public boolean onMenuItemSelected(@NonNull MenuItem menuItem) {
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);

scouterList = new LinkedList<>(Arrays.asList(getResources()
.getStringArray(R.array.student_names)));
if (configPreference.getBoolean("altMode", false)) {
scouterList = new LinkedList<>(Arrays.asList(getResources()
.getStringArray(R.array.royal_students)));
} else {
scouterList = new LinkedList<>(Arrays.asList(getResources()
.getStringArray(R.array.databits_students)));
}

NavController controller = NavHostFragment.findNavController(Provision.this);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,15 @@ public SheetsUpdateTaskNew(Activity activity) {
ArrayList.class, new ArrayList<>()));
try {
// Sheet name and range to upload data to
String range = "SuperRawDatabase!A2:BL700";
String range;

if (configPreference.getBoolean("altMode", false)) {
// Royal Twrecks
range = "Raw Data!A2:BL700";
} else {
// Databits
range = "SuperRawDatabase!A2:BL700";
}

// Configure a new value range to store the data
ValueRange content = new ValueRange();
Expand Down Expand Up @@ -132,7 +140,14 @@ public SheetsUpdateTaskNew(Activity activity) {

@Override
protected void onPreExecute() {
String hardcode = "1ZKXLsKNM05-5BhIzbWjLOdvka-9NipSjVqFf_iG2eak";
String hardcode;
if (configPreference.getBoolean("altMode", false)) {
// Royal Twrecks
hardcode = "";
} else {
// Databits
hardcode = "";
}
spreadsheetId = configPreference.getString("linked_spreadsheet_id", hardcode);
}

Expand Down
70 changes: 70 additions & 0 deletions app/src/main/res/layout/fragment_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,74 @@
app:layout_constraintTop_toBottomOf="@+id/buttonPermissions"
/>

<com.addisonelliott.segmentedbutton.SegmentedButtonGroup
android:id="@+id/buttonGroup_selector"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="16dp"
android:elevation="2dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/altModeSelectorText"
app:sbg_divider="@color/accent_color"
app:sbg_dividerPadding="@dimen/sbg_dividerPadding"
app:sbg_dividerWidth="@dimen/sbg_dividerWidth"
app:sbg_position="0"
app:sbg_radius="2dp"
app:sbg_ripple="true"
app:sbg_selectedBackground="@color/accent_color"
app:sbg_selectionAnimationDuration="250"
app:sbg_selectionAnimationInterpolator="fastOutSlowIn"
>

<com.addisonelliott.segmentedbutton.SegmentedButton
android:id="@+id/button_one"
android:layout_width="7dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:padding="5dp"
app:autoSizeTextType="uniform"
app:sb_selectedTextColor="@color/white"
app:sb_text="Neither"
app:sb_textColor="@color/text_color"
/>

<com.addisonelliott.segmentedbutton.SegmentedButton
android:id="@+id/button_two"
android:layout_width="7dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:padding="5dp"
app:autoSizeTextType="uniform"
app:sb_selectedTextColor="@color/white"
app:sb_text="Databits 3883"
app:sb_textColor="@color/text_color"
/>

<com.addisonelliott.segmentedbutton.SegmentedButton
android:id="@+id/button_three"
android:layout_width="7dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:padding="5dp"
app:autoSizeTextType="uniform"
app:sb_selectedTextColor="@color/white"
app:sb_text="Royal T-Wrecks 3206"
app:sb_textColor="@color/text_color"
/>
</com.addisonelliott.segmentedbutton.SegmentedButtonGroup>
<TextView
android:id="@+id/altModeSelectorText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="Team Selector"
android:textColor="@color/text_color"
android:textSize="24sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/team_saved_button"
/>

</androidx.constraintlayout.widget.ConstraintLayout>

0 comments on commit 5c31b81

Please sign in to comment.