Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .idea/AndroidProjectSystem.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/deploymentTargetSelector.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/deviceManager.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/planningMode.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ dependencies {
implementation(libs.material)
implementation(libs.activity)
implementation(libs.constraintlayout)
implementation(libs.mpandroidchart)
testImplementation(libs.junit)
androidTestImplementation(libs.ext.junit)
androidTestImplementation(libs.espresso.core)
Expand Down
Binary file modified app/release/app-release.apk
Binary file not shown.
Binary file modified app/release/baselineProfiles/0/app-release.dm
Binary file not shown.
Binary file modified app/release/baselineProfiles/1/app-release.dm
Binary file not shown.
11 changes: 11 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" >

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />

<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
Expand All @@ -10,6 +17,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.RoboticsScoutingMatchApp"
android:requestLegacyExternalStorage="true"
tools:targetApi="31" >
<activity
android:name=".ActivityCompetitionSelection"
Expand All @@ -36,6 +44,9 @@
android:name=".activityPreMatch"
android:exported="false" >
</activity>
<activity
android:name=".activityDataShowing"
android:exported="false" />
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,22 @@
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.graphics.Insets;
import androidx.core.view.GravityCompat;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.drawerlayout.widget.DrawerLayout;

import com.google.android.material.navigation.NavigationView;

import java.io.BufferedReader;
import java.io.File;
Expand All @@ -24,26 +30,56 @@
import java.io.InputStreamReader;
import java.util.Calendar;

/**
* Launcher activity for the app. Handles competition selection and data persistence checks.
* Serves as the home screen with navigation to the Data Dashboard.
*/
public class ActivityCompetitionSelection extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
EdgeToEdge.enable(this);
setContentView(R.layout.activity_competition_selection);
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {

// Sidebar/Navigation Drawer Setup
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

DrawerLayout drawer = findViewById(R.id.drawer_layout);
NavigationView navigationView = findViewById(R.id.nav_view);

// Adjust for system status bars
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.app_bar), (v, insets) -> {
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
v.setPadding(0, systemBars.top, 0, 0);
return insets;
});

ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.addDrawerListener(toggle);
toggle.syncState();

// Centralized navigation logic
navigationView.setNavigationItemSelectedListener(item -> {
int id = item.getItemId();
if (id == R.id.nav_dashboard) {
// Open Data Dashboard
startActivity(new Intent(this, activityDataShowing.class));
} else if (id == R.id.nav_scout) {
// Reset/Restart Scouting flow
Intent intent = new Intent(this, ActivityCompetitionSelection.class);
intent.putExtra("chooseNewCompetition", true);
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
drawer.closeDrawer(GravityCompat.START);
return true;
});

U u = new U();
RadioGroup competitionRadioGroup = findViewById(R.id.competition_radio_group);
// RadioButton wpiButton = findViewById(R.id.comp_wpi_button);
// RadioButton uvmButton = findViewById(R.id.comp_uvm_button);
// RadioButton dcmpButton = findViewById(R.id.comp_dcmp);
// RadioButton worldsButton = findViewById(R.id.comp_worlds);
// RadioButton testButton = findViewById(R.id.comp_test);
Button saveButton = findViewById(R.id.save_button);
Toast unfilledMessage = new Toast(this);
unfilledMessage.setDuration(Toast.LENGTH_SHORT);
Expand All @@ -58,6 +94,7 @@ protected void onCreate(Bundle savedInstanceState) {
scoutName = "";
}

// Persistence check: If a competition was already selected today, skip this screen
final String FILENAME = "matchAndDate";
File file = new File(this.getFilesDir(), FILENAME);
Calendar now = Calendar.getInstance();
Expand All @@ -76,14 +113,15 @@ protected void onCreate(Bundle savedInstanceState) {
dateAndMatchString += reader.readLine();
reader.close();
} catch (FileNotFoundException e) {
Log.e("File Not Found Exception", e.toString());
Log.e("ActivityComp", "Persisted file not found", e);
} catch (IOException e) {
Log.e("IOException", e.toString());
Log.e("ActivityComp", "Read error", e);
}
}
if (!dateAndMatchString.isEmpty()) {
String fileDate = u.untilNextComma(dateAndMatchString);
if (fileDate.equals(currentDate)) {
// Fast-forward to scouting if date matches
Intent i = new Intent(this, activityPreMatch.class);
i.putExtra("competition", u.nextCommaOn(dateAndMatchString));
i.putExtra("scoutName", scoutName);
Expand All @@ -98,14 +136,15 @@ protected void onCreate(Bundle savedInstanceState) {
if(u.getData(competitionRadioGroup).isEmpty()){
response = "Please choose current competition to be scouting";
}else{
// Save selection locally
String fileContents = finalCurrentDate + "," + u.getData(competitionRadioGroup);
try(FileOutputStream fos = this.openFileOutput(FILENAME, Context.MODE_PRIVATE)){
fos.write(fileContents.getBytes());
} catch(FileNotFoundException e){
Log.e("File Not Found Exception", e.toString());
} catch(IOException e){
Log.e("IO Exception", e.toString());
Log.e("ActivityComp", "Write error", e);
}

// Move to Pre-Match
Intent i = new Intent(this, activityPreMatch.class);
i.putExtra("competition", u.getData(competitionRadioGroup));
i.putExtra("scoutName", scoutName);
Expand All @@ -117,4 +156,15 @@ protected void onCreate(Bundle savedInstanceState) {
}
});
}
}

@Override
public void onBackPressed() {
// Handle Sidebar Drawer if open
DrawerLayout drawer = findViewById(R.id.drawer_layout);
if (drawer != null && drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
} else {
super.onBackPressed();
}
}
}
Loading