added progress circle with feedback to user how well they do the rep

This commit is contained in:
SebasKoedam
2024-06-05 12:23:30 +02:00
parent e75551671a
commit 2a0a08ee9e
9 changed files with 148 additions and 30 deletions

View File

@@ -24,6 +24,7 @@
<entry key="..\:/Users/sebas/Documents/HvA/Reposetories/muupooviixee66/code/src/Fitbot/app/src/main/res/drawable/border_background.xml" value="0.2475" />
<entry key="..\:/Users/sebas/Documents/HvA/Reposetories/muupooviixee66/code/src/Fitbot/app/src/main/res/drawable/border_background_2.xml" value="0.2475" />
<entry key="..\:/Users/sebas/Documents/HvA/Reposetories/muupooviixee66/code/src/Fitbot/app/src/main/res/drawable/border_background_3.xml" value="0.2475" />
<entry key="..\:/Users/sebas/Documents/HvA/Reposetories/muupooviixee66/code/src/Fitbot/app/src/main/res/drawable/border_background_circle.xml" value="0.2475" />
<entry key="..\:/Users/sebas/Documents/HvA/Reposetories/muupooviixee66/code/src/Fitbot/app/src/main/res/drawable/box_background.xml" value="0.2555" />
<entry key="..\:/Users/sebas/Documents/HvA/Reposetories/muupooviixee66/code/src/Fitbot/app/src/main/res/drawable/darkred_button_gradient.xml" value="0.346" />
<entry key="..\:/Users/sebas/Documents/HvA/Reposetories/muupooviixee66/code/src/Fitbot/app/src/main/res/drawable/fitbot_launcher_background.xml" value="0.2475" />
@@ -33,6 +34,9 @@
<entry key="..\:/Users/sebas/Documents/HvA/Reposetories/muupooviixee66/code/src/Fitbot/app/src/main/res/drawable/ic_baseline_settings_48.xml" value="0.25" />
<entry key="..\:/Users/sebas/Documents/HvA/Reposetories/muupooviixee66/code/src/Fitbot/app/src/main/res/drawable/ic_baseline_star_rate_48.xml" value="0.25" />
<entry key="..\:/Users/sebas/Documents/HvA/Reposetories/muupooviixee66/code/src/Fitbot/app/src/main/res/drawable/ic_launcher_background.xml" value="0.25" />
<entry key="..\:/Users/sebas/Documents/HvA/Reposetories/muupooviixee66/code/src/Fitbot/app/src/main/res/drawable/progress_circle.xml" value="0.2475" />
<entry key="..\:/Users/sebas/Documents/HvA/Reposetories/muupooviixee66/code/src/Fitbot/app/src/main/res/drawable/progress_circle_burst.xml" value="0.2475" />
<entry key="..\:/Users/sebas/Documents/HvA/Reposetories/muupooviixee66/code/src/Fitbot/app/src/main/res/drawable/progress_circle_burst_good.xml" value="0.1" />
<entry key="..\:/Users/sebas/Documents/HvA/Reposetories/muupooviixee66/code/src/Fitbot/app/src/main/res/drawable/rectangle.xml" value="0.2395" />
<entry key="..\:/Users/sebas/Documents/HvA/Reposetories/muupooviixee66/code/src/Fitbot/app/src/main/res/drawable/red_button_gradient.xml" value="0.346" />
<entry key="..\:/Users/sebas/Documents/HvA/Reposetories/muupooviixee66/code/src/Fitbot/app/src/main/res/layout/activity_bicepvideo.xml" value="0.22826086956521738" />

View File

