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 index 65f5e43..6820fd7 100644 --- 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 @@ -1,6 +1,8 @@ package com.example.fitbot; +import android.content.Intent; import android.os.Bundle; +import android.widget.Button; import com.aldebaran.qi.sdk.QiContext; import com.aldebaran.qi.sdk.QiSDK; @@ -8,6 +10,7 @@ import com.aldebaran.qi.sdk.RobotLifecycleCallbacks; import com.aldebaran.qi.sdk.builder.SayBuilder; import com.aldebaran.qi.sdk.design.activity.RobotActivity; import com.aldebaran.qi.sdk.object.conversation.Say; +import com.example.fitbot.ui.SportMenuActivity; public class MainActivity extends RobotActivity implements RobotLifecycleCallbacks { @@ -17,6 +20,12 @@ public class MainActivity extends RobotActivity implements RobotLifecycleCallbac super.onCreate(savedInstanceState); // Register the RobotLifecycleCallbacks to this Activity. QiSDK.register(this, this); + + Button button = findViewById(R.id.menu_switch_btn); + button.setOnClickListener(v -> { + Intent i = new Intent(MainActivity.this, SportMenuActivity.class); + startActivity(i); + }); } @Override @@ -30,7 +39,7 @@ public class MainActivity extends RobotActivity implements RobotLifecycleCallbac 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. + .withText("Hallo, heb je zin om sportieve activiteiten te verrichten?") // Set the text to say. .build(); // Build the say action. // Execute the action. 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 index 61c265a..c731a72 100644 --- 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 @@ -6,6 +6,9 @@ import com.aldebaran.qi.sdk.object.locale.Language; import com.aldebaran.qi.sdk.object.locale.Locale; import com.aldebaran.qi.sdk.object.locale.Region; +/** + * SpeechGenerator class for generating speech for the robot + */ public class SpeechGenerator { private static final Locale DUTCH_LOCALE = new Locale(Language.DUTCH, Region.NETHERLANDS); @@ -21,13 +24,18 @@ public class SpeechGenerator { say(phrase, ctx, DUTCH_LOCALE); } - - - public static void say(String text, QiContext ctx, Locale locale) + /** + * Function for making the robot say something with a specific locale + * @param phrase The phrase to make the robot say + * @param ctx The QiContext to use + * @param locale The locale to use + */ + public static void say(String phrase, QiContext ctx, Locale locale) { - SayBuilder.with(ctx) + SayBuilder + .with(ctx) .withLocale(locale) - .withText(text) + .withText(phrase) .build() .run(); } 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 index 1d6f394..f571a81 100644 --- 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 @@ -12,16 +12,15 @@ 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; + private final Paint backgroundPaint, textPaint; + private final String title; + private final Bitmap imageResource; + private final Rect imageRect, elementRect; + private final ESportType type; - public SportMenuItem(Context context, ESportType type, String title, String description, Bitmap backgroundImage) { + public SportMenuItem(Context context, ESportType type, String title, 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()); @@ -29,6 +28,7 @@ public class SportMenuItem extends View { this.backgroundPaint = new Paint(); this.textPaint = new Paint(); this.textPaint.setTextAlign(Paint.Align.CENTER); + this.backgroundPaint.setColor(0xFFF0F0F0); this.textPaint.setColor(0xFF000000); @@ -41,5 +41,6 @@ public class SportMenuItem extends View { 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); + canvas.drawText("Categorie: " + type.getName(), getWidth() / 2.0f, getHeight() - this.textPaint.getFontMetrics().bottom, textPaint); } }