Worked on tele and auto functionality

This commit is contained in:
NoahLacks 2025-01-10 14:27:03 -05:00 committed by GitHub
parent 4a12843824
commit 54bd17a079
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 106 additions and 26 deletions

View File

@ -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;
});
}

View File

@ -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;
});
}
}