@@ -1,18 +1,20 @@
package com.example.fitbot.ui.activities;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.app.Dialog;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.content.ContextCompat;
import android.util.Log;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.VideoView;
@@ -38,6 +40,12 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall
private InputProcessor motionProcessor;
private Exercise currentExercise;
// Progress circle for the exercises
private ProgressBar progressCircle;
private TextView progressText;
private int progress = 0;
private final int maxProgress = 10;
// Exercise status element data
private TextView exerciseMuscleGroupTextView;
private TextView exerciseNameTextView;
@@ -76,6 +84,12 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall
// Set the repetition count for the exercise
EXERCISE_REP = 1;
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);
loadingCircle.setIndeterminateTintList(ColorStateList.valueOf(Color.RED));
@@ -242,4 +256,37 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall
});
dialog.show();
}
public void incrementProgress(View view) {
if (progress < maxProgress) {
progress++;
triggerColorBurst(false);
updateProgress();
}
}
private void updateProgress() {
progressCircle.setProgress(progress);
progressText.setText(progress + "/" + maxProgress);
}
private void triggerColorBurst(boolean isGoodRep) {
if (isGoodRep) {
progressCircle.setProgressDrawable(ContextCompat.getDrawable(this, R.drawable.progress_circle_good));
} else {
progressCircle.setProgressDrawable(ContextCompat.getDrawable(this, R.drawable.progress_circle_bad));
}
ObjectAnimator animator = ObjectAnimator.ofFloat(progressCircle, "alpha", 1f, 0f, 1f);
animator.setDuration(500); // Burst duration
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
progressCircle.setProgressDrawable(ContextCompat.getDrawable(FitnessActivity.this, R.drawable.progress_circle));
}
});
animator.start();
}
}

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/midBlue" />
<stroke android:width="2dp" android:color="#FFFFFF" />
<corners android:radius="360dp" />
</shape>

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/progress">
<rotate
android:fromDegrees="270"
android:toDegrees="270">
<shape android:shape="ring">
<gradient
android:startColor="#ADD8E6"
android:endColor="#798994"
android:angle="0"
android:type="sweep"/>
<size android:width="150dp"
android:height="150dp"/>
</shape>
</rotate>
</item>
</layer-list>

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/progress">
<rotate
android:fromDegrees="270"
android:toDegrees="270">
<shape android:shape="ring">
<gradient
android:startColor="#FF0000"
android:endColor="#FF0000"
android:angle="0"
android:type="sweep"/>
<size android:width="150dp"
android:height="150dp"/>
</shape>
</rotate>
</item>
</layer-list>

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/progress">
<rotate
android:fromDegrees="270"
android:toDegrees="270">
<shape android:shape="ring">
<gradient
android:startColor="#00FF00"
android:endColor="#00FF00"
android:angle="0"
android:type="sweep"/>
<size android:width="150dp"
android:height="150dp"/>
</shape>
</rotate>
</item>
</layer-list>

View File

@@ -97,39 +97,44 @@
android:textAlignment="center" />
</LinearLayout>
<LinearLayout
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/progressText"
android:layout_gravity="center"
android:layout_marginTop="20dp"
android:onClick="incrementProgress"
android:text="Increment" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="10dp"
android:background="@drawable/border_background_3"
android:padding="5dp">
android:background="@drawable/border_background_circle">
<ProgressBar
android:id="@+id/progressCircle"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:indeterminate="false"
android:max="10"
android:progress="10"
android:progressDrawable="@drawable/progress_circle" />
<TextView
android:id="@+id/textViewFitnessReps"
android:id="@+id/progressText"
style="@style/TextStyle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/context"
android:textAlignment="center" />
</LinearLayout>
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="0/10" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="10dp"
android:background="@drawable/border_background_3"
android:padding="5dp">
<TextView
android:id="@+id/textViewFitnessScore"
style="@style/TextStyle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/context"
android:textAlignment="center" />
</LinearLayout>
</RelativeLayout>
<com.example.fitbot.ui.components.ExerciseStatusElement
android:id="@+id/personalMotionPreviewElement"

View File

@@ -39,4 +39,8 @@
<item name="android:padding">6dp</item>
</style>
<style name="ProgressCircle" parent="Widget.AppCompat.ProgressBar">
<item name="android:indeterminateDrawable">@drawable/progress_circle</item>
</style>
</resources>

View File

@@ -10,9 +10,7 @@ dependencyResolutionManagement {
repositories {
google()
mavenCentral()
maven {
url 'https://qisdk.softbankrobotics.com/sdk/maven/'
}
maven { url 'https://qisdk.softbankrobotics.com/sdk/maven/' }
}
}
rootProject.name = "Fitbot"