Added test UI for selecting sport items

This commit is contained in:
Luca Warmenhoven
2024-04-24 15:59:24 +02:00
13 changed files with 204 additions and 42 deletions

View File

@@ -3,12 +3,17 @@
<component name="DesignSurface">
<option name="filePathToZoomLevelMap">
<map>
<entry key="../../../../../../../../layout/custom_preview.xml" value="0.35989583333333336" />
<entry key="..\:/Users/31687/muupooviixee66-1/code/src/Fitbot/app/src/main/res/layout/activity_bicepvideo.xml" value="0.2015625" />
<entry key="..\:/Users/31687/muupooviixee66-1/code/src/Fitbot/app/src/main/res/layout/activity_main.xml" value="0.2015625" />
<entry key="..\:/Users/31687/muupooviixee66-1/code/src/Fitbot/app/src/main/res/layout/activity_main_screen.xml" value="0.358695652173913" />
<entry key="..\:/Users/sebas/Documents/HvA/Reposetories/muupooviixee66/code/src/Fitbot/app/src/main/res/layout/activity_bicepvideo.xml" value="0.22826086956521738" />
<entry key="..\:/Users/sebas/Documents/HvA/Reposetories/muupooviixee66/code/src/Fitbot/app/src/main/res/layout/activity_main.xml" value="0.1" />
<entry key="..\:/Users/sebas/Documents/HvA/Reposetories/muupooviixee66/code/src/Fitbot/app/src/main/res/layout/activity_main_screen.xml" value="0.1" />
<entry key="app/src/main/res/layout/activity_main.xml" value="0.2341485507246377" />
<entry key="app/src/main/res/layout/activity_sport_item.xml" value="0.2341485507246377" />
<entry key="app/src/main/res/layout/activity_sport_menu.xml" value="0.22056159420289856" />
<entry key="app/src/main/res/layout/sport_menu_item.xml" value="0.22056159420289856" />
</map>
</option>
</component>

View File

@@ -32,6 +32,7 @@ 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'

View File

@@ -11,6 +11,15 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Fitbot">
<activity
android:name=".ui.SportMenuActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".bicepvideo"
android:exported="false" />

View File

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

View File

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

View File

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

View File

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

View File

@@ -15,4 +15,13 @@
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/menu_switch_btn"
android:layout_width="200dp"
android:layout_height="50dp"
android:text="Go to Sport Menu"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
/>
</android.support.constraint.ConstraintLayout>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.support.constraint.ConstraintLayout>

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<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:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:context=".ui.SportMenuActivity">
<com.example.fitbot.ui.SportMenuItem
android:id="@+id/sportMenuItem1"
android:layout_width="300dp"
android:layout_height="300dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>