diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 057fce9..22bfcea 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -14,8 +14,10 @@ - - + + + + - - \ No newline at end of file diff --git a/code/src/.idea/.name b/code/src/.idea/.name deleted file mode 100644 index 9a7766c..0000000 --- a/code/src/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -Fitbot \ No newline at end of file diff --git a/code/src/.idea/encodings.xml b/code/src/.idea/encodings.xml deleted file mode 100644 index 15a15b2..0000000 --- a/code/src/.idea/encodings.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/code/src/.idea/misc.xml b/code/src/.idea/misc.xml deleted file mode 100644 index b691e65..0000000 --- a/code/src/.idea/misc.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/code/src/.gitignore b/code/src/Fitbot/.gitignore similarity index 100% rename from code/src/.gitignore rename to code/src/Fitbot/.gitignore diff --git a/code/src/Fitbot/.idea/.gitignore b/code/src/Fitbot/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/code/src/Fitbot/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/code/src/.idea/compiler.xml b/code/src/Fitbot/.idea/compiler.xml similarity index 100% rename from code/src/.idea/compiler.xml rename to code/src/Fitbot/.idea/compiler.xml diff --git a/code/src/Fitbot/.idea/deploymentTargetDropDown.xml b/code/src/Fitbot/.idea/deploymentTargetDropDown.xml new file mode 100644 index 0000000..a5abdd5 --- /dev/null +++ b/code/src/Fitbot/.idea/deploymentTargetDropDown.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/code/src/.idea/gradle.xml b/code/src/Fitbot/.idea/gradle.xml similarity index 100% rename from code/src/.idea/gradle.xml rename to code/src/Fitbot/.idea/gradle.xml diff --git a/code/src/Fitbot/.idea/misc.xml b/code/src/Fitbot/.idea/misc.xml new file mode 100644 index 0000000..42e8983 --- /dev/null +++ b/code/src/Fitbot/.idea/misc.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/code/src/.idea/vcs.xml b/code/src/Fitbot/.idea/vcs.xml similarity index 53% rename from code/src/.idea/vcs.xml rename to code/src/Fitbot/.idea/vcs.xml index 64713b8..c2365ab 100644 --- a/code/src/.idea/vcs.xml +++ b/code/src/Fitbot/.idea/vcs.xml @@ -1,7 +1,6 @@ - - + \ No newline at end of file diff --git a/code/src/app/.gitignore b/code/src/Fitbot/app/.gitignore similarity index 100% rename from code/src/app/.gitignore rename to code/src/Fitbot/app/.gitignore diff --git a/fitbot/build.gradle b/code/src/Fitbot/app/build.gradle similarity index 62% rename from fitbot/build.gradle rename to code/src/Fitbot/app/build.gradle index d2bf7a6..23c5f19 100644 --- a/fitbot/build.gradle +++ b/code/src/Fitbot/app/build.gradle @@ -1,16 +1,18 @@ plugins { - id 'com.android.library' + id 'com.android.application' } android { - compileSdk 34 + compileSdk 29 defaultConfig { - minSdk 21 - targetSdk 34 + applicationId "com.example.fitbot" + minSdk 23 + targetSdk 29 + versionCode 1 + versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" - consumerProguardFiles "consumer-rules.pro" } buildTypes { @@ -23,12 +25,17 @@ android { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } + buildToolsVersion '29.0.3' } dependencies { implementation 'com.android.support:appcompat-v7:28.0.0' + implementation 'com.android.support.constraint:constraint-layout:2.0.4' + implementation 'com.android.support:cardview-v7:28.0.0' testImplementation 'junit:junit:4.13.2' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' + implementation 'com.aldebaran:qisdk:1.7.5' + implementation 'com.aldebaran:qisdk-design:1.7.5' } \ No newline at end of file diff --git a/code/src/app/proguard-rules.pro b/code/src/Fitbot/app/proguard-rules.pro similarity index 100% rename from code/src/app/proguard-rules.pro rename to code/src/Fitbot/app/proguard-rules.pro diff --git a/fitbot/src/androidTest/java/com/fitbot/ExampleInstrumentedTest.java b/code/src/Fitbot/app/src/androidTest/java/com/example/fitbot/ExampleInstrumentedTest.java similarity index 86% rename from fitbot/src/androidTest/java/com/fitbot/ExampleInstrumentedTest.java rename to code/src/Fitbot/app/src/androidTest/java/com/example/fitbot/ExampleInstrumentedTest.java index ed5b5a2..ca533dc 100644 --- a/fitbot/src/androidTest/java/com/fitbot/ExampleInstrumentedTest.java +++ b/code/src/Fitbot/app/src/androidTest/java/com/example/fitbot/ExampleInstrumentedTest.java @@ -1,4 +1,4 @@ -package com.fitbot; +package com.example.fitbot; import android.content.Context; import android.support.test.InstrumentationRegistry; @@ -20,6 +20,6 @@ public class ExampleInstrumentedTest { public void useAppContext() { // Context of the app under test. Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); - assertEquals("com.fitbot.test", appContext.getPackageName()); + assertEquals("com.example.fitbot", appContext.getPackageName()); } } \ No newline at end of file diff --git a/code/src/Fitbot/app/src/main/AndroidManifest.xml b/code/src/Fitbot/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..7a1dc0f --- /dev/null +++ b/code/src/Fitbot/app/src/main/AndroidManifest.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/code/src/app/src/main/assets/robot/robotsdk.xml b/code/src/Fitbot/app/src/main/assets/robot/robotsdk.xml similarity index 100% rename from code/src/app/src/main/assets/robot/robotsdk.xml rename to code/src/Fitbot/app/src/main/assets/robot/robotsdk.xml diff --git a/code/src/Fitbot/app/src/main/java/com/example/fitbot/BicepVideo.java b/code/src/Fitbot/app/src/main/java/com/example/fitbot/BicepVideo.java new file mode 100644 index 0000000..3016b0a --- /dev/null +++ b/code/src/Fitbot/app/src/main/java/com/example/fitbot/BicepVideo.java @@ -0,0 +1,59 @@ +package com.example.fitbot; + +import android.content.Intent; +import android.net.Uri; +import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; +import android.widget.Button; +import android.widget.MediaController; +import android.widget.VideoView; + +import com.aldebaran.qi.sdk.QiContext; +import com.aldebaran.qi.sdk.builder.AnimateBuilder; +import com.aldebaran.qi.sdk.builder.AnimationBuilder; +import com.aldebaran.qi.sdk.object.actuation.Animate; +import com.aldebaran.qi.sdk.object.actuation.Animation; + +public class BicepVideo extends AppCompatActivity { + +// private QiContext qiContext; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_bicepvideo); + setupButtons(); + } + + public void Video(QiContext qiContext) { + VideoView videoView = findViewById(R.id.videoView); + videoView.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.bicepvideo)); + + MediaController mediaController = new MediaController(this); + videoView.setMediaController(mediaController); + videoView.setOnCompletionListener(mp -> videoView.start()); + videoView.start(); + + Animation animation = AnimationBuilder.with(qiContext) + .withResources(R.raw.bicepcurl) + .build(); + + Animate animate = AnimateBuilder.with(qiContext) + .withAnimation(animation) + .build(); + + + animate.async().run(); + + } + private void setupButtons() { + Button backButton = findViewById(R.id.buttonback); + backButton.setOnClickListener(v -> finish()); + + Button completeButton = findViewById(R.id.buttoncomplete); + completeButton.setOnClickListener(v -> { + Intent intent = new Intent(BicepVideo.this, Completion_Screen.class); + startActivity(intent); + }); + } +} \ No newline at end of file diff --git a/code/src/Fitbot/app/src/main/java/com/example/fitbot/Completion_Screen.java b/code/src/Fitbot/app/src/main/java/com/example/fitbot/Completion_Screen.java new file mode 100644 index 0000000..092c65a --- /dev/null +++ b/code/src/Fitbot/app/src/main/java/com/example/fitbot/Completion_Screen.java @@ -0,0 +1,13 @@ +package com.example.fitbot; + +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; + +public class Completion_Screen extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_completion_screen); + } +} \ No newline at end of file diff --git a/code/src/Fitbot/app/src/main/java/com/example/fitbot/MainActivity.java b/code/src/Fitbot/app/src/main/java/com/example/fitbot/MainActivity.java new file mode 100644 index 0000000..6ada06e --- /dev/null +++ b/code/src/Fitbot/app/src/main/java/com/example/fitbot/MainActivity.java @@ -0,0 +1,79 @@ +package com.example.fitbot; + +import android.content.Intent; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; + +import com.aldebaran.qi.sdk.QiContext; +import com.aldebaran.qi.sdk.QiSDK; +import com.aldebaran.qi.sdk.RobotLifecycleCallbacks; +import com.aldebaran.qi.sdk.builder.AnimateBuilder; +import com.aldebaran.qi.sdk.builder.AnimationBuilder; +import com.aldebaran.qi.sdk.builder.SayBuilder; +import com.aldebaran.qi.sdk.design.activity.RobotActivity; +import com.aldebaran.qi.sdk.design.activity.conversationstatus.SpeechBarDisplayStrategy; +import com.aldebaran.qi.sdk.object.actuation.Animate; +import com.aldebaran.qi.sdk.object.actuation.Animation; +import com.aldebaran.qi.sdk.object.conversation.Phrase; +import com.aldebaran.qi.sdk.object.conversation.Say; + + +public class MainActivity extends RobotActivity implements RobotLifecycleCallbacks { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + // Register the RobotLifecycleCallbacks to this Activity. + QiSDK.register(this, this); + } + + @Override + protected void onDestroy() { + // Unregister the RobotLifecycleCallbacks for this Activity. + QiSDK.unregister(this, this); + super.onDestroy(); + } + + @Override + public void onRobotFocusGained(QiContext qiContext) { + // Create a new say action. + Say say = SayBuilder.with(qiContext) // Create the builder with the context. + .withText("Hallo hoe gaat het?") // Set the text to say. + .build(); // Build the say action. + + Phrase namePhrase = new Phrase("This location is " + locationName); + Say sayName = SayBuilder.with(qiContext) + .withPhrase(namePhrase) + .withLocale(locale) + .build(); + + Phrase descriptionPhrase = new Phrase(locationDescription); + Say sayDescription = SayBuilder.with(qiContext) + .withPhrase(descriptionPhrase) + .withLocale(locale) + .build(); + + sayName.run(); + sayDescription.run(); + + // Create a new BicepVideo with the qiContext + bicepvideo BicepVideo = new bicepvideo(); + + // Call the videoPlayer method + BicepVideo.Video(qiContext); + + // Execute the action. + say.run(); + } + + + @Override + public void onRobotFocusLost() { + // Nothing here. + } + + @Override + public void onRobotFocusRefused(String reason) { + // The robot focus is refused. + } +} \ No newline at end of file diff --git a/code/src/Fitbot/app/src/main/java/com/example/fitbot/MainScreen.java b/code/src/Fitbot/app/src/main/java/com/example/fitbot/MainScreen.java new file mode 100644 index 0000000..6762be8 --- /dev/null +++ b/code/src/Fitbot/app/src/main/java/com/example/fitbot/MainScreen.java @@ -0,0 +1,22 @@ +package com.example.fitbot; + +import android.content.Intent; +import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; +import android.widget.Button; + +public class MainScreen extends AppCompatActivity { + Button button; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main_screen); + + button = findViewById(R.id.open_BicepVideo); + button.setOnClickListener(v -> { + Intent i = new Intent(MainScreen.this, BicepVideo.class); + startActivity(i); + }); + } +} \ No newline at end of file diff --git a/code/src/Fitbot/app/src/main/java/com/example/fitbot/speech/SpeechGenerator.java b/code/src/Fitbot/app/src/main/java/com/example/fitbot/speech/SpeechGenerator.java new file mode 100644 index 0000000..61c265a --- /dev/null +++ b/code/src/Fitbot/app/src/main/java/com/example/fitbot/speech/SpeechGenerator.java @@ -0,0 +1,35 @@ +package com.example.fitbot.speech; + +import com.aldebaran.qi.sdk.QiContext; +import com.aldebaran.qi.sdk.builder.SayBuilder; +import com.aldebaran.qi.sdk.object.locale.Language; +import com.aldebaran.qi.sdk.object.locale.Locale; +import com.aldebaran.qi.sdk.object.locale.Region; + +public class SpeechGenerator { + + private static final Locale DUTCH_LOCALE = new Locale(Language.DUTCH, Region.NETHERLANDS); + private SayBuilder builder; + + /** + * Function for making the robot say something with DUTCH_LOCALE as locale + * @param phrase The phrase to make the robot say + * @param ctx The QiContext to use + */ + public static void say(String phrase, QiContext ctx) + { + say(phrase, ctx, DUTCH_LOCALE); + } + + + + public static void say(String text, QiContext ctx, Locale locale) + { + SayBuilder.with(ctx) + .withLocale(locale) + .withText(text) + .build() + .run(); + } + +} diff --git a/code/src/Fitbot/app/src/main/java/com/example/fitbot/sports/ESportType.java b/code/src/Fitbot/app/src/main/java/com/example/fitbot/sports/ESportType.java new file mode 100644 index 0000000..4ea7606 --- /dev/null +++ b/code/src/Fitbot/app/src/main/java/com/example/fitbot/sports/ESportType.java @@ -0,0 +1,18 @@ +package com.example.fitbot.sports; + +public enum ESportType { + + FITNESS("Fitness"), + POWER("Krachttrening"); + + private final String name; + + ESportType(String name) { + this.name = name; + } + + public String getName() { + return name; + } + +} diff --git a/code/src/Fitbot/app/src/main/java/com/example/fitbot/ui/SportItemActivity.java b/code/src/Fitbot/app/src/main/java/com/example/fitbot/ui/SportItemActivity.java new file mode 100644 index 0000000..481605d --- /dev/null +++ b/code/src/Fitbot/app/src/main/java/com/example/fitbot/ui/SportItemActivity.java @@ -0,0 +1,21 @@ +package com.example.fitbot.ui; + +import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; + +import com.example.fitbot.R; + +public class SportItemActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_sport_item); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + } + +} diff --git a/code/src/Fitbot/app/src/main/java/com/example/fitbot/ui/SportMenuActivity.java b/code/src/Fitbot/app/src/main/java/com/example/fitbot/ui/SportMenuActivity.java new file mode 100644 index 0000000..d6d060a --- /dev/null +++ b/code/src/Fitbot/app/src/main/java/com/example/fitbot/ui/SportMenuActivity.java @@ -0,0 +1,22 @@ +package com.example.fitbot.ui; + +import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; + +import com.example.fitbot.R; + + +public class SportMenuActivity extends AppCompatActivity { + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_sport_menu); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + } +} \ No newline at end of file diff --git a/code/src/Fitbot/app/src/main/java/com/example/fitbot/ui/SportMenuItem.java b/code/src/Fitbot/app/src/main/java/com/example/fitbot/ui/SportMenuItem.java new file mode 100644 index 0000000..1d6f394 --- /dev/null +++ b/code/src/Fitbot/app/src/main/java/com/example/fitbot/ui/SportMenuItem.java @@ -0,0 +1,45 @@ +package com.example.fitbot.ui; + +import android.content.Context; +import android.content.Intent; +import android.graphics.Bitmap; +import android.graphics.Canvas; +import android.graphics.Paint; +import android.graphics.Rect; +import android.view.View; + +import com.example.fitbot.sports.ESportType; + +public class SportMenuItem extends View { + + private Paint backgroundPaint, textPaint; + private String title, description; + private Bitmap imageResource; + private Rect imageRect, elementRect; + private ESportType type; + + public SportMenuItem(Context context, ESportType type, String title, String description, Bitmap backgroundImage) { + super(context); + this.title = title; + this.description = description; + this.imageResource = backgroundImage; + this.imageRect = new Rect(0, 0, this.imageResource.getWidth(), this.imageResource.getHeight()); + this.elementRect = new Rect(0, 0, this.getWidth(), this.getHeight()); + this.type = type; + this.backgroundPaint = new Paint(); + this.textPaint = new Paint(); + this.textPaint.setTextAlign(Paint.Align.CENTER); + this.backgroundPaint.setColor(0xFFF0F0F0); + this.textPaint.setColor(0xFF000000); + + this.setOnClickListener(v -> context.startActivity(new Intent(context, SportItemActivity.class))); + } + + @Override + protected void onDraw(Canvas canvas) { + super.onDraw(canvas); + canvas.drawBitmap(this.imageResource, this.imageRect, this.elementRect, null); + canvas.drawRoundRect(0, 0, getWidth(), getHeight(), 10, 10, backgroundPaint); + canvas.drawText(title, getWidth() / 2.0f, this.textPaint.getFontMetrics().top, textPaint); + } +} diff --git a/code/src/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/code/src/Fitbot/app/src/main/res/drawable-v24/ic_launcher_foreground.xml similarity index 100% rename from code/src/app/src/main/res/drawable-v24/ic_launcher_foreground.xml rename to code/src/Fitbot/app/src/main/res/drawable-v24/ic_launcher_foreground.xml diff --git a/code/src/app/src/main/res/drawable/ic_launcher_background.xml b/code/src/Fitbot/app/src/main/res/drawable/ic_launcher_background.xml similarity index 100% rename from code/src/app/src/main/res/drawable/ic_launcher_background.xml rename to code/src/Fitbot/app/src/main/res/drawable/ic_launcher_background.xml diff --git a/code/src/Fitbot/app/src/main/res/layout/activity_bicepvideo.xml b/code/src/Fitbot/app/src/main/res/layout/activity_bicepvideo.xml new file mode 100644 index 0000000..b866143 --- /dev/null +++ b/code/src/Fitbot/app/src/main/res/layout/activity_bicepvideo.xml @@ -0,0 +1,58 @@ + + + + + +