Compare commits
11
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ccdff78a4a | ||
|
|
373ca2d106 | ||
|
|
28c98ba766 | ||
|
|
559a95b1c2 | ||
|
|
9f253b655c | ||
|
|
d38e05a4b6 | ||
|
|
595d97ef57 | ||
|
|
1c360e8604 | ||
|
|
bd2927ed64 | ||
|
|
30f9c6c3f4 | ||
|
|
9e3652e275 |
No files matched your search
@@ -2,7 +2,6 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="com.example.greenwatch">
|
package="com.example.greenwatch">
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
|
||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
android:icon="@mipmap/ic_launcher"
|
android:icon="@mipmap/ic_launcher"
|
||||||
@@ -11,7 +10,22 @@
|
|||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/Theme.GreenWatch">
|
android:theme="@style/Theme.GreenWatch">
|
||||||
<activity
|
<activity
|
||||||
android:name=".Mikrofon"
|
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" />
|
android:exported="false" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".MainActivity"
|
android:name=".MainActivity"
|
||||||
|
|||||||
@@ -0,0 +1,137 @@
|
|||||||
|
package com.example.greenwatch;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.lifecycle.Observer;
|
||||||
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
|
|
||||||
|
import android.hardware.Sensor;
|
||||||
|
import android.hardware.SensorEvent;
|
||||||
|
import android.hardware.SensorEventListener;
|
||||||
|
import android.hardware.SensorManager;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.example.greenwatch.models.Device;
|
||||||
|
import com.example.greenwatch.viewmodels.AccelerometerViewModel;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class AccelerometerActivity extends AppCompatActivity implements SensorEventListener {
|
||||||
|
|
||||||
|
private SensorManager accelerometerManager;
|
||||||
|
private Sensor accelerometerSensor;
|
||||||
|
private TextView accelerometerStatusMessage;
|
||||||
|
private TextView accelerometerDataTV;
|
||||||
|
private TextView accelerometerWarningTV;
|
||||||
|
private Button backToMainActivityButton;
|
||||||
|
private AccelerometerViewModel mAccelerometerViewModel;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_accelerometer);
|
||||||
|
|
||||||
|
accelerometerStatusMessage = (TextView) findViewById(R.id.tvAccelerometerStatusmessage);
|
||||||
|
accelerometerDataTV = (TextView) findViewById(R.id.tvAccelerometerData);
|
||||||
|
accelerometerWarningTV = (TextView) findViewById(R.id.tvAccelerometerWarning);
|
||||||
|
backToMainActivityButton = (Button) findViewById(R.id.accelerometerBackToMainActivity);
|
||||||
|
|
||||||
|
backToMainActivityButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
mAccelerometerViewModel = new ViewModelProvider(this).get(AccelerometerViewModel.class);
|
||||||
|
mAccelerometerViewModel.init();
|
||||||
|
mAccelerometerViewModel.getConnectedDeviceList().observe(this, new Observer<List<Device>>() {
|
||||||
|
@Override
|
||||||
|
public void onChanged(List<Device> devices) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("Time Stamp: ");
|
||||||
|
sb.append(mAccelerometerViewModel.getTimeStamp(mAccelerometerViewModel.getLocalDeviceUUID()));
|
||||||
|
sb.append(";\n");
|
||||||
|
sb.append("DeviceID: ");
|
||||||
|
sb.append(mAccelerometerViewModel.getDeviceID(mAccelerometerViewModel.getLocalDeviceUUID()));
|
||||||
|
sb.append(";\n");
|
||||||
|
sb.append("Sensor Status: ");
|
||||||
|
sb.append(mAccelerometerViewModel.getSensorStatus(mAccelerometerViewModel.getLocalDeviceUUID()));
|
||||||
|
sb.append(";\n");
|
||||||
|
sb.append("Sensor Type: ");
|
||||||
|
sb.append(mAccelerometerViewModel.getSensorType(mAccelerometerViewModel.getLocalDeviceUUID()));
|
||||||
|
sb.append(";\n");
|
||||||
|
sb.append("Sensor Massage: ");
|
||||||
|
sb.append(mAccelerometerViewModel.getSensorMassage(mAccelerometerViewModel.getLocalDeviceUUID()));
|
||||||
|
accelerometerStatusMessage.setText(sb);
|
||||||
|
Toast.makeText(AccelerometerActivity.this, "onChanged", Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
mAccelerometerViewModel.getMovementDetectedValue().observe(this, new Observer<Boolean>() {
|
||||||
|
@Override
|
||||||
|
public void onChanged(Boolean aBoolean) {
|
||||||
|
if (aBoolean) {
|
||||||
|
mAccelerometerViewModel.setDevice(mAccelerometerViewModel.getLocalDeviceUUID(), mAccelerometerViewModel.getSystemTimeStamp(), mAccelerometerViewModel.getLocalDeviceUUID(), true, "Accelerometer", 10);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
mAccelerometerViewModel.setDevice(mAccelerometerViewModel.getLocalDeviceUUID(), mAccelerometerViewModel.getSystemTimeStamp(), mAccelerometerViewModel.getLocalDeviceUUID(), false, "Accelerometer", 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
accelerometerManager = (SensorManager) getSystemService(SENSOR_SERVICE);
|
||||||
|
if (accelerometerManager.getSensorList(Sensor.TYPE_GYROSCOPE).size() == 0) {
|
||||||
|
accelerometerSensor = null;
|
||||||
|
Toast.makeText(AccelerometerActivity.this, "No accelerometer sensor available", Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
accelerometerSensor = accelerometerManager.getSensorList(Sensor.TYPE_GYROSCOPE).get(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSensorChanged(SensorEvent event) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("x=")
|
||||||
|
.append(event.values[0])
|
||||||
|
.append("\ny=")
|
||||||
|
.append(event.values[1])
|
||||||
|
.append("\nz=")
|
||||||
|
.append(event.values[2]);
|
||||||
|
accelerometerDataTV.setText(sb.toString());
|
||||||
|
mAccelerometerViewModel.addValueToGesamtBE(event.values[0] + event.values[1] + event.values[2]);
|
||||||
|
mAccelerometerViewModel.meanValueCalculation();
|
||||||
|
mAccelerometerViewModel.calibrateAccelerometerSensor();
|
||||||
|
mAccelerometerViewModel.checkAlarmCondition();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAccuracyChanged(Sensor sensor, int accuracy) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
if (accelerometerSensor != null) {
|
||||||
|
if (accelerometerManager.registerListener(this, accelerometerSensor, SensorManager.SENSOR_DELAY_GAME)) {
|
||||||
|
Toast.makeText(AccelerometerActivity.this, "We registered to the sensor", Toast.LENGTH_LONG).show();
|
||||||
|
} else {
|
||||||
|
Toast.makeText(AccelerometerActivity.this, "Registration did not work", Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
if (accelerometerSensor != null) {
|
||||||
|
accelerometerManager.unregisterListener(this, accelerometerSensor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package com.example.greenwatch;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
|
||||||
|
public class AudiodetectionActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
private Button backToMainActivityButton;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_audiodetection);
|
||||||
|
|
||||||
|
backToMainActivityButton = (Button) findViewById(R.id.audiodetectorBackToMainActivity);
|
||||||
|
|
||||||
|
backToMainActivityButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package com.example.greenwatch;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
|
||||||
|
public class AudiodetectionAndAccelerometerActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
private Button backToMainActivity;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_audiodetection_and_accelerometer);
|
||||||
|
|
||||||
|
backToMainActivity = (Button) findViewById(R.id.audiodetectionAndAccelerometerBackToMainActivity);
|
||||||
|
|
||||||
|
backToMainActivity.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package com.example.greenwatch;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
|
||||||
|
public class ConnectionActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
private Button backToMainActivity;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_connection);
|
||||||
|
|
||||||
|
backToMainActivity = (Button) findViewById(R.id.connectionBackToMainActivity);
|
||||||
|
|
||||||
|
backToMainActivity.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
package com.example.greenwatch;
|
|
||||||
|
|
||||||
public class GleitenderMittelwert {
|
|
||||||
private final float wichtungNeuerWert;
|
|
||||||
private final float wichtungAlterWert;
|
|
||||||
private float mittelwert = 0;
|
|
||||||
|
|
||||||
private boolean istMittelwertGesetzt = false;
|
|
||||||
|
|
||||||
GleitenderMittelwert(float wichtungNeuerWert) {
|
|
||||||
this.wichtungNeuerWert = wichtungNeuerWert;
|
|
||||||
this.wichtungAlterWert = 1 - this.wichtungNeuerWert;
|
|
||||||
}
|
|
||||||
|
|
||||||
float mittel(float wert) {
|
|
||||||
if (istMittelwertGesetzt) {
|
|
||||||
mittelwert = wert * wichtungNeuerWert + mittelwert * wichtungAlterWert;
|
|
||||||
} else {
|
|
||||||
mittelwert = wert;
|
|
||||||
istMittelwertGesetzt = true;
|
|
||||||
}
|
|
||||||
return mittelwert;
|
|
||||||
}}
|
|
||||||
@@ -1,25 +1,138 @@
|
|||||||
package com.example.greenwatch;
|
package com.example.greenwatch;
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.lifecycle.Observer;
|
||||||
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.example.greenwatch.models.Device;
|
||||||
|
import com.example.greenwatch.viewmodels.MainActivityViewModel;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
private TextView tvstatusmessage;
|
||||||
|
private Button audiodetectionButton;
|
||||||
|
private Button videodetectionButton;
|
||||||
|
private Button accelerometerButton;
|
||||||
|
private Button audiodetectionAndAccelerometerButton;
|
||||||
|
private Button videodetectionAndAccelerometerButton;
|
||||||
|
private Button connectionButton;
|
||||||
|
private MainActivityViewModel mMainActivityViewModel;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
|
|
||||||
((Button)findViewById(R.id.buttonstartmicdetection)).setOnClickListener(new View.OnClickListener(){
|
tvstatusmessage = (TextView) findViewById(R.id.tvStatusmessage);
|
||||||
|
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);
|
||||||
|
|
||||||
|
mMainActivityViewModel = new ViewModelProvider(this).get(MainActivityViewModel.class);
|
||||||
|
mMainActivityViewModel.init();
|
||||||
|
mMainActivityViewModel.getConnectedDeviceList().observe(this, new Observer<List<Device>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onChanged(List<Device> devices) {
|
||||||
Intent i = new Intent(MainActivity.this, Mikrofon.class);
|
StringBuilder sb = new StringBuilder();
|
||||||
startActivity(i);
|
sb.append("Time Stamp: ");
|
||||||
|
sb.append(mMainActivityViewModel.getTimeStamp(mMainActivityViewModel.getLocalDeviceUUID()));
|
||||||
|
sb.append(";\n");
|
||||||
|
sb.append("DeviceID: ");
|
||||||
|
sb.append(mMainActivityViewModel.getDeviceID(mMainActivityViewModel.getLocalDeviceUUID()));
|
||||||
|
sb.append(";\n");
|
||||||
|
sb.append("Sensor Status: ");
|
||||||
|
sb.append(mMainActivityViewModel.getSensorStatus(mMainActivityViewModel.getLocalDeviceUUID()));
|
||||||
|
sb.append(";\n");
|
||||||
|
sb.append("Sensor Type: ");
|
||||||
|
sb.append(mMainActivityViewModel.getSensorType(mMainActivityViewModel.getLocalDeviceUUID()));
|
||||||
|
sb.append(";\n");
|
||||||
|
sb.append("Sensor Massage: ");
|
||||||
|
sb.append(mMainActivityViewModel.getSensorMassage(mMainActivityViewModel.getLocalDeviceUUID()));
|
||||||
|
tvstatusmessage.setText(sb);
|
||||||
|
Toast.makeText(MainActivity.this, "onChanged", Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
audiodetectionButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
//openAudiodetectionActivity();
|
||||||
|
mMainActivityViewModel.setDevice(mMainActivityViewModel.getLocalDeviceUUID(), "10:51", "12345", false, "Audio", 10);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
videodetectionButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
//openVideodetectionActivity();
|
||||||
|
mMainActivityViewModel.setSensorType(mMainActivityViewModel.getLocalDeviceUUID(), "Video");
|
||||||
|
mMainActivityViewModel.setTimeStamp(mMainActivityViewModel.getLocalDeviceUUID(), "12:50");
|
||||||
|
mMainActivityViewModel.setDeviceID(mMainActivityViewModel.getLocalDeviceUUID(), mMainActivityViewModel.getLocalDeviceUUID());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
accelerometerButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
openAccelerometerActivity();
|
||||||
|
mMainActivityViewModel.setSensorType(mMainActivityViewModel.getLocalDeviceUUID(), "Accelerometer");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
audiodetectionAndAccelerometerButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
//openAudiodetectionAndAccelerometerActivity();
|
||||||
|
mMainActivityViewModel.setSensorType(mMainActivityViewModel.getLocalDeviceUUID(), "AudiodetectionAndAccelerometer");
|
||||||
|
mMainActivityViewModel.setTimeStamp(mMainActivityViewModel.getLocalDeviceUUID(), "00:00");
|
||||||
|
mMainActivityViewModel.setDeviceID(mMainActivityViewModel.getLocalDeviceUUID(), "6789");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,254 +1,4 @@
|
|||||||
package com.example.greenwatch;
|
package com.example.greenwatch;
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
public class Mikrofon {
|
||||||
import androidx.core.app.ActivityCompat;
|
|
||||||
import androidx.core.content.ContextCompat;
|
|
||||||
|
|
||||||
import android.Manifest;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.media.AudioFormat;
|
|
||||||
import android.media.AudioRecord;
|
|
||||||
import android.media.MediaRecorder;
|
|
||||||
import android.os.AsyncTask;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
public class Mikrofon extends AppCompatActivity {
|
|
||||||
|
|
||||||
private AufnahmeTask aufnahmeTask;
|
|
||||||
private TextView textViewMaxAmp;
|
|
||||||
private TextView textViewMaxAmpdb;
|
|
||||||
private TextView textViewZeitstempel;
|
|
||||||
private static final int RECHTEANFORDERUNG_MIKROFON = 1;
|
|
||||||
|
|
||||||
private boolean detection_mic = false;
|
|
||||||
private String zeit = "0";
|
|
||||||
private boolean kalibrierung_do = true;
|
|
||||||
private float threshold = 40;
|
|
||||||
private float sensitivity = 5;
|
|
||||||
private final static String KEY_WERT = "KEY_WERT_" + Mikrofon.class.getSimpleName();
|
|
||||||
private final static String KEY_KALIBRIERUNG = "KEY_KALIBRIERUNG_" + Mikrofon.class.getSimpleName();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setContentView(R.layout.activity_mikrofon);
|
|
||||||
textViewMaxAmp = (TextView) findViewById(R.id.textViewMaxAmp);
|
|
||||||
textViewMaxAmpdb = (TextView) findViewById(R.id.textViewMaxAmpdb);
|
|
||||||
textViewZeitstempel = (TextView) findViewById(R.id.textViewZeitstempel);
|
|
||||||
//kalibrierung_do = true;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
SharedPreferences p = getPreferences(Context.MODE_PRIVATE);
|
|
||||||
threshold = p.getFloat(KEY_WERT, 40);
|
|
||||||
kalibrierung_do = p.getBoolean(KEY_KALIBRIERUNG, true);
|
|
||||||
|
|
||||||
if (!istZugriffAufMikrofonErlaubt()) {
|
|
||||||
zugriffAufMikrofonAnfordern();
|
|
||||||
}
|
|
||||||
if (istZugriffAufMikrofonErlaubt()) {
|
|
||||||
aufnahmeTask = new AufnahmeTask();
|
|
||||||
aufnahmeTask.execute();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPause() {
|
|
||||||
super.onPause();
|
|
||||||
SharedPreferences p = getPreferences(Context.MODE_PRIVATE);
|
|
||||||
SharedPreferences.Editor editor = p.edit();
|
|
||||||
editor.putFloat(KEY_WERT, threshold);
|
|
||||||
if(isFinishing()==true){
|
|
||||||
editor.putBoolean(KEY_KALIBRIERUNG, true);
|
|
||||||
}else {
|
|
||||||
editor.putBoolean(KEY_KALIBRIERUNG, false);
|
|
||||||
}
|
|
||||||
editor.commit();
|
|
||||||
if(aufnahmeTask!=null) {
|
|
||||||
aufnahmeTask.cancel(true);
|
|
||||||
aufnahmeTask = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean istZugriffAufMikrofonErlaubt() {
|
|
||||||
if (ContextCompat.checkSelfPermission(this, android.Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void zugriffAufMikrofonAnfordern() {
|
|
||||||
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.RECORD_AUDIO}, RECHTEANFORDERUNG_MIKROFON);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String Zeitpunkt(){
|
|
||||||
Long tslong = System.currentTimeMillis();
|
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
|
|
||||||
Date date = new Date(tslong);
|
|
||||||
String resultdate = sdf.format(date);
|
|
||||||
|
|
||||||
return resultdate;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class AufnahmeTask extends AsyncTask<Long, Verarbeitungsergebnis, Void> {
|
|
||||||
private AudioRecord recorder;
|
|
||||||
private final int sampleRateInHz = 44100;
|
|
||||||
private final int channelConfig = AudioFormat.CHANNEL_IN_MONO;
|
|
||||||
private final int audioFormat = AudioFormat.ENCODING_PCM_16BIT;
|
|
||||||
private int minPufferGroesseInBytes;
|
|
||||||
private int pufferGroesseInBytes;
|
|
||||||
private RingPuffer ringPuffer = new RingPuffer(10);
|
|
||||||
private boolean erlaubt_rise = true;
|
|
||||||
private boolean erlaubt_fall = true;
|
|
||||||
|
|
||||||
AufnahmeTask() {
|
|
||||||
minPufferGroesseInBytes = AudioRecord.getMinBufferSize(sampleRateInHz, channelConfig, audioFormat);
|
|
||||||
pufferGroesseInBytes = minPufferGroesseInBytes * 2;
|
|
||||||
recorder = new AudioRecord(MediaRecorder.AudioSource.MIC, sampleRateInHz, channelConfig, audioFormat, pufferGroesseInBytes);
|
|
||||||
}
|
|
||||||
//hi
|
|
||||||
public float kalibrieren(short[] puffer){
|
|
||||||
try {
|
|
||||||
Thread.sleep(3000);
|
|
||||||
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
int anzahlIterationen = 100;
|
|
||||||
float sum = 0;
|
|
||||||
for(int i = 0; i < anzahlIterationen; i++){
|
|
||||||
int z = recorder.read(puffer, 0, puffer.length);
|
|
||||||
Verarbeitungsergebnis kalibrierung = verarbeiten(puffer, z);
|
|
||||||
sum += (float) kalibrierung.db;
|
|
||||||
System.out.println("Aktueller_Wert Kalibrierung" +kalibrierung.db);
|
|
||||||
}
|
|
||||||
System.out.println("Summe:"+sum);
|
|
||||||
return sum/anzahlIterationen;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Detektion(Verarbeitungsergebnis ergebnis){
|
|
||||||
if(ergebnis.db >= (threshold+sensitivity)){
|
|
||||||
detection_mic = true;
|
|
||||||
erlaubt_fall = true;
|
|
||||||
while(erlaubt_rise){
|
|
||||||
erlaubt_rise = false;
|
|
||||||
zeit = Zeitpunkt() + " - " + ergebnis.db + " - " + (threshold+sensitivity); //Überschreiben des Zeitpunkts beim Erkennen der Detektion
|
|
||||||
//nur zum Testen in zeit noch ergebnis.db und threshold ausgegeben -> muss am Ende nur Zeitpunkt() rein, Rest weg
|
|
||||||
}
|
|
||||||
} else if (ergebnis.db <= (threshold)) {
|
|
||||||
detection_mic = false;
|
|
||||||
erlaubt_rise = true;
|
|
||||||
while(erlaubt_fall){
|
|
||||||
erlaubt_fall = false;
|
|
||||||
zeit = Zeitpunkt(); //erneutes Überschreiben des Zeitpunkts beim Verschwinden der Detektion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
protected Void doInBackground(Long... params) {
|
|
||||||
|
|
||||||
recorder.startRecording();
|
|
||||||
short[] puffer = new short[pufferGroesseInBytes / 2];
|
|
||||||
GleitenderMittelwert gleitenderMittelwertdB = new GleitenderMittelwert(0.2f);
|
|
||||||
float db = 0;
|
|
||||||
|
|
||||||
|
|
||||||
//kalibrierung
|
|
||||||
if(kalibrierung_do){
|
|
||||||
threshold = kalibrieren(puffer);
|
|
||||||
kalibrierung_do = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
for (; ; ) {
|
|
||||||
if (isCancelled()) {
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
//ergebnis ermitteln
|
|
||||||
int n = recorder.read(puffer, 0, puffer.length);
|
|
||||||
Verarbeitungsergebnis ergebnis = verarbeiten(puffer, n);
|
|
||||||
|
|
||||||
//Mittelwertberechnnung
|
|
||||||
db = (float) ergebnis.db;
|
|
||||||
db = gleitenderMittelwertdB.mittel(db);
|
|
||||||
ergebnis.db = (int) db;
|
|
||||||
|
|
||||||
//Db Wert mit Schwellwert vergleichen und Warnung setzen
|
|
||||||
Detektion(ergebnis);
|
|
||||||
publishProgress(ergebnis);
|
|
||||||
|
|
||||||
try {
|
|
||||||
Thread.sleep(10);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
recorder.release();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Verarbeitungsergebnis verarbeiten(short[] daten, int n) {
|
|
||||||
String status;
|
|
||||||
short maxAmp = -1;
|
|
||||||
int db = 0, db_wert = 0;
|
|
||||||
|
|
||||||
if (n == AudioRecord.ERROR_INVALID_OPERATION) {
|
|
||||||
status = "ERROR_INVALID_OPERATION";
|
|
||||||
} else if (n == AudioRecord.ERROR_BAD_VALUE) {
|
|
||||||
status = "ERROR_BAD_VALUE";
|
|
||||||
} else {
|
|
||||||
status = "OK";
|
|
||||||
short max = 0;
|
|
||||||
for (int i = 0; i < n; i++) {
|
|
||||||
if (daten[i] > max) {
|
|
||||||
max = daten[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ringPuffer.hinzufuegen(max);
|
|
||||||
maxAmp = ringPuffer.maximum();
|
|
||||||
}
|
|
||||||
//Umwandlung Amplitudenwert in dB
|
|
||||||
db_wert = (int) (20*Math.log10(maxAmp));
|
|
||||||
if (db_wert > 0){
|
|
||||||
db = db_wert;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return new Verarbeitungsergebnis(status, maxAmp, db);
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////
|
|
||||||
@Override
|
|
||||||
protected void onProgressUpdate(Verarbeitungsergebnis... progress) {
|
|
||||||
super.onProgressUpdate(progress);
|
|
||||||
|
|
||||||
|
|
||||||
System.out.println(detection_mic);
|
|
||||||
System.out.println(zeit);
|
|
||||||
textViewZeitstempel.setText(zeit);
|
|
||||||
|
|
||||||
textViewMaxAmpdb.setText("" + progress[0].db);
|
|
||||||
textViewMaxAmp.setText("" + progress[0].maxAmp);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/////////////////////////////////////////////
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
package com.example.greenwatch;
|
|
||||||
|
|
||||||
public class RingPuffer {
|
|
||||||
|
|
||||||
private short[] puffer;
|
|
||||||
private final int laenge;
|
|
||||||
private int anzahlEnthaltenerDaten;
|
|
||||||
private int position;
|
|
||||||
|
|
||||||
|
|
||||||
public RingPuffer(int n) {
|
|
||||||
laenge = n;
|
|
||||||
anzahlEnthaltenerDaten = 0;
|
|
||||||
position = 0;
|
|
||||||
puffer = new short[laenge];
|
|
||||||
}
|
|
||||||
|
|
||||||
public void hinzufuegen(short wert) {
|
|
||||||
puffer[position] = wert;
|
|
||||||
position++;
|
|
||||||
if (position >= laenge) {
|
|
||||||
position = 0;
|
|
||||||
}
|
|
||||||
if (anzahlEnthaltenerDaten < laenge) {
|
|
||||||
anzahlEnthaltenerDaten++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*public void hinzufuegen(short[] daten) {
|
|
||||||
for (short d : daten) {
|
|
||||||
puffer[position] = d;
|
|
||||||
position++;
|
|
||||||
if (position >= laenge) {
|
|
||||||
position = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (anzahlEnthaltenerDaten < laenge) {
|
|
||||||
anzahlEnthaltenerDaten += daten.length;
|
|
||||||
if (anzahlEnthaltenerDaten >= laenge) {
|
|
||||||
anzahlEnthaltenerDaten = laenge;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
public short maximum() {
|
|
||||||
short max = 0;
|
|
||||||
for (int i = 0; i < anzahlEnthaltenerDaten; i++) {
|
|
||||||
if (puffer[i] > max) {
|
|
||||||
max = puffer[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return max;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* public float mittelwert() {
|
|
||||||
float summe = 0;
|
|
||||||
for (int i = 0; i < anzahlEnthaltenerDaten; i++) {
|
|
||||||
summe += puffer[i];
|
|
||||||
}
|
|
||||||
return summe / anzahlEnthaltenerDaten;
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package com.example.greenwatch;
|
|
||||||
|
|
||||||
public class Verarbeitungsergebnis {
|
|
||||||
String status;
|
|
||||||
short maxAmp;
|
|
||||||
int db;
|
|
||||||
//
|
|
||||||
Verarbeitungsergebnis(String status, short maxAmp, int db) {
|
|
||||||
this.status = status;
|
|
||||||
this.maxAmp = maxAmp;
|
|
||||||
this.db = db;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package com.example.greenwatch;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
|
||||||
|
public class VideodetectionActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
private Button backToMainActivity;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_videodetection);
|
||||||
|
|
||||||
|
backToMainActivity = (Button) findViewById(R.id.videodetectorBackToMainActivity);
|
||||||
|
|
||||||
|
backToMainActivity.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package com.example.greenwatch;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
|
||||||
|
public class VideodetectionAndAccelerometerActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
private Button backToMainActivity;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_videodetection_and_accelerometer);
|
||||||
|
|
||||||
|
backToMainActivity = (Button) findViewById(R.id.videodetectionAndAccelerometerBackToMainActivity);
|
||||||
|
|
||||||
|
backToMainActivity.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
package com.example.greenwatch.models;
|
||||||
|
|
||||||
|
|
||||||
|
public class Device {
|
||||||
|
|
||||||
|
private String timeStamp;
|
||||||
|
private String deviceID;
|
||||||
|
private boolean sensorStatus;
|
||||||
|
private String sensorType;
|
||||||
|
private int sensorMassage;
|
||||||
|
|
||||||
|
public Device(String timeStamp, String deviceID, boolean sensorStatus, String sensorType, int sensorMassage) {
|
||||||
|
this.timeStamp = timeStamp;
|
||||||
|
this.deviceID = deviceID;
|
||||||
|
this.sensorStatus = sensorStatus;
|
||||||
|
this.sensorType = sensorType;
|
||||||
|
this.sensorMassage = sensorMassage;
|
||||||
|
}
|
||||||
|
public void setTimeStamp(String timeStamp) {
|
||||||
|
this.timeStamp = timeStamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTimeStamp() {
|
||||||
|
return timeStamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeviceID(String deviceID) {
|
||||||
|
this.deviceID = deviceID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDeviceID() {
|
||||||
|
return deviceID;
|
||||||
|
}
|
||||||
|
public void setSensorType(String sensorType) {
|
||||||
|
this.sensorType = sensorType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSensorType() {
|
||||||
|
return sensorType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSensorStatus(boolean sensorStatus) {
|
||||||
|
this.sensorStatus = sensorStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getSensorStatus() {
|
||||||
|
return sensorStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSensorMassage(int sensorMassage) {
|
||||||
|
this.sensorMassage = sensorMassage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSensorMassage() {
|
||||||
|
return sensorMassage;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,216 @@
|
|||||||
|
package com.example.greenwatch.repositories;
|
||||||
|
|
||||||
|
|
||||||
|
import androidx.lifecycle.MutableLiveData;
|
||||||
|
|
||||||
|
import com.example.greenwatch.models.Device;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class DeviceRepository {
|
||||||
|
|
||||||
|
private String delimiter = ", ";
|
||||||
|
private String deviceUUID;
|
||||||
|
private static DeviceRepository deviceRepositoryInstance;
|
||||||
|
private MutableLiveData<List<Device>> deviceList = new MutableLiveData<>();
|
||||||
|
private HashMap<String, Device> connectedDevicesList = new HashMap<>();
|
||||||
|
private HashMap<String, String> deviceIDMapper = new HashMap<>();
|
||||||
|
|
||||||
|
public static synchronized DeviceRepository getInstance() {
|
||||||
|
if (deviceRepositoryInstance == null){
|
||||||
|
deviceRepositoryInstance = new DeviceRepository();
|
||||||
|
deviceRepositoryInstance.setDeviceUUID();
|
||||||
|
}
|
||||||
|
return deviceRepositoryInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MutableLiveData<List<Device>> getConnectedDeviceList() {
|
||||||
|
setMutableLiveDataValue();
|
||||||
|
return deviceList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void createNewDevice(String timeStamp, String deviceID, boolean sensorStatus, String sensorType, int sensorMassage){
|
||||||
|
Device newDevice = new Device(timeStamp, deviceID, sensorStatus, sensorType, sensorMassage);
|
||||||
|
addToConnectedDeviceList(newDevice.getDeviceID(), newDevice);
|
||||||
|
setMutableLiveDataValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void createNewRemoteDevice(String message) {
|
||||||
|
String[] messageString = messageStringSplitter(message);
|
||||||
|
String timeStamp = messageString[0];
|
||||||
|
String deviceID = messageString[1];
|
||||||
|
boolean sensorStatus = Boolean.valueOf(messageString[1]);
|
||||||
|
String sensorType = messageString[3];
|
||||||
|
int sensorMassage = Integer.valueOf(messageString[4]);
|
||||||
|
|
||||||
|
if(!connectedDevicesList.containsKey(deviceID)) {
|
||||||
|
createNewDevice(timeStamp, deviceID, sensorStatus, sensorType, sensorMassage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String messageStringBuilder(String deviceID) {
|
||||||
|
StringBuilder message = new StringBuilder();
|
||||||
|
Device device = connectedDevicesList.get(deviceID);
|
||||||
|
if(device != null) {
|
||||||
|
message.append(device.getTimeStamp())
|
||||||
|
.append(delimiter)
|
||||||
|
.append(device.getDeviceID())
|
||||||
|
.append(delimiter)
|
||||||
|
.append(device.getSensorStatus())
|
||||||
|
.append(delimiter)
|
||||||
|
.append(device.getSensorType())
|
||||||
|
.append(delimiter)
|
||||||
|
.append(device.getSensorMassage());
|
||||||
|
return message.toString();
|
||||||
|
}
|
||||||
|
return message.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLocalDeviceUUID() {
|
||||||
|
return deviceUUID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDevice(String deviceID, String timeStamp, String newDeviceID, boolean sensorStatus, String sensorType, int sensorMassage) {
|
||||||
|
String checkedDeviceID = checkDeviceID(deviceID);
|
||||||
|
Device device = connectedDevicesList.get(checkedDeviceID);
|
||||||
|
if(device != null) {
|
||||||
|
device.setTimeStamp(timeStamp);
|
||||||
|
device.setDeviceID(newDeviceID);
|
||||||
|
device.setSensorStatus(sensorStatus);
|
||||||
|
device.setSensorType(sensorType);
|
||||||
|
device.setSensorMassage(sensorMassage);
|
||||||
|
setDeviceIDMapper(newDeviceID);
|
||||||
|
connectedDevicesList.remove(checkedDeviceID);
|
||||||
|
addToConnectedDeviceList(newDeviceID, device);
|
||||||
|
setMutableLiveDataValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTimeStamp(String deviceID, String timeStamp) {
|
||||||
|
String checkedDeviceID = checkDeviceID(deviceID);
|
||||||
|
Device device = connectedDevicesList.get(checkedDeviceID);
|
||||||
|
if(device != null) {
|
||||||
|
device.setTimeStamp(timeStamp);
|
||||||
|
addToConnectedDeviceList(checkedDeviceID, device);
|
||||||
|
setMutableLiveDataValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTimeStamp(String deviceID) {
|
||||||
|
String checkedDeviceID = checkDeviceID(deviceID);
|
||||||
|
Device device = connectedDevicesList.get(checkedDeviceID);
|
||||||
|
if(device != null) {
|
||||||
|
return device.getTimeStamp();
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeviceID(String deviceID, String newDeviceID) {
|
||||||
|
String checkedDeviceID = checkDeviceID(deviceID);
|
||||||
|
Device device = connectedDevicesList.get(checkedDeviceID);
|
||||||
|
if(device != null) {
|
||||||
|
device.setDeviceID(newDeviceID);
|
||||||
|
setDeviceIDMapper(newDeviceID);
|
||||||
|
connectedDevicesList.remove(checkedDeviceID);
|
||||||
|
addToConnectedDeviceList(newDeviceID, device);
|
||||||
|
setMutableLiveDataValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDeviceID(String deviceID) {
|
||||||
|
String checkedDeviceID = checkDeviceID(deviceID);
|
||||||
|
Device device = connectedDevicesList.get(checkedDeviceID);
|
||||||
|
if(device != null) {
|
||||||
|
return device.getDeviceID();
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSensorStatus(String deviceID, boolean sensorStatus) {
|
||||||
|
String checkedDeviceID = checkDeviceID(deviceID);
|
||||||
|
Device device = connectedDevicesList.get(checkedDeviceID);
|
||||||
|
if(device != null) {
|
||||||
|
device.setSensorStatus(sensorStatus);
|
||||||
|
addToConnectedDeviceList(checkedDeviceID, device);
|
||||||
|
setMutableLiveDataValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getSensorStatus(String deviceID) {
|
||||||
|
String checkedDeviceID = checkDeviceID(deviceID);
|
||||||
|
Device device = connectedDevicesList.get(checkedDeviceID);
|
||||||
|
if(device != null) {
|
||||||
|
return device.getSensorStatus();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSensorType(String deviceID, String sensorType) {
|
||||||
|
String checkedDeviceID = checkDeviceID(deviceID);
|
||||||
|
Device device = connectedDevicesList.get(checkedDeviceID);
|
||||||
|
if(device != null) {
|
||||||
|
device.setSensorType(sensorType);
|
||||||
|
addToConnectedDeviceList(checkedDeviceID, device);
|
||||||
|
setMutableLiveDataValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSensorType(String deviceID) {
|
||||||
|
String checkedDeviceID = checkDeviceID(deviceID);
|
||||||
|
Device device = connectedDevicesList.get(checkedDeviceID);
|
||||||
|
if(device != null) {
|
||||||
|
return device.getSensorType();
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSensorMassage(String deviceID, int sensorMessage) {
|
||||||
|
String checkedDeviceID = checkDeviceID(deviceID);
|
||||||
|
Device device = connectedDevicesList.get(checkedDeviceID);
|
||||||
|
if(device != null) {
|
||||||
|
device.setSensorMassage(sensorMessage);
|
||||||
|
addToConnectedDeviceList(checkedDeviceID, device);
|
||||||
|
setMutableLiveDataValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSensorMassage(String deviceID) {
|
||||||
|
String checkedDeviceID = checkDeviceID(deviceID);
|
||||||
|
Device device = connectedDevicesList.get(checkedDeviceID);
|
||||||
|
if(device != null) {
|
||||||
|
return device.getSensorMassage();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setMutableLiveDataValue() {
|
||||||
|
List<Device> list = new ArrayList<>(connectedDevicesList.values());
|
||||||
|
deviceList.setValue(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addToConnectedDeviceList(String key, Device device) {
|
||||||
|
connectedDevicesList.put(key, device);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String checkDeviceID(String deviceID) {
|
||||||
|
if(!deviceIDMapper.isEmpty() && deviceID.equals(deviceUUID)) {
|
||||||
|
return deviceIDMapper.get(deviceID);
|
||||||
|
}
|
||||||
|
return deviceID;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setDeviceIDMapper(String deviceID) {
|
||||||
|
deviceIDMapper.put(deviceUUID, deviceID);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setDeviceUUID(){
|
||||||
|
this.deviceUUID = UUID.randomUUID().toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String[] messageStringSplitter(String message) {
|
||||||
|
return message.split(delimiter);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,143 @@
|
|||||||
|
package com.example.greenwatch.viewmodels;
|
||||||
|
|
||||||
|
import androidx.lifecycle.LiveData;
|
||||||
|
import androidx.lifecycle.MutableLiveData;
|
||||||
|
import androidx.lifecycle.ViewModel;
|
||||||
|
|
||||||
|
import com.example.greenwatch.models.Device;
|
||||||
|
import com.example.greenwatch.repositories.DeviceRepository;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class AccelerometerViewModel extends ViewModel {
|
||||||
|
|
||||||
|
private MutableLiveData<List<Device>> mDeviceList;
|
||||||
|
private MutableLiveData<Boolean> mMovementDetected = new MutableLiveData<>();
|
||||||
|
private DeviceRepository mDeviceRepository;
|
||||||
|
private ArrayList<Float> Gesamt_be;
|
||||||
|
int arraySize = 500;
|
||||||
|
int functionCallCount;
|
||||||
|
float meanValue;
|
||||||
|
float offsetValue;
|
||||||
|
float thresholdValue;
|
||||||
|
boolean startMeasuring;
|
||||||
|
|
||||||
|
public void init() {
|
||||||
|
if (mDeviceList == null) {
|
||||||
|
mDeviceRepository = DeviceRepository.getInstance();
|
||||||
|
mDeviceList = mDeviceRepository.getConnectedDeviceList();
|
||||||
|
}
|
||||||
|
initGesamtBE();
|
||||||
|
mMovementDetected.setValue(false);
|
||||||
|
functionCallCount = 0;
|
||||||
|
meanValue = 0f;
|
||||||
|
offsetValue = 0.1f;
|
||||||
|
thresholdValue = 0.15f;
|
||||||
|
startMeasuring = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initGesamtBE() {
|
||||||
|
Gesamt_be = new ArrayList<>(arraySize);
|
||||||
|
for (int i = 0; i < arraySize; i++) {
|
||||||
|
Gesamt_be.add(0f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addValueToGesamtBE(float newValue) {
|
||||||
|
if (Gesamt_be.size() == arraySize) {
|
||||||
|
Gesamt_be.remove(Gesamt_be.size() -1);
|
||||||
|
}
|
||||||
|
Gesamt_be.add(0, newValue);
|
||||||
|
functionCallCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void meanValueCalculation() {
|
||||||
|
for (float element : Gesamt_be) {
|
||||||
|
meanValue += Math.abs(element);
|
||||||
|
}
|
||||||
|
meanValue = meanValue/arraySize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void calibrateAccelerometerSensor() {
|
||||||
|
if (functionCallCount <= arraySize) {
|
||||||
|
offsetValue = meanValue;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
startMeasuring = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void checkAlarmCondition() {
|
||||||
|
if (meanValue > (thresholdValue + offsetValue) && startMeasuring && !mMovementDetected.getValue()) {
|
||||||
|
mMovementDetected.setValue(true);
|
||||||
|
}
|
||||||
|
else if (meanValue < (thresholdValue + offsetValue) && mMovementDetected.getValue()){
|
||||||
|
mMovementDetected.setValue(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSystemTimeStamp() {
|
||||||
|
SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
|
||||||
|
Date date = new Date(System.currentTimeMillis());
|
||||||
|
return formatter.format(date);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LiveData<Boolean> getMovementDetectedValue() {
|
||||||
|
return mMovementDetected;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LiveData<List<Device>> getConnectedDeviceList() {
|
||||||
|
return mDeviceList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDevice(String deviceID, String timeStamp, String newDeviceID, boolean sensorStatus, String sensorType, int sensorMassage) {
|
||||||
|
mDeviceRepository.setDevice(deviceID, timeStamp,newDeviceID, sensorStatus, sensorType, sensorMassage);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTimeStamp(String deviceID, String timeStamp) {
|
||||||
|
mDeviceRepository.setTimeStamp(deviceID, timeStamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTimeStamp(String deviceID) {
|
||||||
|
return mDeviceRepository.getTimeStamp(deviceID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeviceID(String deviceID, String newDeviceID) {
|
||||||
|
mDeviceRepository.setDeviceID(deviceID, newDeviceID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDeviceID(String deviceID) {
|
||||||
|
return mDeviceRepository.getDeviceID(deviceID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSensorStatus(String deviceID, boolean sensorStatus) {
|
||||||
|
mDeviceRepository.setSensorStatus(deviceID, sensorStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getSensorStatus(String deviceID) {
|
||||||
|
return mDeviceRepository.getSensorStatus(deviceID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSensorType(String deviceID, String sensorType) {
|
||||||
|
mDeviceRepository.setSensorType(deviceID, sensorType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSensorType(String deviceID) {
|
||||||
|
return mDeviceRepository.getSensorType(deviceID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSensorMassage(String deviceID, int sensorMessage) {
|
||||||
|
mDeviceRepository.setSensorMassage(deviceID, sensorMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSensorMassage(String deviceID) {
|
||||||
|
return mDeviceRepository.getSensorMassage(deviceID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLocalDeviceUUID() {
|
||||||
|
return mDeviceRepository.getLocalDeviceUUID();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
package com.example.greenwatch.viewmodels;
|
||||||
|
|
||||||
|
import androidx.lifecycle.LiveData;
|
||||||
|
import androidx.lifecycle.MutableLiveData;
|
||||||
|
import androidx.lifecycle.ViewModel;
|
||||||
|
|
||||||
|
import com.example.greenwatch.models.Device;
|
||||||
|
import com.example.greenwatch.repositories.DeviceRepository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class MainActivityViewModel extends ViewModel {
|
||||||
|
|
||||||
|
private MutableLiveData<List<Device>> mDeviceList;
|
||||||
|
private DeviceRepository mDeviceRepository;
|
||||||
|
|
||||||
|
public void init() {
|
||||||
|
if(mDeviceList != null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mDeviceRepository = DeviceRepository.getInstance();
|
||||||
|
mDeviceRepository.createNewDevice("", mDeviceRepository.getLocalDeviceUUID(), false, "", 0);
|
||||||
|
mDeviceList = mDeviceRepository.getConnectedDeviceList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public LiveData<List<Device>> getConnectedDeviceList() {
|
||||||
|
return mDeviceList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDevice(String deviceID, String timeStamp, String newDeviceID, boolean sensorStatus, String sensorType, int sensorMassage) {
|
||||||
|
mDeviceRepository.setDevice(deviceID, timeStamp,newDeviceID, sensorStatus, sensorType, sensorMassage);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTimeStamp(String deviceID, String timeStamp) {
|
||||||
|
mDeviceRepository.setTimeStamp(deviceID, timeStamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTimeStamp(String deviceID) {
|
||||||
|
return mDeviceRepository.getTimeStamp(deviceID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeviceID(String deviceID, String newDeviceID) {
|
||||||
|
mDeviceRepository.setDeviceID(deviceID, newDeviceID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDeviceID(String deviceID) {
|
||||||
|
return mDeviceRepository.getDeviceID(deviceID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSensorStatus(String deviceID, boolean sensorStatus) {
|
||||||
|
mDeviceRepository.setSensorStatus(deviceID, sensorStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getSensorStatus(String deviceID) {
|
||||||
|
return mDeviceRepository.getSensorStatus(deviceID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSensorType(String deviceID, String sensorType) {
|
||||||
|
mDeviceRepository.setSensorType(deviceID, sensorType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSensorType(String deviceID) {
|
||||||
|
return mDeviceRepository.getSensorType(deviceID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSensorMassage(String deviceID, int sensorMessage) {
|
||||||
|
mDeviceRepository.setSensorMassage(deviceID, sensorMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSensorMassage(String deviceID) {
|
||||||
|
return mDeviceRepository.getSensorMassage(deviceID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLocalDeviceUUID() {
|
||||||
|
return mDeviceRepository.getLocalDeviceUUID();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<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=".AccelerometerActivity">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvAccelerometerStatusmessage"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="">
|
||||||
|
</TextView>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvAccelerometerData"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="">
|
||||||
|
</TextView>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvAccelerometerWarning"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="">
|
||||||
|
</TextView>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/accelerometerBackToMainActivity"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Back to MainActivity">
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<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=".AudiodetectionActivity">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvAudiodetectionStatusmessage"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Audiodetection Activity">
|
||||||
|
</TextView>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/audiodetectorBackToMainActivity"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Back to MainActivity">
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<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=".AudiodetectionAndAccelerometerActivity">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvAudiodetectionAndAccelerometerStatusmessage"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Audiodetection + Accelerometer Activity">
|
||||||
|
</TextView>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/audiodetectionAndAccelerometerBackToMainActivity"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Back to MainActivity">
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<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=".ConnectionActivity">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvConnectionStatusmessage"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Connection Activity">
|
||||||
|
</TextView>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/connectionBackToMainActivity"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Back to MainActivity">
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
@@ -1,18 +1,75 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?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:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="10dp"
|
||||||
tools:context=".MainActivity">
|
tools:context=".MainActivity">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvStatusmessage"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:text="Hello World!"
|
||||||
|
android:layout_weight="1">
|
||||||
|
</TextView>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_weight="1">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/buttonstartmicdetection"
|
android:id="@+id/audiodetectionButton"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Starte Mikrofon Detection"
|
android:layout_weight="1"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
android:text="Audiodetection">
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
</Button>
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
<Button
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
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>
|
||||||
@@ -1,78 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<RelativeLayout
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:paddingBottom="16dp"
|
|
||||||
android:paddingLeft="16dp"
|
|
||||||
android:paddingRight="16dp"
|
|
||||||
android:paddingTop="16dp"
|
|
||||||
tools:activity="com.example.greenwatch">
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="max. Amp: "
|
|
||||||
android:id="@+id/labelMaxAmp"
|
|
||||||
android:layout_alignParentTop="true"
|
|
||||||
android:layout_alignParentStart="true"/>
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:id="@+id/textViewMaxAmp"
|
|
||||||
android:text=" "
|
|
||||||
android:layout_alignBaseline="@+id/labelMaxAmp"
|
|
||||||
android:layout_toEndOf="@+id/labelMaxAmpdb"/>
|
|
||||||
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="max. Amp in dB: "
|
|
||||||
android:id="@+id/labelMaxAmpdb"
|
|
||||||
android:layout_below="@+id/labelMaxAmp"
|
|
||||||
android:layout_alignParentStart="true"/>
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:id="@+id/textViewMaxAmpdb"
|
|
||||||
android:text=" "
|
|
||||||
android:layout_alignBaseline="@+id/labelMaxAmpdb"
|
|
||||||
android:layout_toEndOf="@+id/labelMaxAmpdb"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="Meldung: "
|
|
||||||
android:id="@+id/labelZeitstempel"
|
|
||||||
android:layout_below="@+id/labelMaxAmpdb"
|
|
||||||
android:layout_alignParentStart="true"/>
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:id="@+id/textViewZeitstempel"
|
|
||||||
android:text=" "
|
|
||||||
android:layout_alignBaseline="@+id/labelZeitstempel"
|
|
||||||
android:layout_toEndOf="@+id/labelMaxAmpdb"/>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<ScrollView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:id="@+id/scrollView3"
|
|
||||||
android:layout_below="@+id/labelMaxAmpdb"
|
|
||||||
android:layout_alignParentStart="true">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:id="@+id/textViewLogger"/>
|
|
||||||
</ScrollView>
|
|
||||||
|
|
||||||
</RelativeLayout>
|
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<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=".VideodetectionActivity">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvVideodetectionStatusmessage"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Videodetection Activity">
|
||||||
|
</TextView>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/videodetectorBackToMainActivity"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Back to MainActivity">
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<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=".VideodetectionAndAccelerometerActivity">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvVideodetectionAndAccelerometerStatusmessage"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Videodetection + Accelerometer Activity">
|
||||||
|
</TextView>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/videodetectionAndAccelerometerBackToMainActivity"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Back to MainActivity">
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
Reference in new issue
Block a user