diff --git a/code/src/Fitbot/app/src/main/java/com/example/fitbot/ui/activities/FitnessActivity.java b/code/src/Fitbot/app/src/main/java/com/example/fitbot/ui/activities/FitnessActivity.java
index 5b8f87f..6a58910 100644
--- a/code/src/Fitbot/app/src/main/java/com/example/fitbot/ui/activities/FitnessActivity.java
+++ b/code/src/Fitbot/app/src/main/java/com/example/fitbot/ui/activities/FitnessActivity.java
@@ -91,9 +91,7 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall
progressCircle = findViewById(R.id.progressCircle);
progressText = findViewById(R.id.progressText);
-
progressCircle.setMax(maxProgress);
- updateProgress();
// Set color of loading circle
ProgressBar loadingCircle = findViewById(R.id.loadingCircle);
@@ -270,7 +268,7 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall
dialog.show();
}
- public void incrementProgress(View view) {
+ public void incrementProgress() {
if (progress < maxProgress) {
progress++;
triggerColorBurst(true);
@@ -283,15 +281,12 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall
progressText.setText(progress + "/" + maxProgress);
}
- private void triggerColorBurst(boolean isGoodRep) {
+ public void triggerColorBurst(boolean isGoodRep) {
- if (isGoodRep) {
- progressCircle.setProgressDrawable(ContextCompat.getDrawable(this, R.drawable.progress_circle_good));
- new MediaPlayer().create(this, R.raw.good_sound).start();
- } else {
- progressCircle.setProgressDrawable(ContextCompat.getDrawable(this, R.drawable.progress_circle_bad));
- new MediaPlayer().create(this, R.raw.wrong_sound).start();
- }
+ int circleId = isGoodRep ? R.drawable.progress_circle_good : R.drawable.progress_circle_bad;
+ int soundId = isGoodRep ? R.raw.good_sound : R.raw.wrong_sound;
+ progressCircle.setProgressDrawable(ContextCompat.getDrawable(this, circleId));
+ MediaPlayer.create(this, soundId).start();
ObjectAnimator animator = ObjectAnimator.ofFloat(progressCircle, "alpha", 1f, 0f, 1f);
animator.setDuration(500); // Burst duration
diff --git a/code/src/Fitbot/app/src/main/java/com/example/fitbot/util/processing/InputProcessor.java b/code/src/Fitbot/app/src/main/java/com/example/fitbot/util/processing/InputProcessor.java
index 6a3fd8a..dc46191 100644
--- a/code/src/Fitbot/app/src/main/java/com/example/fitbot/util/processing/InputProcessor.java
+++ b/code/src/Fitbot/app/src/main/java/com/example/fitbot/util/processing/InputProcessor.java
@@ -28,7 +28,7 @@ public class InputProcessor {
private Vector3f[][] targetRotationVectorPaths; // Target path of the motion data
private final float sampleRate; // The sample rate of the motion sensor
- private float exerciseDurationInSeconds;
+ private float exerciseRepetitionDurationInSeconds = 0.0f;
private int repetitionsRemaining = 0;
private int exercisesRemaining = 0;
private float exerciseScore = 0.0F;
@@ -120,7 +120,7 @@ public class InputProcessor {
this.targetRotationVectorPaths = new Vector3f[2][exercise.rightPath.getAngleVectors().length];
this.targetRotationVectorPaths[0] = exercise.leftPath.getAngleVectors();
this.targetRotationVectorPaths[1] = exercise.rightPath.getAngleVectors();
- this.exerciseDurationInSeconds = exercise.exerciseTimeInSeconds;
+ this.exerciseRepetitionDurationInSeconds = exercise.exerciseTimeInSeconds;
this.secondsPassed = 0.0D;
this.lastTime = System.currentTimeMillis();
}
@@ -130,15 +130,14 @@ public class InputProcessor {
*/
public void onAdequateRepetition() {
ExerciseManager.TOTAL_REPETITIONS_PERFORMED++;
- // TODO: Add animation for correct repetition
+ new FitnessActivity().incrementProgress();
}
/**
* Method that is called whenever the user performs a bad repetition.
*/
public void onInadequateRepetition() {
-
- // TODO: Add animation for wrong repetition
+ new FitnessActivity().triggerColorBurst(false);
}
/**
@@ -170,7 +169,7 @@ public class InputProcessor {
public boolean hasFinished() {
return this.recordingMovement ?
(this.secondsPassed >= this.recordingDurationInSeconds) :
- (this.secondsPassed >= this.exerciseDurationInSeconds);
+ (this.secondsPassed >= this.exerciseRepetitionDurationInSeconds);
}
/**
@@ -367,6 +366,10 @@ public class InputProcessor {
// Ensure the sensor ID is within the bounds of the array
if (sensorId < 0 || sensorId >= selfRotationVectorPaths.length)
return 0.0d;
+
+ // Calculate the index of the rotational vector where we're currently at
+ int targetRotationIdx =
+
/*
// Index of the current rotation vector
@@ -394,10 +397,10 @@ public class InputProcessor {
*/
public double getAverageError(int sensorId) {
double error = 0;
- for (int i = 0; i < this.exerciseDurationInSeconds; i++) {
+ for (int i = 0; i < this.exerciseRepetitionDurationInSeconds; i++) {
error += getError(sensorId, i);
}
- return error / this.exerciseDurationInSeconds;
+ return error / this.exerciseRepetitionDurationInSeconds;
}
public float secondsPassed() {
diff --git a/code/src/Fitbot/app/src/main/res/layout/activity_fitness.xml b/code/src/Fitbot/app/src/main/res/layout/activity_fitness.xml
index b33ef19..641d8d9 100644
--- a/code/src/Fitbot/app/src/main/res/layout/activity_fitness.xml
+++ b/code/src/Fitbot/app/src/main/res/layout/activity_fitness.xml
@@ -77,7 +77,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
- android:text="@string/title"
+ android:text="@string/exerciseTitle"
android:textAlignment="center" />
-
-
Score:
Title
- ContextContextContext
+ Exercise descriptionLorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
- Description
+ Exercise title
\ No newline at end of file