Added generic code in MainActivity for robot

This commit is contained in:
Luca Warmenhoven
2024-04-19 15:40:18 +02:00
parent c9a35f5e2a
commit 56875ce2d8
3 changed files with 39 additions and 23 deletions

25
.idea/workspace.xml generated
View File

@@ -14,19 +14,8 @@
</configurations>
</component>
<component name="ChangeListManager">
<list default="true" id="00599d5b-7eb5-44da-ad7f-98bf42384c16" name="Changes" comment="Moved files to appropriate directory.">
<change afterPath="$PROJECT_DIR$/fitbot/.gitignore" afterDir="false" />
<change afterPath="$PROJECT_DIR$/fitbot/build.gradle" afterDir="false" />
<change afterPath="$PROJECT_DIR$/fitbot/proguard-rules.pro" afterDir="false" />
<change afterPath="$PROJECT_DIR$/fitbot/src/androidTest/java/com/fitbot/ExampleInstrumentedTest.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/fitbot/src/main/AndroidManifest.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/fitbot/src/test/java/com/fitbot/ExampleUnitTest.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/local.properties" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/code/src/app/build.gradle" beforeDir="false" afterPath="$PROJECT_DIR$/code/src/app/build.gradle" afterDir="false" />
<change beforePath="$PROJECT_DIR$/code/src/app/src/main/AndroidManifest.xml" beforeDir="false" afterPath="$PROJECT_DIR$/code/src/app/src/main/AndroidManifest.xml" afterDir="false" />
<list default="true" id="00599d5b-7eb5-44da-ad7f-98bf42384c16" name="Changes" comment="Added speech example">
<change beforePath="$PROJECT_DIR$/code/src/app/src/main/java/com/fitbot/speech/SpeechGenerator.java" beforeDir="false" afterPath="$PROJECT_DIR$/code/src/app/src/main/java/com/fitbot/speech/SpeechGenerator.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/app/res/activity_main.xml" beforeDir="false" afterPath="$PROJECT_DIR$/fitbot/consumer-rules.pro" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -193,7 +182,14 @@
<option name="project" value="LOCAL" />
<updated>1713530847982</updated>
</task>
<option name="localTasksCounter" value="4" />
<task id="LOCAL-00004" summary="Added speech example">
<created>1713533683504</created>
<option name="number" value="00004" />
<option name="presentableId" value="LOCAL-00004" />
<option name="project" value="LOCAL" />
<updated>1713533683504</updated>
</task>
<option name="localTasksCounter" value="5" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
@@ -215,6 +211,7 @@
<MESSAGE value="Changes" />
<MESSAGE value="Added audio recorder files and speech callbacks" />
<MESSAGE value="Moved files to appropriate directory." />
<option name="LAST_COMMIT_MESSAGE" value="Moved files to appropriate directory." />
<MESSAGE value="Added speech example" />
<option name="LAST_COMMIT_MESSAGE" value="Added speech example" />
</component>
</project>

View File

@@ -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.
}
}

View File

@@ -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");
}