This commit is contained in:
2024-06-05 17:36:01 +02:00
parent 3b7352aa4c
commit 5537230b49
4 changed files with 31 additions and 20 deletions

View File

@@ -37,7 +37,7 @@ public class ExerciseManager {
}; };
public static final int DEFAULT_EXERCISE_REPETITIONS = 10; public static final int DEFAULT_EXERCISE_REPETITIONS = 10;
public static final float EXERCISE_ERROR_MARGIN = 1.0f; public static final float EXERCISE_ERROR_MARGIN = 1.5f;
public static final float EXERCISE_TIME_SCALING_FACTOR = 1.0f; public static final float EXERCISE_TIME_SCALING_FACTOR = 1.0f;
// Fields representing the statistics of the user // Fields representing the statistics of the user

View File

@@ -41,7 +41,7 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall
// Progress circle for the exercises // Progress circle for the exercises
private ProgressBar progressCircle; private ProgressBar progressCircle;
private TextView progressText; private TextView progressText;
private int progress = 0; private int progress = 1;
private final int maxProgress = 10; private final int maxProgress = 10;
// Exercise status element data // Exercise status element data
@@ -178,6 +178,7 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall
// Start checking for user movement once the video has loaded // Start checking for user movement once the video has loaded
this.motionProcessor.startListening(); this.motionProcessor.startListening();
this.motionProcessor.startCheckingUserMovement(); this.motionProcessor.startCheckingUserMovement();
// this.motionProcessor.setRecording(true, 4.f);
return true; return true;
} }
@@ -204,7 +205,7 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall
public void playVideo(VideoView videoView, Context context) { public void playVideo(VideoView videoView, Context context) {
// Set up the video player // Set up the video player
if (videoView != null) { if (videoView != null) {
videoView.setVideoURI(Uri.parse("android.resource://" + context.getPackageName() + "/" + R.raw.arm_raises)); videoView.setVideoPath(exerciseVideoUrl);
videoView.start(); videoView.start();
} else { } else {
Log.e("FitnessActivity", "VideoView is null. Check your layout XML."); Log.e("FitnessActivity", "VideoView is null. Check your layout XML.");
@@ -273,19 +274,25 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall
public void triggerColorBurst(boolean isGoodRep) { public void triggerColorBurst(boolean isGoodRep) {
int circleId = isGoodRep ? R.drawable.progress_circle_good : R.drawable.progress_circle_bad; Log.i("InputProcessor", "Color Burst");
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); try {
animator.setDuration(700); // Burst duration int circleId = isGoodRep ? R.drawable.progress_circle_good : R.drawable.progress_circle_bad;
animator.addListener(new AnimatorListenerAdapter() { int soundId = isGoodRep ? R.raw.good_sound : R.raw.wrong_sound;
@Override progressCircle.setProgressDrawable(ContextCompat.getDrawable(this, circleId));
public void onAnimationEnd(Animator animation) { // MediaPlayer.create(this, soundId).start();
progressCircle.setProgressDrawable(ContextCompat.getDrawable(FitnessActivity.this, R.drawable.progress_circle));
} ObjectAnimator animator = ObjectAnimator.ofFloat(progressCircle, "alpha", 1f, 0f, 1f);
}); animator.setDuration(700); // Burst duration
animator.start(); animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
progressCircle.setProgressDrawable(ContextCompat.getDrawable(FitnessActivity.this, R.drawable.progress_circle));
}
});
animator.start();
} catch (Exception e) {
e.printStackTrace();
}
} }
} }

View File

@@ -108,8 +108,11 @@ public class InputProcessor {
while (this.exercisesRemaining > 0) { while (this.exercisesRemaining > 0) {
if ( this.totalChecks == 0) if ( this.totalChecks == 0 || this.selfRotationVectorPaths == null
|| this.selfRotationVectorPaths.length == 0
|| this.selfRotationVectorPaths[0].size() == 0)
continue; continue;
boolean isFaulty = this.isFaultyMovement(); boolean isFaulty = this.isFaultyMovement();
Log.i("InputProcessor", "Movement checked: " + (isFaulty ? "Faulty" : "Good")); Log.i("InputProcessor", "Movement checked: " + (isFaulty ? "Faulty" : "Good"));
@@ -170,7 +173,7 @@ public class InputProcessor {
Log.i("InputProcessor", "Repetition time: " + exercise.exerciseTimeInSeconds); Log.i("InputProcessor", "Repetition time: " + exercise.exerciseTimeInSeconds);
this.exerciseRepetitionDurationInSeconds = Math.max(this.exerciseRepetitionDurationInSeconds, 2); this.exerciseRepetitionDurationInSeconds = Math.max(this.exerciseRepetitionDurationInSeconds, 2);
this.errorCheckInterval_s = exercise.exerciseTimeInSeconds / 6.0f; this.errorCheckInterval_s = exercise.exerciseTimeInSeconds / 3.0f;
Log.i("InputProcessor", "Exercise error checking interval: " + this.errorCheckInterval_s); Log.i("InputProcessor", "Exercise error checking interval: " + this.errorCheckInterval_s);
} }
@@ -256,6 +259,7 @@ public class InputProcessor {
this.parentActivity.runOnUiThread(() -> { this.parentActivity.runOnUiThread(() -> {
NavigationManager.navigateToActivity(this.parentActivity, EndScreenActivity.class); NavigationManager.navigateToActivity(this.parentActivity, EndScreenActivity.class);
}); });
return;
} }
Log.i("MotionProcessor", "Fetching exercise data."); Log.i("MotionProcessor", "Fetching exercise data.");

View File

@@ -113,7 +113,7 @@
android:layout_gravity="center" android:layout_gravity="center"
android:indeterminate="false" android:indeterminate="false"
android:max="10" android:max="10"
android:progress="0" android:progress="1"
android:progressDrawable="@drawable/progress_circle" /> android:progressDrawable="@drawable/progress_circle" />
<TextView <TextView
@@ -122,7 +122,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerInParent="true" android:layout_centerInParent="true"
android:text="0/10" /> android:text="1/10" />
</RelativeLayout> </RelativeLayout>