Added fitness activity switching

This commit is contained in:
Luca Warmenhoven
2024-05-17 14:53:45 +02:00
parent cfcbe7d51c
commit 7442d1fca4
5 changed files with 45 additions and 7 deletions

View File

@@ -15,9 +15,11 @@
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/Theme.Fitbot" > android:theme="@style/Theme.Fitbot" >
<!--android:name=".ui.activities.MainActivity"-->
<activity <activity
android:name=".ui.activities.FitnessActivity" android:name=".ui.activities.FitnessActivity"
android:exported="true" />
<activity
android:name=".ui.activities.MainActivity"
android:exported="true" > android:exported="true" >
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />

View File

@@ -1,6 +1,7 @@
package com.example.fitbot.ui.activities; package com.example.fitbot.ui.activities;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.support.design.widget.NavigationView; import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat; import android.support.v4.view.GravityCompat;
@@ -8,6 +9,8 @@ import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle; import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.widget.Button;
import com.example.fitbot.R; import com.example.fitbot.R;
@@ -17,6 +20,7 @@ public class MainActivity extends AppCompatActivity {
DrawerLayout drawerLayout; DrawerLayout drawerLayout;
NavigationView navigationView; NavigationView navigationView;
Toolbar toolbar; Toolbar toolbar;
Button startButton;
@SuppressLint("WrongViewCast") @SuppressLint("WrongViewCast")
@Override @Override
@@ -28,6 +32,14 @@ public class MainActivity extends AppCompatActivity {
drawerLayout = findViewById(R.id.drawer_layout); drawerLayout = findViewById(R.id.drawer_layout);
navigationView = findViewById(R.id.nav_view); navigationView = findViewById(R.id.nav_view);
toolbar = findViewById(R.id.toolbar); toolbar = findViewById(R.id.toolbar);
startButton = findViewById(R.id.startButton);
startButton.setOnClickListener(v -> {
// Switch to fitness activity
Log.i("MainActivity", "Switching to FitnessActivity");
Intent intent = new Intent(MainActivity.this, FitnessActivity.class);
startActivity(intent);
});
/*---Tool Bar---*/ /*---Tool Bar---*/
// setSupportActionBar(toolbar); // setSupportActionBar(toolbar);

View File

@@ -4,6 +4,7 @@ import android.content.Context;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.Path; import android.graphics.Path;
import android.util.Log;
import android.view.View; import android.view.View;
import com.example.fitbot.util.path.GesturePath; import com.example.fitbot.util.path.GesturePath;
@@ -24,6 +25,8 @@ public class PersonalMotionPreviewElement extends View {
private Path referencePath, performingPath; private Path referencePath, performingPath;
private Paint referencePaint, performingPaint; private Paint referencePaint, performingPaint;
private Paint backgroundColor = new Paint();
/** /**
* Constants for the preview path projection. * Constants for the preview path projection.
*/ */
@@ -42,6 +45,9 @@ public class PersonalMotionPreviewElement extends View {
*/ */
public PersonalMotionPreviewElement(Context context, GesturePath path) { public PersonalMotionPreviewElement(Context context, GesturePath path) {
super(context); super(context);
Log.i("PersonalMotionPreviewElement", "Creating new PersonalMotionPreviewElement.");
this.backgroundColor = new Paint();
this.backgroundColor.setColor(0xFF000000); // Black
this.path = path; this.path = path;
this.motionProcessor = new MotionProcessor(); this.motionProcessor = new MotionProcessor();
this.motionProcessor.startListening(); this.motionProcessor.startListening();
@@ -158,6 +164,7 @@ public class PersonalMotionPreviewElement extends View {
@Override @Override
public void onDraw(Canvas canvas) { public void onDraw(Canvas canvas) {
canvas.drawRect(0, 0, getWidth(), getHeight(), backgroundColor);
// Draw the sport preview canvas // Draw the sport preview canvas
canvas.drawPath(referencePath, referencePaint); canvas.drawPath(referencePath, referencePaint);
canvas.drawPath(performingPath, performingPaint); canvas.drawPath(performingPath, performingPaint);

View File

@@ -1,10 +1,25 @@
<?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
android:background="#232323"
android:fitsSystemWindows="true"
tools:context=".ui.activities.FitnessActivity"
tools:openDrawer="start">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.example.fitbot.ui.components.PersonalMotionPreviewElement <com.example.fitbot.ui.components.PersonalMotionPreviewElement
android:id="@+id/personalMotionPreviewElement"
android:visibility="visible"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"/> android:layout_height="match_parent"/>
</android.support.constraint.ConstraintLayout> </LinearLayout>
</android.support.v4.widget.DrawerLayout>

View File

@@ -1,9 +1,12 @@
package com.example.fitbot; package com.example.fitbot;
import static org.junit.Assert.assertEquals;
import com.example.fitbot.util.path.GesturePath; import com.example.fitbot.util.path.GesturePath;
import com.example.fitbot.util.path.PathSegment; import com.example.fitbot.util.path.PathSegment;
import org.joml.Vector3f; import org.joml.Vector3f;
import org.junit.Test;
public class PathSegmentTest { public class PathSegmentTest {
@@ -23,7 +26,6 @@ public class PathSegmentTest {
@Test @Test
@DisplayName("Test Path Segment Interpolation")
public void test_pathSegmentInterpolation() { public void test_pathSegmentInterpolation() {
Vector3f start = new Vector3f(0, 0, 0); Vector3f start = new Vector3f(0, 0, 0);
Vector3f end = new Vector3f(1, 1, 1); Vector3f end = new Vector3f(1, 1, 1);