From 54bd17a079460c83994b6d8712614835f8f38763 Mon Sep 17 00:00:00 2001 From: NoahLacks <77650157+NoahLacks@users.noreply.github.com> Date: Fri, 10 Jan 2025 14:27:03 -0500 Subject: [PATCH] Worked on tele and auto functionality --- .../com/example/scoutingapp/AutoActivity.java | 49 +++++------ .../com/example/scoutingapp/TeleActivity.java | 83 +++++++++++++++++++ 2 files changed, 106 insertions(+), 26 deletions(-) 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 4aac6e0..2c0bfcf 100644 --- a/ScoutingApp/app/src/main/java/com/example/scoutingapp/AutoActivity.java +++ b/ScoutingApp/app/src/main/java/com/example/scoutingapp/AutoActivity.java @@ -2,7 +2,8 @@ package com.example.scoutingapp; import android.content.Intent; import android.os.Bundle; -import android.view.View; +import android.os.Vibrator; +import android.util.Log; import android.widget.Button; import android.widget.CheckBox; @@ -19,24 +20,11 @@ public class AutoActivity extends AppCompatActivity { private int l1Scored = 0; private int processorScored = 0; private int netScored = 0; - private int startingLocation; private boolean reefPickup = false; private boolean canLeave = false; private boolean coralPickup = false; - private Button l4Button; - private Button l3Button; - private Button l2Button; - private Button l1Button; - private Button processorButton; - private Button netButton; - private Button nextButton; - - private CheckBox canLeaveBox; - private CheckBox reefPickupBox; - private CheckBox coralPickupBox; - @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -48,52 +36,60 @@ public class AutoActivity extends AppCompatActivity { return insets; }); - l4Button = (Button) findViewById(R.id.button_L4); - l3Button = (Button) findViewById(R.id.button_L3); - l2Button = (Button) findViewById(R.id.button_L2); - l1Button = (Button) findViewById(R.id.button_L1); - processorButton = (Button) findViewById(R.id.button_Processor); - netButton = (Button) findViewById(R.id.button_Net); + Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE); + + Button l4Button = (Button) findViewById(R.id.button_L4); + Button l3Button = (Button) findViewById(R.id.button_L3); + Button l2Button = (Button) findViewById(R.id.button_L2); + Button l1Button = (Button) findViewById(R.id.button_L1); + Button processorButton = (Button) findViewById(R.id.button_Processor); + Button netButton = (Button) findViewById(R.id.button_Net); + Button nextButton = (Button) findViewById(R.id.button_Next); + + CheckBox coralPickupBox = (CheckBox) findViewById(R.id.cb_coralPickup); + CheckBox reefPickupBox = (CheckBox) findViewById(R.id.cb_algaeReef); + CheckBox canLeaveBox = (CheckBox) findViewById(R.id.cb_CanLeave); + l4Button.setOnClickListener((v) -> l4Scored++); l4Button.setOnLongClickListener((v) -> { l4Scored--; - //vibration + vibrator.vibrate(250); return true; }); l3Button.setOnClickListener((v) -> l3Scored++); l3Button.setOnLongClickListener((v) -> { l3Scored--; - //vibration + vibrator.vibrate(250); return true; }); l2Button.setOnClickListener((v) -> l2Scored++); l2Button.setOnLongClickListener((v) -> { l2Scored--; - //vibration + vibrator.vibrate(250); return true; }); l1Button.setOnClickListener((v) -> l1Scored++); l1Button.setOnLongClickListener((v) -> { l1Scored--; - //vibration + vibrator.vibrate(250); return true; }); processorButton.setOnClickListener((v) -> processorScored++); processorButton.setOnLongClickListener((v) -> { processorScored--; - //vibration + vibrator.vibrate(250); return true; }); netButton.setOnClickListener((v) -> netScored++); netButton.setOnLongClickListener((v) -> { netScored--; - //vibration + vibrator.vibrate(250); return true; }); @@ -107,6 +103,7 @@ public class AutoActivity extends AppCompatActivity { //submit data Intent intent = new Intent(this, TeleActivity.class); startActivity(intent); + Log.d("test", intent.toString()); return true; }); } 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 6df8efa..3509e1e 100644 --- a/ScoutingApp/app/src/main/java/com/example/scoutingapp/TeleActivity.java +++ b/ScoutingApp/app/src/main/java/com/example/scoutingapp/TeleActivity.java @@ -1,6 +1,11 @@ package com.example.scoutingapp; +import android.content.Intent; import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.widget.Button; +import android.widget.CheckBox; import androidx.activity.EdgeToEdge; import androidx.appcompat.app.AppCompatActivity; @@ -9,6 +14,16 @@ import androidx.core.view.ViewCompat; import androidx.core.view.WindowInsetsCompat; public class TeleActivity extends AppCompatActivity { + private int l4Scored = 0; + private int l3Scored = 0; + private int l2Scored = 0; + private int l1Scored = 0; + private int processorScored = 0; + private int netScored = 0; + + private boolean reefPickup = false; + private boolean canLeave = false; + private boolean coralPickup = false; @Override protected void onCreate(Bundle savedInstanceState) { @@ -20,5 +35,73 @@ public class TeleActivity extends AppCompatActivity { v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom); return insets; }); + + Button l4Button = (Button) findViewById(R.id.button_L4); + Button l3Button = (Button) findViewById(R.id.button_L3); + Button l2Button = (Button) findViewById(R.id.button_L2); + Button l1Button = (Button) findViewById(R.id.button_L1); + Button processorButton = (Button) findViewById(R.id.button_Processor); + Button netButton = (Button) findViewById(R.id.button_Net); + Button nextButton = (Button) findViewById(R.id.button_Next); + + CheckBox coralPickupBox = (CheckBox) findViewById(R.id.cb_coralPickup); + CheckBox reefPickupBox = (CheckBox) findViewById(R.id.cb_algaeReef); + CheckBox canLeaveBox = (CheckBox) findViewById(R.id.cb_CanLeave); + + + l4Button.setOnClickListener((v) -> l4Scored++); + l4Button.setOnLongClickListener((v) -> { + l4Scored--; + //vibration + return true; + }); + + l3Button.setOnClickListener((v) -> l3Scored++); + l3Button.setOnLongClickListener((v) -> { + l3Scored--; + //vibration + return true; + }); + + l2Button.setOnClickListener((v) -> l2Scored++); + l2Button.setOnLongClickListener((v) -> { + l2Scored--; + //vibration + return true; + }); + + l1Button.setOnClickListener((v) -> l1Scored++); + l1Button.setOnLongClickListener((v) -> { + l1Scored--; + //vibration + return true; + }); + + processorButton.setOnClickListener((v) -> processorScored++); + processorButton.setOnLongClickListener((v) -> { + processorScored--; + //vibration + return true; + }); + + netButton.setOnClickListener((v) -> netScored++); + netButton.setOnLongClickListener((v) -> { + netScored--; + //vibration + return true; + }); + + canLeaveBox.setOnClickListener((v) -> canLeave = canLeaveBox.isChecked()); + + reefPickupBox.setOnClickListener((v) -> reefPickup = reefPickupBox.isChecked()); + + coralPickupBox.setOnClickListener((v) -> coralPickup = coralPickupBox.isChecked()); + + nextButton.setOnLongClickListener((v) -> { + //submit data + Intent intent = new Intent(this, EndActivity.class); + startActivity(intent); + return true; + }); } } \ No newline at end of file