From a22829b3cbd6a7f5694ba1047a3e55325c95bd11 Mon Sep 17 00:00:00 2001 From: wildercayden Date: Sun, 9 Mar 2025 13:27:48 -0400 Subject: [PATCH] Added text at the bottom for match, made the app team colors, and fixed end activity --- ScoutingApp/app/src/main/AndroidManifest.xml | 3 + .../com/example/scoutingapp/AutoActivity.java | 28 ++++- .../com/example/scoutingapp/EndActivity.java | 81 ++++++++++++- .../com/example/scoutingapp/MainActivity.java | 2 +- .../com/example/scoutingapp/TeleActivity.java | 20 +++- .../example/scoutingapp/startingActivity.java | 23 ++-- .../app/src/main/res/layout/activity_auto.xml | 42 ++++++- .../app/src/main/res/layout/activity_end.xml | 108 ++++++++++++++++-- .../app/src/main/res/layout/activity_main.xml | 42 +++++-- .../src/main/res/layout/activity_starting.xml | 19 ++- .../app/src/main/res/layout/activity_tele.xml | 44 +++++-- 11 files changed, 353 insertions(+), 59 deletions(-) diff --git a/ScoutingApp/app/src/main/AndroidManifest.xml b/ScoutingApp/app/src/main/AndroidManifest.xml index d08280e..51bce65 100644 --- a/ScoutingApp/app/src/main/AndroidManifest.xml +++ b/ScoutingApp/app/src/main/AndroidManifest.xml @@ -17,6 +17,9 @@ android:supportsRtl="true" android:theme="@style/Theme.ScoutingApp" tools:targetApi="31"> + diff --git a/ScoutingApp/app/src/main/java/com/example/scoutingapp/AutoActivity.java b/ScoutingApp/app/src/main/java/com/example/scoutingapp/AutoActivity.java index 2216cc6..ec507d7 100644 --- a/ScoutingApp/app/src/main/java/com/example/scoutingapp/AutoActivity.java +++ b/ScoutingApp/app/src/main/java/com/example/scoutingapp/AutoActivity.java @@ -2,6 +2,7 @@ package com.example.scoutingapp; import android.content.Context; import android.content.Intent; +import android.graphics.Color; import android.os.Bundle; import android.util.Log; import android.widget.Button; @@ -25,7 +26,7 @@ public class AutoActivity extends AppCompatActivity { private int l1Scored = 0; private int processorScored = 0; private int netScored = 0; - + private boolean alliance = true; private boolean reefPickup = false; private boolean canLeave = false; private boolean coralPickup = false; @@ -41,6 +42,7 @@ public class AutoActivity extends AppCompatActivity { public static final String Match_key = "MATCHCONFIRM"; public static final String Team_key = "TEAMCONFIRM"; public static final String Postion_key = "POSTIONKEY"; + public static final String Alliance_key = "ALLIANCECONFIRM"; @Override protected void onCreate(Bundle savedInstanceState) { @@ -52,11 +54,23 @@ public class AutoActivity extends AppCompatActivity { v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom); return insets; }); - Intent intentInput = getIntent(); - eventString = intentInput.getStringExtra(MainActivity.eventKey); - matchString = intentInput.getStringExtra(MainActivity.matchKey); - TeamString = intentInput.getStringExtra(MainActivity.teamKey); - startingPostionString = intentInput.getStringExtra(MainActivity.postionKey); + Intent intentinput = getIntent(); + eventString = intentinput.getStringExtra(startingActivity.Event_Key); + matchString = intentinput.getStringExtra(startingActivity.Match_key); + TeamString = intentinput.getStringExtra(startingActivity.Team_key); + startingPostionString = intentinput.getStringExtra(startingActivity.Postion_key); + alliance = intentinput.getBooleanExtra(startingActivity.Alliance_key, false); + TextView textViewTeam = findViewById(R.id.teamnumber); + textViewTeam.setText("Team " + TeamString); + TextView textViewMatch = findViewById(R.id.matchNumber); + textViewMatch.setText("Match " + matchString); + if (alliance == true) { + textViewTeam.setBackgroundColor(Color.parseColor("#F71000")); //red + textViewMatch.setBackgroundColor(Color.parseColor("#F71000")); + } else { + textViewTeam.setBackgroundColor(Color.parseColor("#0084ff")); + textViewMatch.setBackgroundColor(Color.parseColor("#0084ff"));//blue + } l4Button = (Button) findViewById(R.id.button_L4); @@ -146,6 +160,8 @@ public class AutoActivity extends AppCompatActivity { intent.putExtra(Event_Key, eventString); intent.putExtra(Match_key, matchString); intent.putExtra(Team_key, TeamString); + intent.putExtra(Postion_key, startingPostionString); + intent.putExtra(Alliance_key, alliance); startActivity(intent); return true; }); diff --git a/ScoutingApp/app/src/main/java/com/example/scoutingapp/EndActivity.java b/ScoutingApp/app/src/main/java/com/example/scoutingapp/EndActivity.java index 4e59198..1860a04 100644 --- a/ScoutingApp/app/src/main/java/com/example/scoutingapp/EndActivity.java +++ b/ScoutingApp/app/src/main/java/com/example/scoutingapp/EndActivity.java @@ -1,11 +1,18 @@ package com.example.scoutingapp; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Locale; import android.content.Intent; +import android.graphics.Color; import android.net.Uri; import android.os.Bundle; +import android.util.Log; import android.view.View; import android.widget.Button; +import android.widget.EditText; +import android.widget.TextView; import androidx.activity.EdgeToEdge; @@ -14,15 +21,23 @@ import androidx.core.graphics.Insets; import androidx.core.view.ViewCompat; import androidx.core.view.WindowInsetsCompat; +import java.io.FileWriter; +import java.io.IOException; import java.util.List; import java.io.File; public class EndActivity extends AppCompatActivity { - private String eventString, matchString, TeamString; + private String eventString, matchString, TeamString, noteString; + private int climbLevel = 0; + private EditText noteText; + public static final String Team_key = "TEAMCONFIRM"; public static final String Event_Key = "EVENTCONFIRM"; public static final String Match_key = "MATCHCONFIRM"; + private Boolean alliance = true; //true = red, false = blue + private Button deepClimbButton, shallowClimbButton, parkButton, noClimbButton; + @Override protected void onCreate(Bundle savedInstanceState) { @@ -34,15 +49,35 @@ public class EndActivity extends AppCompatActivity { v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom); return insets; }); + Intent intent = new Intent(this, MainActivity.class); + noteText = (EditText) findViewById(R.id.Notes); Intent intentinput = getIntent(); eventString = intentinput.getStringExtra(TeleActivity.Event_Key); matchString = intentinput.getStringExtra(TeleActivity.Match_key); TeamString = intentinput.getStringExtra(TeleActivity.Team_key); + alliance = intentinput.getBooleanExtra(TeleActivity.Alliance_key, false); + TextView textViewTeam = findViewById(R.id.teamnumber); + textViewTeam.setText("Team " + TeamString); + TextView textViewMatch = findViewById(R.id.matchNumber); + textViewMatch.setText("Match " + matchString); + if (alliance == true) { + textViewTeam.setBackgroundColor(Color.parseColor("#F71000")); //red + textViewMatch.setBackgroundColor(Color.parseColor("#F71000")); + } else { + textViewTeam.setBackgroundColor(Color.parseColor("#0084ff")); + textViewMatch.setBackgroundColor(Color.parseColor("#0084ff"));//blue + } + + deepClimbButton = (Button) findViewById(R.id.RB_DeepClimb); + shallowClimbButton = (Button) findViewById(R.id.RB_ShallowClimb); + parkButton = (Button) findViewById(R.id.RB_Park); + noClimbButton = (Button) findViewById(R.id.RB_NoClimb); Button submit = (Button) findViewById(R.id.Submit_button); submit.setOnClickListener(new View.OnClickListener() { - public void onClick(View view) { + noteString = noteText.getText().toString(); + csvMake(); String csvFileString = eventString+matchString+TeamString+".csv"; Submit submit = new Submit(); //Writes data to file to make google sheet read it as a list @@ -52,6 +87,8 @@ public class EndActivity extends AppCompatActivity { //Uploads the Data to the Google sheet submit.uploadSheets(EndActivity.this, csvFileString); //submit.renameFile(EndActivity.this, csvFileString); + startActivity(intent); + } }); @@ -64,10 +101,46 @@ public class EndActivity extends AppCompatActivity { } }); + deepClimbButton.setOnClickListener((v) -> { + climbLevel = 3; + }); + + shallowClimbButton.setOnClickListener((v) -> { + climbLevel = 2; + }); + + parkButton.setOnClickListener((v) -> { + climbLevel = 1; + }); + + noClimbButton.setOnClickListener((v) -> { + climbLevel = 0; + }); + } + + public void csvMake() { + //adds the strings + String timestamp = getTimestamp(); + String CSVLine = String.format( + "%s, %s, %s", climbLevel, noteString, timestamp + ); + + //makes the file + File csvFile = new File(this.getFilesDir(), eventString + matchString + TeamString + ".csv"); + Log.d("CSVFile", "File created/written at: " + csvFile.getAbsolutePath()); + //writes to file + try (FileWriter writer = new FileWriter(csvFile, true)) { + writer.append(CSVLine).append("\n"); + Log.d("CSVFilePath", csvFile.getAbsolutePath()); + } catch (IOException e) { + Log.d("CSVFail", "CSV didn't make"); + } } - - + public static String getTimestamp() { + SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yy HH:mm:ss.SSS", Locale.getDefault()); + return sdf.format(new Date()); + } } diff --git a/ScoutingApp/app/src/main/java/com/example/scoutingapp/MainActivity.java b/ScoutingApp/app/src/main/java/com/example/scoutingapp/MainActivity.java index 077ebc2..f06ee5a 100644 --- a/ScoutingApp/app/src/main/java/com/example/scoutingapp/MainActivity.java +++ b/ScoutingApp/app/src/main/java/com/example/scoutingapp/MainActivity.java @@ -260,7 +260,7 @@ public class MainActivity extends AppCompatActivity { private void makeIntent() { - Intent intent = new Intent(this, AutoActivity.class); + Intent intent = new Intent(this, startingActivity.class); intent.putExtra(eventKey, eventString); intent.putExtra(matchKey, matchNumberString); intent.putExtra(teamKey, teamString); diff --git a/ScoutingApp/app/src/main/java/com/example/scoutingapp/TeleActivity.java b/ScoutingApp/app/src/main/java/com/example/scoutingapp/TeleActivity.java index ea29b32..3da7868 100644 --- a/ScoutingApp/app/src/main/java/com/example/scoutingapp/TeleActivity.java +++ b/ScoutingApp/app/src/main/java/com/example/scoutingapp/TeleActivity.java @@ -2,6 +2,7 @@ package com.example.scoutingapp; import android.content.Context; import android.content.Intent; +import android.graphics.Color; import android.os.Bundle; import android.util.Log; import android.widget.Button; @@ -29,6 +30,7 @@ public class TeleActivity extends AppCompatActivity { private boolean reefPickup = false; private boolean canLeave = false; private boolean coralPickup = false; + private boolean alliance = true; private Button l4Button; private Button l3Button; @@ -41,6 +43,7 @@ public class TeleActivity extends AppCompatActivity { public static final String Match_key = "MATCHCONFIRM"; public static final String Team_key = "TEAMCONFIRM"; public static final String Postion_key = "POSTIONKEY"; + public static final String Alliance_key= "ALLIANCECONFIRM"; @Override protected void onCreate(Bundle savedInstanceState) { @@ -57,6 +60,18 @@ public class TeleActivity extends AppCompatActivity { matchString = intentinput.getStringExtra(AutoActivity.Match_key); TeamString = intentinput.getStringExtra(AutoActivity.Team_key); startingPostionString = intentinput.getStringExtra(AutoActivity.Postion_key); + alliance = intentinput.getBooleanExtra(AutoActivity.Alliance_key, false); + TextView textViewTeam = findViewById(R.id.teamnumber); + textViewTeam.setText("Team " + TeamString); + TextView textViewMatch = findViewById(R.id.matchNumber); + textViewMatch.setText("Match " + matchString); + if (alliance == true) { + textViewTeam.setBackgroundColor(Color.parseColor("#F71000")); //red + textViewMatch.setBackgroundColor(Color.parseColor("#F71000")); + } else { + textViewTeam.setBackgroundColor(Color.parseColor("#0084ff")); + textViewMatch.setBackgroundColor(Color.parseColor("#0084ff"));//blue + } l4Button = (Button) findViewById(R.id.button_L4); @@ -146,6 +161,7 @@ public class TeleActivity extends AppCompatActivity { intent.putExtra(Event_Key, eventString); intent.putExtra(Match_key, matchString); intent.putExtra(Team_key, TeamString); + intent.putExtra(Alliance_key, alliance); startActivity(intent); return true; }); @@ -201,11 +217,11 @@ public class TeleActivity extends AppCompatActivity { ); //makes the file - File csvFile = new File(this.getFilesDir(), eventString+matchString+TeamString+".csv"); + File csvFile = new File(this.getFilesDir(), eventString + matchString + TeamString + ".csv"); Log.d("CSVFile", "File created/written at: " + csvFile.getAbsolutePath()); //writes to file try (FileWriter writer = new FileWriter(csvFile, true)) { - writer.append(CSVLine).append("\n"); + writer.append(CSVLine).append(","); Log.d("CSVFilePath", csvFile.getAbsolutePath()); } catch (IOException e) { Log.d("CSVFail", "CSV didn't make"); diff --git a/ScoutingApp/app/src/main/java/com/example/scoutingapp/startingActivity.java b/ScoutingApp/app/src/main/java/com/example/scoutingapp/startingActivity.java index e3d9807..275632c 100644 --- a/ScoutingApp/app/src/main/java/com/example/scoutingapp/startingActivity.java +++ b/ScoutingApp/app/src/main/java/com/example/scoutingapp/startingActivity.java @@ -16,8 +16,8 @@ import androidx.core.view.ViewCompat; import androidx.core.view.WindowInsetsCompat; public class startingActivity extends AppCompatActivity { - private String eventString, matchString, teamString, startingPostionString; - private Boolean alliance = true; //true = red, false = blue + private String eventString, matchString, teamString, startingPostionString, allianceString; + private boolean alliance = true; public static final String Event_Key = "EVENTCONFIRM"; public static final String Match_key = "MATCHCONFIRM"; public static final String Team_key = "TEAMCONFIRM"; @@ -37,13 +37,18 @@ public class startingActivity extends AppCompatActivity { eventString = intentInput.getStringExtra(MainActivity.eventKey); matchString = intentInput.getStringExtra(MainActivity.matchKey); teamString = intentInput.getStringExtra(MainActivity.teamKey); - alliance = intentInput.getBooleanExtra(MainActivity.allianceKey, false); - TextView textView = findViewById(R.id.teamnumber); - textView.setText(teamString); - if (alliance == true) { - textView.setBackgroundColor(Color.parseColor("#F71000")); //red + allianceString = intentInput.getStringExtra(MainActivity.allianceKey); + TextView textViewTeam = findViewById(R.id.teamnumber); + textViewTeam.setText("Team " + teamString); + TextView textViewMatch = findViewById(R.id.matchNumber); + textViewMatch.setText("Match " + matchString); + if ("red".equals(allianceString)) { + textViewTeam.setBackgroundColor(Color.parseColor("#F71000")); //red + textViewMatch.setBackgroundColor(Color.parseColor("#F71000")); } else { - textView.setBackgroundColor(Color.parseColor("#0084ff"));//blue + textViewTeam.setBackgroundColor(Color.parseColor("#0084ff")); + textViewMatch.setBackgroundColor(Color.parseColor("#0084ff"));//blue + alliance = false; } Button nextButton = (Button) findViewById(R.id.nextButton); @@ -102,7 +107,7 @@ public class startingActivity extends AppCompatActivity { intent.putExtra(Match_key, matchString); intent.putExtra(Team_key, teamString); intent.putExtra(Postion_key, startingPostionString); - intent.putExtra(Alliance_key, alliance); + intent.putExtra(Alliance_key, allianceString); startActivity(intent); } } \ No newline at end of file diff --git a/ScoutingApp/app/src/main/res/layout/activity_auto.xml b/ScoutingApp/app/src/main/res/layout/activity_auto.xml index 660a03b..946c572 100644 --- a/ScoutingApp/app/src/main/res/layout/activity_auto.xml +++ b/ScoutingApp/app/src/main/res/layout/activity_auto.xml @@ -5,8 +5,33 @@ android:id="@+id/main" android:layout_width="match_parent" android:layout_height="match_parent" + android:background="#000000" tools:context=".AutoActivity"> + + + + @@ -102,16 +128,16 @@ android:id="@+id/button_Processor" android:layout_width="0dp" android:layout_height="0dp" - android:backgroundTint="#402196F3" + android:backgroundTint="#6B0EE906" android:text="@string/processor" android:textColor="#000000" android:textSize="34sp" app:cornerRadius="0dp" - app:layout_constraintBottom_toTopOf="@+id/linearLayout" + app:layout_constraintBottom_toTopOf="@+id/matchNumber" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toEndOf="@+id/button_Net" app:layout_constraintTop_toBottomOf="@+id/imageView2" - app:strokeColor="#2196F3" + app:strokeColor="#0EE906" app:strokeWidth="5dp" tools:ignore="VisualLintButtonSize" /> @@ -119,16 +145,16 @@ android:id="@+id/button_Net" android:layout_width="0dp" android:layout_height="0dp" - android:backgroundTint="#402196F3" + android:backgroundTint="#6B0EE906" android:text="@string/net" android:textColor="#000000" android:textSize="34sp" app:cornerRadius="0dp" - app:layout_constraintBottom_toTopOf="@+id/linearLayout" + app:layout_constraintBottom_toTopOf="@+id/teamnumber" app:layout_constraintEnd_toStartOf="@+id/button_Processor" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/imageView2" - app:strokeColor="#2196F3" + app:strokeColor="#0EE906" app:strokeWidth="5dp" tools:ignore="VisualLintButtonSize" /> @@ -147,6 +173,7 @@ android:layout_height="wrap_content" android:layout_weight="1" android:text="@string/can_leave" + android:textColor="#FFFFFF" tools:ignore="VisualLintButtonSize" /> @@ -174,6 +203,7 @@ android:layout_marginTop="8dp" android:layout_marginEnd="8dp" android:text="@string/hold_button_to_ndecrement" + android:textColor="#FFFFFF" app:layout_constraintBottom_toTopOf="@+id/imageView2" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toEndOf="@+id/textView2" diff --git a/ScoutingApp/app/src/main/res/layout/activity_end.xml b/ScoutingApp/app/src/main/res/layout/activity_end.xml index 46ca7a7..56777e5 100644 --- a/ScoutingApp/app/src/main/res/layout/activity_end.xml +++ b/ScoutingApp/app/src/main/res/layout/activity_end.xml @@ -5,25 +5,115 @@ android:id="@+id/main" android:layout_width="match_parent" android:layout_height="match_parent" + android:background="#000000" tools:context=".EndActivity"> -