From 56875ce2d8863e86882348a236cc6245b48190a2 Mon Sep 17 00:00:00 2001 From: Luca Warmenhoven Date: Fri, 19 Apr 2024 15:40:18 +0200 Subject: [PATCH] Added generic code in MainActivity for robot --- .idea/workspace.xml | 25 +++++++------- .../main/java/com/fitbot/MainActivity.java | 33 +++++++++++++++---- .../com/fitbot/speech/SpeechGenerator.java | 4 +-- 3 files changed, 39 insertions(+), 23 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 1f50acc..057fce9 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -14,19 +14,8 @@ - - - - - - - - - - - + - @@ -215,6 +211,7 @@ - \ No newline at end of file diff --git a/code/src/app/src/main/java/com/fitbot/MainActivity.java b/code/src/app/src/main/java/com/fitbot/MainActivity.java index 204e1d2..5a784ff 100644 --- a/code/src/app/src/main/java/com/fitbot/MainActivity.java +++ b/code/src/app/src/main/java/com/fitbot/MainActivity.java @@ -4,15 +4,34 @@ import android.app.Activity; import android.media.MediaRecorder; import android.os.Bundle; -public class MainActivity extends Activity { +public class MainActivity extends RobotActivity implements RobotLifecycleCallbacks { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - - /* Since this is our main activity, we can start our audio recording service here */ - - - + // 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) { + // The robot focus is gained. + } + + @Override + public void onRobotFocusLost() { + // The robot focus is lost. + } + + @Override + public void onRobotFocusRefused(String reason) { + // The robot focus is refused. + } +} \ No newline at end of file diff --git a/code/src/app/src/main/java/com/fitbot/speech/SpeechGenerator.java b/code/src/app/src/main/java/com/fitbot/speech/SpeechGenerator.java index 2f888f4..93e1d19 100644 --- a/code/src/app/src/main/java/com/fitbot/speech/SpeechGenerator.java +++ b/code/src/app/src/main/java/com/fitbot/speech/SpeechGenerator.java @@ -29,11 +29,11 @@ public class SpeechGenerator { } /** - * Default constructor, sets the language to English + * Default constructor, sets the language to Dutch */ public SpeechGenerator() { - this("en"); + this("nl"); }