Browse Source

Added Activities to MainActivity and made them accessible

DoNotMerge_Runnable_Test_Branch
Christian Tinz 1 year ago
parent
commit
9f253b655c

+ 18
- 0
app/src/main/AndroidManifest.xml View File

@@ -9,6 +9,24 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.GreenWatch">
<activity
android:name=".ConnectionActivity"
android:exported="false" />
<activity
android:name=".VideodetectionAndAccelerometerActivity"
android:exported="false" />
<activity
android:name=".AudiodetectionAndAccelerometerActivity"
android:exported="false" />
<activity
android:name=".VideodetectionActivity"
android:exported="false" />
<activity
android:name=".AudiodetectionActivity"
android:exported="false" />
<activity
android:name=".AccelerometerActivity"
android:exported="false" />
<activity
android:name=".MainActivity"
android:exported="true">

+ 78
- 0
app/src/main/java/com/example/greenwatch/MainActivity.java View File

@@ -2,13 +2,91 @@ package com.example.greenwatch;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {

private Button audiodetectionButton;
private Button videodetectionButton;
private Button accelerometerButton;
private Button audiodetectionAndAccelerometerButton;
private Button videodetectionAndAccelerometerButton;
private Button connectionButton;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

audiodetectionButton = (Button) findViewById(R.id.audiodetectionButton);
videodetectionButton = (Button) findViewById(R.id.videodetectionButton);
accelerometerButton = (Button) findViewById(R.id.accelerometerButton);
audiodetectionAndAccelerometerButton = (Button) findViewById(R.id.audiodetectionAndAccelerometerButton);
videodetectionAndAccelerometerButton = (Button) findViewById(R.id.videodetectionAndAccelerometerButton);
connectionButton = (Button) findViewById(R.id.connectionButton);
audiodetectionButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openAudiodetectionActivity();
}
});
videodetectionButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openVideodetectionActivity();
}
});
accelerometerButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openAccelerometerActivity();
}
});
audiodetectionAndAccelerometerButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openAudiodetectionAndAccelerometerActivity();
}
});
videodetectionAndAccelerometerButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openVideodetectionAndAccelerometerActivity();
}
});
connectionButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openConnectionActivity();
}
});
}
public void openAudiodetectionActivity(){
Intent intent = new Intent(this, AudiodetectionActivity.class);
startActivity(intent);
}
public void openVideodetectionActivity(){
Intent intent = new Intent(this, VideodetectionActivity.class);
startActivity(intent);
}
public void openAccelerometerActivity(){
Intent intent = new Intent(this, AccelerometerActivity.class);
startActivity(intent);
}
public void openAudiodetectionAndAccelerometerActivity(){
Intent intent = new Intent(this, AudiodetectionAndAccelerometerActivity.class);
startActivity(intent);
}
public void openVideodetectionAndAccelerometerActivity(){
Intent intent = new Intent(this, VideodetectionAndAccelerometerActivity.class);
startActivity(intent);
}
public void openConnectionActivity(){
Intent intent = new Intent(this, ConnectionActivity.class);
startActivity(intent);
}

}

+ 65
- 8
app/src/main/res/layout/activity_main.xml View File

@@ -1,18 +1,75 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout 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="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp"
tools:context=".MainActivity">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tvStatusmessage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
android:layout_weight="1">
</TextView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_weight="1">

</androidx.constraintlayout.widget.ConstraintLayout>
<Button
android:id="@+id/audiodetectionButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Audiodetection">
</Button>

<Button
android:id="@+id/videodetectionButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Videodetection">
</Button>

<Button
android:id="@+id/accelerometerButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Accelerometer">
</Button>

<Button
android:id="@+id/audiodetectionAndAccelerometerButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Audiodetection + Accelerometer">
</Button>

<Button
android:id="@+id/videodetectionAndAccelerometerButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Videodetection + Accelerometer">
</Button>

<Button
android:id="@+id/connectionButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Connect to Devices">
</Button>

</LinearLayout>

</LinearLayout>

Loading…
Cancel
Save