diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 1fbe258..1c7614f 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -5,7 +5,7 @@ plugins { var versionMajor = 3 var versionMinor = 0 -var versionPatch = 7 +var versionPatch = 9 android { namespace = "com.team3663.scouting_app" diff --git a/app/src/main/java/com/team3663/scouting_app/activities/MatchTally.java b/app/src/main/java/com/team3663/scouting_app/activities/MatchTally.java index 33ea2e9..5b5bd5f 100644 --- a/app/src/main/java/com/team3663/scouting_app/activities/MatchTally.java +++ b/app/src/main/java/com/team3663/scouting_app/activities/MatchTally.java @@ -225,8 +225,8 @@ else if (current_X_Absolute < matchBinding.butRightZone.getX()) matchBinding.butPickup.setVisibility(View.INVISIBLE); // Enable the climb button - matchBinding.butClimb.setEnabled(true); - matchBinding.butClimb.setClickable(true); + matchBinding.butClimb.setEnabled(in_alliance_zone); + matchBinding.butClimb.setClickable(in_alliance_zone); climb_button_pressed = false; // Certain actions can't be set from a non-UI thread (like within a TimerTask that runs on a @@ -785,6 +785,15 @@ private void setRobotLocation(float in_X, float in_Y) { starting_X_Absolute = Math.min(Math.max(in_X, matchBinding.FieldTouch.getWidth() * (100.0f - Constants.Match.START_LINE_X) / 100.0f - offset), matchBinding.FieldTouch.getWidth() * (100.0f - Constants.Match.START_LINE_X) / 100.0f + offset); } + // Ensure we aren't placing a robot where it can't be located - 2026 Season + if ((starting_Y_Absolute > (Constants.Match.HUB_TOP_Y_PERCENT * matchBinding.FieldTouch.getHeight())) && (starting_Y_Absolute < (Constants.Match.HUB_BOTTOM_Y_PERCENT * matchBinding.FieldTouch.getHeight()))) { + if ((blue_alliance && currentAllianceOnLeft.equals(Constants.Match.ORIENTATION_BLUE_ON_LEFT)) || + (!blue_alliance && currentAllianceOnLeft.equals(Constants.Match.ORIENTATION_RED_ON_LEFT))) + starting_X_Absolute = matchBinding.FieldTouch.getWidth() * Constants.Match.START_LINE_X / 100.0f - offset; + else + starting_X_Absolute = matchBinding.FieldTouch.getWidth() * (100.0f - Constants.Match.START_LINE_X) / 100.0f + offset; + } + // Save off the correct relative values based on the orientation if (currentAllianceOnLeft.equals(Constants.Match.ORIENTATION_RED_ON_LEFT)) { starting_X_Relative = starting_X_Absolute; @@ -916,11 +925,6 @@ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { private void initZoneButtons() { // Set up an OnClick listener per button matchBinding.butLeftZone.setOnClickListener(view -> { - // We'll use the button click to determine if we should allow or disallow shooting / climbing but won't process - // anything else if we're not in Tele mode. - in_alliance_zone = ((currentAllianceOnLeft.equals(Constants.Match.ORIENTATION_RED_ON_LEFT)) && team_alliance.substring(0, 1).equalsIgnoreCase("R")) || - ((currentAllianceOnLeft.equals(Constants.Match.ORIENTATION_BLUE_ON_LEFT)) && team_alliance.substring(0, 1).equalsIgnoreCase("B")); - // If the match hasn't even started yet, just return if (Globals.CurrentMatchPhase.equals(Constants.Phases.NONE)) return; @@ -943,8 +947,6 @@ private void initZoneButtons() { }); matchBinding.butCenterZone.setOnClickListener(view -> { - in_alliance_zone = false; - // If the match hasn't even started yet, just return if (Globals.CurrentMatchPhase.equals(Constants.Phases.NONE)) return; @@ -968,11 +970,6 @@ private void initZoneButtons() { }); matchBinding.butRightZone.setOnClickListener(view -> { - // We'll use the button click to determine if we should allow or disallow shooting / climbing but won't process - // anything else if we're not in Tele mode. - in_alliance_zone = ((!currentAllianceOnLeft.equals(Constants.Match.ORIENTATION_RED_ON_LEFT)) || !team_alliance.substring(0, 1).equalsIgnoreCase("R")) && - ((!currentAllianceOnLeft.equals(Constants.Match.ORIENTATION_BLUE_ON_LEFT)) || !team_alliance.substring(0, 1).equalsIgnoreCase("B")); - // If the match hasn't even started yet, just return if (Globals.CurrentMatchPhase.equals(Constants.Phases.NONE)) return; @@ -995,16 +992,48 @@ private void initZoneButtons() { }); matchBinding.butLeftZone.setOnTouchListener((view, motionEvent) -> { + // only handle DOWN actions + if (motionEvent.getAction() == MotionEvent.ACTION_UP) return false; + + // We'll use the button click to determine if we should allow or disallow shooting / climbing but won't process + // anything else if we're not in Tele mode. + in_alliance_zone = ((currentAllianceOnLeft.equals(Constants.Match.ORIENTATION_RED_ON_LEFT)) && team_alliance.substring(0, 1).equalsIgnoreCase("R")) || + ((currentAllianceOnLeft.equals(Constants.Match.ORIENTATION_BLUE_ON_LEFT)) && team_alliance.substring(0, 1).equalsIgnoreCase("B")); + tele_button_position_x = matchBinding.butLeftZone.getX(); tele_button_position_y = matchBinding.butLeftZone.getY(); matchBinding.FieldTouch.dispatchTouchEvent(motionEvent); return false; }); matchBinding.butCenterZone.setOnTouchListener((view, motionEvent) -> { + // only handle DOWN actions + if (motionEvent.getAction() == MotionEvent.ACTION_UP) return false; + + // if the alliance zone is on the LEFT, check the left edge of the robot + in_alliance_zone = false; + if (((currentAllianceOnLeft.equals(Constants.Match.ORIENTATION_RED_ON_LEFT)) + && team_alliance.substring(0, 1).equalsIgnoreCase("R")) + || ((currentAllianceOnLeft.equals(Constants.Match.ORIENTATION_BLUE_ON_LEFT)) + && team_alliance.substring(0, 1).equalsIgnoreCase("B"))) { + if (motionEvent.getX() <= (matchBinding.textRobot.getWidth() / 2f)) + in_alliance_zone = true; + // otherwise the alliance zone is on the RIGHT, check the right edge of the robot + } else + if (motionEvent.getX() >= (matchBinding.butCenterZone.getWidth() - matchBinding.textRobot.getWidth() / 2f)) + in_alliance_zone = true; + tele_button_position_x = matchBinding.butCenterZone.getX(); tele_button_position_y = matchBinding.butCenterZone.getY(); matchBinding.FieldTouch.dispatchTouchEvent(motionEvent); return false; }); matchBinding.butRightZone.setOnTouchListener((view, motionEvent) -> { + // only handle DOWN actions + if (motionEvent.getAction() == MotionEvent.ACTION_UP) return false; + + // We'll use the button click to determine if we should allow or disallow shooting / climbing but won't process + // anything else if we're not in Tele mode. + in_alliance_zone = ((!currentAllianceOnLeft.equals(Constants.Match.ORIENTATION_RED_ON_LEFT)) || !team_alliance.substring(0, 1).equalsIgnoreCase("R")) && + ((!currentAllianceOnLeft.equals(Constants.Match.ORIENTATION_BLUE_ON_LEFT)) || !team_alliance.substring(0, 1).equalsIgnoreCase("B")); + tele_button_position_x = matchBinding.butRightZone.getX(); tele_button_position_y = matchBinding.butRightZone.getY(); matchBinding.FieldTouch.dispatchTouchEvent(motionEvent); diff --git a/app/src/main/java/com/team3663/scouting_app/config/Constants.java b/app/src/main/java/com/team3663/scouting_app/config/Constants.java index ab3f459..09acc13 100644 --- a/app/src/main/java/com/team3663/scouting_app/config/Constants.java +++ b/app/src/main/java/com/team3663/scouting_app/config/Constants.java @@ -60,6 +60,8 @@ public static class Match { public static float START_LINE_X = 24.17f; public static final int TRANSITION_EVENT_DNE = -1; public static final int SEEKBAR_MAX = 60; + public static final float HUB_TOP_Y_PERCENT = 129f / 337f; + public static final float HUB_BOTTOM_Y_PERCENT = 208f / 337f; } public static class Data { diff --git a/app/src/main/res/layout/match_tally.xml b/app/src/main/res/layout/match_tally.xml index 3c909b5..b06a6d8 100644 --- a/app/src/main/res/layout/match_tally.xml +++ b/app/src/main/res/layout/match_tally.xml @@ -184,7 +184,7 @@ android:text="@string/button_climb" android:textSize="22sp" android:layout_gravity="center_vertical" - android:backgroundTint="@color/light_blue" + android:backgroundTint="@color/dark_green" app:cornerRadius="20dp"/>