Compare commits

..
Author SHA1 Message Date
bauseweinfr74630 144b8eb676 Kapselung in Funktionen; 2023-06-20 16:23:42 +02:00
proelssju74689 d3d7def833 Mikrofon Activity Ausbesserung Kalibrierung;
Speicherung der dB-Werte nur, wenn positiv + Kommentare zum Verständnis der zu speichernden Variablen
2023-06-12 13:28:45 +02:00
proelssju74689 c61e56c3b5 Mikrofon Activity kalibrierung_do initialisiert 2023-06-07 15:17:28 +02:00
proelssju74689 f2b85fb4e7 Mikrofon Activity commit im Nachhinein 2023-06-07 13:48:36 +02:00
proelssju74689 32decab687 Mikrofon XML commit im Nachhinein 2023-06-07 13:47:56 +02:00
proelssju74689 f98a3580a6 Mikrofon Manifest angepasst - App läuft 2023-06-07 13:46:53 +02:00
proelssju74689 5b920359a1 Mikrofon als Activity 2023-06-07 13:39:57 +02:00
33 changed files with 444 additions and 1992 deletions
+1 -19
View File
@@ -2,13 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.greenwatch">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.CAMERA" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
@@ -17,19 +11,7 @@
android:supportsRtl="true"
android:theme="@style/Theme.GreenWatch">
<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:name=".Mikrofon"
android:exported="false" />
<activity
android:name=".MainActivity"
@@ -1,147 +0,0 @@
package com.example.greenwatch;
import androidx.appcompat.app.AppCompatActivity;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
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.adapters.AlarmHistoryListAdapter;
import com.example.greenwatch.adapters.DeviceListAdapter;
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);
RecyclerView recyclerView = findViewById(R.id.deviceListRecyclerView);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setHasFixedSize(true);
final DeviceListAdapter deviceListAdapter = new DeviceListAdapter();
recyclerView.setAdapter(deviceListAdapter);
RecyclerView alarmHistoryListRecyclerView = findViewById(R.id.alarmHistoryListRecyclerView);
alarmHistoryListRecyclerView.setLayoutManager(new LinearLayoutManager(this));
alarmHistoryListRecyclerView.setHasFixedSize(true);
final AlarmHistoryListAdapter alarmHistoryListAdapter = new AlarmHistoryListAdapter();
alarmHistoryListRecyclerView.setAdapter(alarmHistoryListAdapter);
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) {
deviceListAdapter.setDevices(devices);
Toast.makeText(AccelerometerActivity.this, "onChanged", Toast.LENGTH_LONG).show();
}
});
mAccelerometerViewModel.getAlarmHistoryList().observe(this, new Observer<List<Device>>() {
@Override
public void onChanged(List<Device> devices) {
alarmHistoryListAdapter.setAlarmHistoryList(devices);
}
});
mAccelerometerViewModel.getMovementDetectedValue().observe(this, new Observer<Boolean>() {
@Override
public void onChanged(Boolean aBoolean) {
if (aBoolean) {
mAccelerometerViewModel.updateDevice(mAccelerometerViewModel.getLocalDeviceUUID(), mAccelerometerViewModel.getSystemTimeStamp(), true, "Accelerometer", 10);
}
else {
mAccelerometerViewModel.updateDevice(mAccelerometerViewModel.getLocalDeviceUUID(), mAccelerometerViewModel.getSystemTimeStamp(), 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);
}
}
}
@@ -1,27 +0,0 @@
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();
}
});
}
}
@@ -1,27 +0,0 @@
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,23 @@
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,147 +1,25 @@
package com.example.greenwatch;
import androidx.appcompat.app.AppCompatActivity;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import com.example.greenwatch.adapters.AlarmHistoryListAdapter;
import com.example.greenwatch.adapters.DeviceListAdapter;
import com.example.greenwatch.models.Device;
import com.example.greenwatch.viewmodels.MainActivityViewModel;
import java.util.List;
public class MainActivity extends AppCompatActivity {
private Button audiodetectionButton;
private Button videodetectionButton;
private Button accelerometerButton;
private Button audiodetectionAndAccelerometerButton;
private Button videodetectionAndAccelerometerButton;
private Button connectionButton;
private MainActivityViewModel mMainActivityViewModel;
@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);
RecyclerView deviceListRecyclerView = findViewById(R.id.deviceListRecyclerView);
deviceListRecyclerView.setLayoutManager(new LinearLayoutManager(this));
deviceListRecyclerView.setHasFixedSize(true);
final DeviceListAdapter deviceListAdapter = new DeviceListAdapter();
deviceListRecyclerView.setAdapter(deviceListAdapter);
RecyclerView alarmHistoryListRecyclerView = findViewById(R.id.alarmHistoryListRecyclerView);
alarmHistoryListRecyclerView.setLayoutManager(new LinearLayoutManager(this));
alarmHistoryListRecyclerView.setHasFixedSize(true);
final AlarmHistoryListAdapter alarmHistoryListAdapter = new AlarmHistoryListAdapter();
alarmHistoryListRecyclerView.setAdapter(alarmHistoryListAdapter);
mMainActivityViewModel = new ViewModelProvider(this).get(MainActivityViewModel.class);
mMainActivityViewModel.init();
mMainActivityViewModel.getConnectedDeviceList().observe(this, new Observer<List<Device>>() {
((Button)findViewById(R.id.buttonstartmicdetection)).setOnClickListener(new View.OnClickListener(){
@Override
public void onChanged(List<Device> devices) {
deviceListAdapter.setDevices(devices);
Toast.makeText(MainActivity.this, "onChanged", Toast.LENGTH_LONG).show();
}
});
mMainActivityViewModel.getAlarmHistoryList().observe(this, new Observer<List<Device>>() {
@Override
public void onChanged(List<Device> devices) {
alarmHistoryListAdapter.setAlarmHistoryList(devices);
}
});
audiodetectionButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//openAudiodetectionActivity();
mMainActivityViewModel.updateDevice(mMainActivityViewModel.getLocalDeviceUUID(), "10:51", 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(), "12345");
}
});
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 onClick(View view) {
Intent i = new Intent(MainActivity.this, Mikrofon.class);
startActivity(i);
}
});
}
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);
mMainActivityViewModel.updateDevice(mMainActivityViewModel.getLocalDeviceUUID(), "24:00", false, "Video", 0);
}
public void openConnectionActivity(){
//Intent intent = new Intent(this, ConnectionActivity.class);
//startActivity(intent);
mMainActivityViewModel.updateDevice(mMainActivityViewModel.getLocalDeviceUUID(), "10:51", true, "Audio", 10);
}
}
@@ -1,4 +1,254 @@
package com.example.greenwatch;
public class Mikrofon {
import androidx.appcompat.app.AppCompatActivity;
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);
}
}
/////////////////////////////////////////////
}
@@ -0,0 +1,63 @@
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;
}*/
}
@@ -0,0 +1,13 @@
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;
}
}
@@ -1,27 +0,0 @@
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();
}
});
}
}
@@ -1,27 +0,0 @@
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();
}
});
}
}
@@ -1,62 +0,0 @@
package com.example.greenwatch.adapters;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.example.greenwatch.R;
import com.example.greenwatch.models.Device;
import java.util.ArrayList;
import java.util.List;
public class AlarmHistoryListAdapter extends RecyclerView.Adapter<AlarmHistoryListAdapter.AlarmHistoryListHolder> {
private List<Device> alarmHistoryList = new ArrayList<>();
@NonNull
@Override
public AlarmHistoryListHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.alarm_history_item, parent, false);
return new AlarmHistoryListHolder(itemView);
}
@Override
public void onBindViewHolder(@NonNull AlarmHistoryListHolder holder, int position) {
Device currentDevice = alarmHistoryList.get(position);
holder.textViewSensorType.setText(holder.itemView.getContext().getString(R.string.sensor_type_placeholder, currentDevice.getSensorType()));
holder.textViewDeviceID.setText(holder.itemView.getContext().getString(R.string.deviceID_placeholder, currentDevice.getDeviceID()));
holder.textViewTimeStamp.setText(holder.itemView.getContext().getString(R.string.sensor_time_stamp_placeholder, currentDevice.getTimeStamp()));
holder.textViewSensorMessage.setText(holder.itemView.getContext().getString(R.string.sensor_message_placeholder, currentDevice.getSensorMassage()));
}
@Override
public int getItemCount() {
return alarmHistoryList.size();
}
public void setAlarmHistoryList(List<Device> alarmHistoryList) {
this.alarmHistoryList = alarmHistoryList;
notifyDataSetChanged();
}
class AlarmHistoryListHolder extends RecyclerView.ViewHolder {
private TextView textViewSensorType;
private TextView textViewDeviceID;
private TextView textViewTimeStamp;
private TextView textViewSensorMessage;
public AlarmHistoryListHolder(View itemView) {
super(itemView);
textViewSensorType = (TextView) itemView.findViewById(R.id.tvAlarmHistoryDeviceSensorType);
textViewDeviceID = (TextView) itemView.findViewById(R.id.tvAlarmHistoryDeviceID);
textViewTimeStamp = (TextView) itemView.findViewById(R.id.tvAlarmHistoryDeviceTimeStamp);
textViewSensorMessage = (TextView) itemView.findViewById(R.id.tvAlarmHistoryDeviceSensorMassage);
}
}
}
@@ -1,92 +0,0 @@
package com.example.greenwatch.adapters;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.example.greenwatch.R;
import com.example.greenwatch.models.Device;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
public class DeviceListAdapter extends RecyclerView.Adapter<DeviceListAdapter.DeviceListHolder> {
private List<Device> devices = new ArrayList<>();
@NonNull
@Override
public DeviceListHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.device_item, parent, false);
return new DeviceListHolder(itemView);
}
@Override
public void onBindViewHolder(@NonNull DeviceListHolder holder, int position) {
Device currentDevice = devices.get(position);
holder.textViewSensorType.setText(holder.itemView.getContext().getString(R.string.sensor_type_placeholder, currentDevice.getSensorType()));
holder.textViewDeviceID.setText(holder.itemView.getContext().getString(R.string.deviceID_placeholder, currentDevice.getDeviceID()));
holder.textViewTimeStamp.setText(holder.itemView.getContext().getString(R.string.sensor_time_stamp_placeholder, currentDevice.getTimeStamp()));
holder.textViewSensorMessage.setText(holder.itemView.getContext().getString(R.string.sensor_message_placeholder, currentDevice.getSensorMassage()));
holder.setDeviceSensorStatus(currentDevice);
}
@Override
public int getItemCount() {
return devices.size();
}
public void setDevices(List<Device> devices) {
this.devices = devices;
Collections.sort(this.devices, new Comparator<Device>() {
@Override
public int compare(Device device1, Device device2) {
if (device1.getSensorStatus() && !device2.getSensorStatus()) {
return -1;
} else if (!device1.getSensorStatus() && device2.getSensorStatus()) {
return 1;
} else {
return 0;
}
}
});
notifyDataSetChanged();
}
class DeviceListHolder extends RecyclerView.ViewHolder {
private TextView textViewSensorType;
private TextView textViewSensorStatus;
private TextView textViewDeviceID;
private TextView textViewTimeStamp;
private TextView textViewSensorMessage;
public DeviceListHolder(View itemView) {
super(itemView);
textViewSensorType = (TextView) itemView.findViewById(R.id.tvDeviceSensorType);
textViewSensorStatus = (TextView) itemView.findViewById(R.id.tvDeviceSensorStatus);
textViewDeviceID = (TextView) itemView.findViewById(R.id.tvDeviceID);
textViewTimeStamp = (TextView) itemView.findViewById(R.id.tvDeviceTimeStamp);
textViewSensorMessage = (TextView) itemView.findViewById(R.id.tvDeviceSensorMassage);
}
public void setDeviceSensorStatus(Device device) {
if (device.getSensorStatus()) {
textViewSensorStatus.setText(itemView.getContext().getString(R.string.sensor_status_placeholder, "AN"));
itemView.setBackgroundColor(Color.RED);
}
else {
textViewSensorStatus.setText(itemView.getContext().getString(R.string.sensor_status_placeholder, "AUS"));
itemView.setBackgroundColor(Color.WHITE);
}
}
}
}
@@ -1,246 +0,0 @@
package com.example.greenwatch.alarmrecorder;
import android.media.MediaCodec;
import android.media.MediaExtractor;
import android.media.MediaFormat;
import android.media.MediaMuxer;
import android.media.MediaRecorder;
import android.os.Environment;
import android.widget.Toast;
import com.example.greenwatch.MainActivity;
import com.example.greenwatch.alarmrecorder.runnables.AudioRecorder;
import com.example.greenwatch.alarmrecorder.runnables.VideoRecorder;
import java.io.File;
import java.io.IOException;
import java.nio.ByteBuffer;
public class AlarmRecorder {
private boolean isRecording;
private String videoPath;
private String audioPath;
private MediaFormat videoFormat;
private MediaFormat audioFormat;
private MediaExtractor videoExtractor;
private MediaExtractor audioExtractor;
private Runnable audioRecorderRunnable;
private Runnable videoRecorderRunnable;
private MediaRecorder videoRecorder;
private MediaRecorder audioRecorder;
private Thread videoThread; // Video-Thread als Instanzvariable
private Thread audioThread; // Audio-Thread als Instanzvariable
public AlarmRecorder() {
audioRecorder = new MediaRecorder();
videoRecorder = new MediaRecorder();
videoExtractor = new MediaExtractor();
audioExtractor = new MediaExtractor();
}
private void startRecording() {
createStoragePaths(); //Speicherort und -namen für Audio- und Video-Datei
audioRecorderRunnable = new AudioRecorder(audioRecorder, audioPath);
videoRecorderRunnable = new VideoRecorder(videoRecorder, videoPath);
audioThread = new Thread(audioRecorderRunnable);
videoThread = new Thread(videoRecorderRunnable);
//Threads starten
videoThread.start();
audioThread.start();
}
private void stopRecording() {
isRecording = false;
try {
stopVideoRecording();
stopAudioRecording();
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(MainActivity.this, "Video- und Audioaufzeichnung beendet", Toast.LENGTH_SHORT).show();
}
});
waitTillThreadsStopped();
File videoFile = new File(videoPath); //Speichere das aufgenommene Video
File audioFile = new File(audioPath); //Speichere die aufgenommene Audio
if (videoFile.exists() && audioFile.exists()) {
//Wenn Video- und Audioaufzeichnung gestoppt und abgespeichert sind, beginne mit dem Mergeprozess der beiden
mergeVideoWithAudio();
} else {
Toast.makeText(MainActivity.this, "Dateien wurden nicht gefunden!", Toast.LENGTH_SHORT).show();
}
} catch (RuntimeException stopException) {
stopException.printStackTrace();
}
}
private void createStoragePaths(){
//Pfade zum Zwischenspeichern der aufgenommenen Audio und Video-Datei
isRecording = true;
String externalStorageDirectory = Environment.getExternalStorageDirectory().getAbsolutePath();
String dcimDirectory = externalStorageDirectory + "/DCIM";
videoPath = dcimDirectory + "/video.mp4";
audioPath = dcimDirectory + "/audio.mp3";
}
private void stopVideoRecording(){
if (videoRecorder != null) {
videoRecorder.stop();
videoRecorder.release();
videoRecorder = null;
}
}
private void stopAudioRecording(){
if (audioRecorder != null) {
audioRecorder.stop();
audioRecorder.release();
audioRecorder = null;
}
}
private void waitTillThreadsStopped(){
try {
videoThread.join();
audioThread.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
private void mergeVideoWithAudio() {
try {
setVideoExtractorDataSource(); //extrahieren der Video Datei, die zuvor zwischengespeichert wurde
setAudioExtractorDataSource(); //extrahieren der Audio Datei, die zuvor zwischengespeichert wurde
//Speicherort der später zusammengeführten Datei
String outputFilePath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES).getAbsolutePath() + "/merged_video.mp4";
//MediaMuxer zum Zusammenführen einer Audio- und einer Videodatei
MediaMuxer muxer = new MediaMuxer(outputFilePath, MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4);
int videoTrack = muxer.addTrack(videoFormat);
int audioTrack = muxer.addTrack(audioFormat);
muxer.start();
ByteBuffer buffer = ByteBuffer.allocate(1024 * 1024);
MediaCodec.BufferInfo bufferInfo = new MediaCodec.BufferInfo();
videoExtraction(buffer, videoTrack, bufferInfo, muxer);
audioExtraction(buffer, audioTrack, bufferInfo, muxer);
muxer.stop();
muxer.release();
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(MainActivity.this, "Video und Audio erfolgreich zusammengeführt", Toast.LENGTH_SHORT).show();
}
});
// Löschen der separaten Video- und Audio-Dateien
deleteVideoFile();
deleteAudioFile();
} catch (IOException e) {
e.printStackTrace();
}
}
private void setVideoExtractorDataSource() {
try {
videoExtractor.setDataSource(videoPath);
int videoTrackIndex = getTrackIndex(videoExtractor, "video/");
if (videoTrackIndex < 0) {
// Video-Track nicht gefunden
return;
}
videoExtractor.selectTrack(videoTrackIndex);
videoFormat = videoExtractor.getTrackFormat(videoTrackIndex);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
private void setAudioExtractorDataSource() {
try {
audioExtractor.setDataSource(audioPath);
int audioTrackIndex = getTrackIndex(audioExtractor, "audio/");
if (audioTrackIndex < 0) {
// Audio-Track nicht gefunden
return;
}
audioExtractor.selectTrack(audioTrackIndex);
audioFormat = audioExtractor.getTrackFormat(audioTrackIndex);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
private int getTrackIndex(MediaExtractor extractor, String mimeType) {
int trackCount = extractor.getTrackCount();
for (int i = 0; i < trackCount; i++) {
MediaFormat format = extractor.getTrackFormat(i);
String trackMimeType = format.getString(MediaFormat.KEY_MIME);
if (trackMimeType.startsWith(mimeType)) {
return i;
}
}
return -1;
}
private void videoExtraction(ByteBuffer buffer, int videoTrack, MediaCodec.BufferInfo bufferInfo, MediaMuxer muxer) {
videoExtractor.seekTo(0, MediaExtractor.SEEK_TO_CLOSEST_SYNC);
while (true) {
int sampleSize = videoExtractor.readSampleData(buffer, 0);
if (sampleSize < 0) {
break;
}
long presentationTimeUs = videoExtractor.getSampleTime();
bufferInfo.offset = 0;
bufferInfo.size = sampleSize;
bufferInfo.flags = MediaCodec.BUFFER_FLAG_KEY_FRAME;
bufferInfo.presentationTimeUs = presentationTimeUs;
muxer.writeSampleData(videoTrack, buffer, bufferInfo);
videoExtractor.advance();
}
}
private void audioExtraction(ByteBuffer buffer, int audioTrack, MediaCodec.BufferInfo bufferInfo, MediaMuxer muxer) {
audioExtractor.seekTo(0, MediaExtractor.SEEK_TO_CLOSEST_SYNC);
while (true) {
int sampleSize = audioExtractor.readSampleData(buffer, 0);
if (sampleSize < 0) {
break;
}
long presentationTimeUs = audioExtractor.getSampleTime();
bufferInfo.offset = 0;
bufferInfo.size = sampleSize;
bufferInfo.flags = 0; // or MediaCodec.BUFFER_FLAG_KEY_FRAME
bufferInfo.presentationTimeUs = presentationTimeUs;
muxer.writeSampleData(audioTrack, buffer, bufferInfo);
audioExtractor.advance();
}
}
private void deleteVideoFile(){
File videoFile = new File(videoPath);
if (videoFile.exists()) {
videoFile.delete();
}
}
private void deleteAudioFile(){
File audioFile = new File(audioPath);
if (audioFile.exists()) {
audioFile.delete();
}
}
}
@@ -1,33 +0,0 @@
package com.example.greenwatch.alarmrecorder.runnables;
import android.media.MediaRecorder;
import android.widget.Toast;
import com.example.greenwatch.MainActivity;
import java.io.IOException;
public class AudioRecorder implements Runnable {
private final MediaRecorder audioRecorder;
private final String audioPath;
public AudioRecorder(MediaRecorder audioRecorder, String audioPath) {
this.audioRecorder = audioRecorder;
this.audioPath = audioPath;
}
@Override
public void run() {
audioRecorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
audioRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
audioRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
audioRecorder.setOutputFile(audioPath);
try {
audioRecorder.prepare();
audioRecorder.start();
} catch (IOException e) {
e.printStackTrace();
}
}
}
@@ -1,35 +0,0 @@
package com.example.greenwatch.alarmrecorder.runnables;
import android.media.MediaRecorder;
import com.example.greenwatch.viewmodels.ViewModelInterface;
import java.io.IOException;
public class VideoRecorder implements Runnable{
private final MediaRecorder videoRecorder;
private final String videoPath;
public VideoRecorder(MediaRecorder videoRecorder, String videoPath) {
this.videoRecorder = videoRecorder;
this.videoPath = videoPath;
}
@Override
public void run() {
videoRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
videoRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
videoRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.DEFAULT);
videoRecorder.setOutputFile(videoPath);
videoRecorder.setOrientationHint(90);
//todo find solution for videoView
videoRecorder.setPreviewDisplay(videoView.getHolder().getSurface());
try {
videoRecorder.prepare();
videoRecorder.start();
} catch (IOException e) {
e.printStackTrace();
}
}
}
@@ -1,133 +0,0 @@
package com.example.greenwatch.communication;
import com.example.greenwatch.repositories.DeviceRepository;
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.net.UnknownHostException;
import java.util.Enumeration;
public class WiFiCommunication {
private final InetAddress address;
private final DatagramSocket socket;
private final int port;
private String rxString;
private String sendMessage;
//private String sendMsg = "default";
private boolean isNewMessage;
volatile private boolean running;
private static WiFiCommunication wifiCommunicationInstance;
private DeviceRepository mDeviceRepository;
private WiFiCommunication() {
port = 1234;
try {
socket = new DatagramSocket(port);
socket.setBroadcast(true);
address = InetAddress.getByName("255.255.255.255");
running = true;
isNewMessage = false;
new ReceiveThread().start();
new SendThread().start();
} catch (SocketException | UnknownHostException e) {
throw new RuntimeException(e);
}
}
public static synchronized WiFiCommunication getInstance() {
if (wifiCommunicationInstance == null){
wifiCommunicationInstance = new WiFiCommunication();
}
return wifiCommunicationInstance;
}
public void setDeviceRepository(DeviceRepository deviceRepository) {
this.mDeviceRepository = deviceRepository;
}
public void setNewMessage(String newMessage, boolean isNewMessage){
this.sendMessage = newMessage;
this.isNewMessage = isNewMessage;
}
public static String getLocalIpAddress() {
try {
for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) {
NetworkInterface networkInterface = (NetworkInterface) ((Enumeration<?>) en).nextElement();
for (Enumeration<InetAddress> addresses = networkInterface.getInetAddresses(); addresses.hasMoreElements();) {
InetAddress inetAddress = addresses.nextElement();
if (!inetAddress.isLoopbackAddress() && inetAddress instanceof Inet4Address) {
return inetAddress.getHostAddress();
}
}
}
} catch (SocketException ex) {
ex.printStackTrace();
}
return null;
}
public void stopCommunication() {
running = false;
socket.close();
}
private class SendThread extends Thread {
private int tmpCnt = 0;
@Override
public void run() {
try {
do {
if(isNewMessage)
{
isNewMessage = false;
//todo: adapt send String
String txString = getLocalIpAddress() + " sends. #" + tmpCnt++ + sendMessage;
byte[] txBuffer = txString.getBytes();
DatagramPacket txPacket = new DatagramPacket(txBuffer, txBuffer.length, address, port);
for(int i = 0; i < 20; i++) {
socket.send(txPacket);
}
}
} while (running);
} catch (IOException e) {
e.printStackTrace();
}
}
}
private class ReceiveThread extends Thread {
private String rxString = "";
private String previousRxString = "";
@Override
public void run() {
try {
do {
byte[] rxBuffer = new byte[1024];
DatagramPacket packet = new DatagramPacket(rxBuffer, rxBuffer.length);
socket.receive(packet);
rxString = new String(packet.getData(), 0, packet.getLength());
if(!previousRxString.equals(rxString)){
mDeviceRepository.getNewReceivedMessage(rxString);
}
previousRxString = rxString;
} while (running);
}
catch (IOException e) {
e.printStackTrace();
}
}
}
}
@@ -1,57 +0,0 @@
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;
}
}
@@ -1,286 +0,0 @@
package com.example.greenwatch.repositories;
import androidx.lifecycle.MutableLiveData;
import com.example.greenwatch.models.Device;
import com.example.greenwatch.communication.WiFiCommunication;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
public class DeviceRepository {
private final int maxAlarmHistoryListSize = 20;
private final String delimiter = ", ";
private final String SensorStatusKey = "An";
private String localDeviceUUID;
private static DeviceRepository deviceRepositoryInstance;
private WiFiCommunication mWiFiCommunication;
private MutableLiveData<List<Device>> deviceList = new MutableLiveData<>();
private MutableLiveData<List<Device>> alarmHistoryList = new MutableLiveData<>();
private HashMap<String, Device> connectedDevicesList = new HashMap<>();
private HashMap<String, String> deviceIDMapper = new HashMap<>();
private List<Device> alarmHistoryDeviceList = new ArrayList<>();
private DeviceRepository() {
setLocalDeviceUUID();
}
public static synchronized DeviceRepository getInstance() {
if (deviceRepositoryInstance == null){
deviceRepositoryInstance = new DeviceRepository();
}
return deviceRepositoryInstance;
}
public void setWiFiCommunication(WiFiCommunication wiFiCommunication) {
this.mWiFiCommunication = wiFiCommunication;
}
public MutableLiveData<List<Device>> getConnectedDeviceList() {
setMutableLiveDataDeviceList();
return deviceList;
}
public MutableLiveData<List<Device>> getAlarmHistoryDeviceList() {
setMutableLiveDataAlarmHistoryList();
return alarmHistoryList;
}
public void createNewDevice(String timeStamp, String deviceID, boolean sensorStatus, String sensorType, int sensorMassage){
Device newDevice = new Device(timeStamp, deviceID, sensorStatus, sensorType, sensorMassage);
if (sensorStatus) {
setAlarmHistoryDeviceList(newDevice);
}
addToConnectedDeviceList(newDevice.getDeviceID(), newDevice);
setMutableLiveDataDeviceList();
}
public void getNewReceivedMessage(String newMessage) {
String[] messageString = messageStringSplitter(newMessage);
String timeStamp = messageString[0];
String deviceID = messageString[1];
boolean sensorStatus = convertSensorStatus(messageString[2]);
String sensorType = messageString[3];
int sensorMassage = Integer.valueOf(messageString[4]);
if (deviceID.equals(checkDeviceID(localDeviceUUID))) {
return;
}
if(!connectedDevicesList.containsKey(deviceID)) {
createNewDevice(timeStamp, deviceID, sensorStatus, sensorType, sensorMassage);
}
else {
updateDevice(deviceID, timeStamp, sensorStatus, sensorType, sensorMassage);
}
}
private 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());
}
else {
message.append("")
.append(delimiter)
.append("")
.append(delimiter)
.append("")
.append(delimiter)
.append("")
.append(delimiter)
.append("");
}
return message.toString();
}
public String getLocalDeviceUUID() {
return localDeviceUUID;
}
public void updateDevice(String deviceID, String timeStamp, boolean sensorStatus, String sensorType, int sensorMassage) {
String checkedDeviceID = checkDeviceID(deviceID);
Device device = connectedDevicesList.get(checkedDeviceID);
if(device != null) {
device.setTimeStamp(timeStamp);
device.setSensorType(sensorType);
device.setSensorMassage(sensorMassage);
if (!device.getSensorStatus() && sensorStatus) {
setAlarmHistoryDeviceList(device);
}
device.setSensorStatus(sensorStatus);
addToConnectedDeviceList(checkedDeviceID, device);
setMutableLiveDataDeviceList();
}
}
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);
setMutableLiveDataDeviceList();
}
}
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);
setMutableLiveDataDeviceList();
}
}
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) {
if (!device.getSensorStatus() && sensorStatus) {
setAlarmHistoryDeviceList(device);
}
device.setSensorStatus(sensorStatus);
addToConnectedDeviceList(checkedDeviceID, device);
setMutableLiveDataDeviceList();
}
}
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);
setMutableLiveDataDeviceList();
}
}
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);
setMutableLiveDataDeviceList();
}
}
public int getSensorMassage(String deviceID) {
String checkedDeviceID = checkDeviceID(deviceID);
Device device = connectedDevicesList.get(checkedDeviceID);
if(device != null) {
return device.getSensorMassage();
}
return 0;
}
public String getSystemTimeStamp() {
SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
Date date = new Date(System.currentTimeMillis());
return formatter.format(date);
}
private void setMutableLiveDataDeviceList() {
List<Device> list = new ArrayList<>(connectedDevicesList.values());
deviceList.setValue(list);
}
private void setMutableLiveDataAlarmHistoryList() {
alarmHistoryList.setValue(alarmHistoryDeviceList);
}
private void addToConnectedDeviceList(String key, Device device) {
connectedDevicesList.put(key, device);
if (key.equals(checkDeviceID(localDeviceUUID))) {
mWiFiCommunication.setNewMessage(messageStringBuilder(device.getDeviceID()),true);
}
}
private String checkDeviceID(String deviceID) {
if(!deviceIDMapper.isEmpty() && deviceID.equals(localDeviceUUID)) {
return deviceIDMapper.get(deviceID);
}
return deviceID;
}
private void setDeviceIDMapper(String deviceID) {
deviceIDMapper.put(localDeviceUUID, deviceID);
}
private void setLocalDeviceUUID(){
this.localDeviceUUID = UUID.randomUUID().toString();
}
private String[] messageStringSplitter(String message) {
return message.split(delimiter);
}
private boolean convertSensorStatus(String status) {
return status.equals(SensorStatusKey);
}
private void setAlarmHistoryDeviceList(Device device) {
if (alarmHistoryDeviceList.size() == maxAlarmHistoryListSize) {
alarmHistoryDeviceList.remove(alarmHistoryDeviceList.size() -1);
}
Device alarmHistoryDevice = new Device(device.getTimeStamp(), device.getDeviceID(), device.getSensorStatus(), device.getSensorType(), device.getSensorMassage());
alarmHistoryDeviceList.add(0, alarmHistoryDevice);
setMutableLiveDataAlarmHistoryList();
}
}
@@ -1,162 +0,0 @@
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 implements ViewModelInterface {
private MutableLiveData<List<Device>> mDeviceList;
private MutableLiveData<Boolean> mMovementDetected = new MutableLiveData<>();
private MutableLiveData<List<Device>> mAlarmHistoryList;
private DeviceRepository mDeviceRepository;
private ArrayList<Float> Gesamt_be;
int arraySize = 500;
int functionCallCount;
float meanValue;
float offsetValue;
float thresholdValue;
boolean startMeasuring;
@Override
public void init() {
if (mDeviceList == null) {
mDeviceRepository = DeviceRepository.getInstance();
mDeviceList = mDeviceRepository.getConnectedDeviceList();
mAlarmHistoryList = mDeviceRepository.getAlarmHistoryDeviceList();
}
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() {
return mDeviceRepository.getSystemTimeStamp();
}
public LiveData<Boolean> getMovementDetectedValue() {
return mMovementDetected;
}
@Override
public LiveData<List<Device>> getConnectedDeviceList() {
return mDeviceList;
}
@Override
public LiveData<List<Device>> getAlarmHistoryList() {
return mAlarmHistoryList;
}
@Override
public void updateDevice(String deviceID, String timeStamp, boolean sensorStatus, String sensorType, int sensorMassage) {
mDeviceRepository.updateDevice(deviceID, timeStamp, sensorStatus, sensorType, sensorMassage);
}
@Override
public void setTimeStamp(String deviceID, String timeStamp) {
mDeviceRepository.setTimeStamp(deviceID, timeStamp);
}
@Override
public String getTimeStamp(String deviceID) {
return mDeviceRepository.getTimeStamp(deviceID);
}
@Override
public void setDeviceID(String deviceID, String newDeviceID) {
mDeviceRepository.setDeviceID(deviceID, newDeviceID);
}
@Override
public String getDeviceID(String deviceID) {
return mDeviceRepository.getDeviceID(deviceID);
}
@Override
public void setSensorStatus(String deviceID, boolean sensorStatus) {
mDeviceRepository.setSensorStatus(deviceID, sensorStatus);
}
@Override
public boolean getSensorStatus(String deviceID) {
return mDeviceRepository.getSensorStatus(deviceID);
}
@Override
public void setSensorType(String deviceID, String sensorType) {
mDeviceRepository.setSensorType(deviceID, sensorType);
}
@Override
public String getSensorType(String deviceID) {
return mDeviceRepository.getSensorType(deviceID);
}
@Override
public void setSensorMassage(String deviceID, int sensorMessage) {
mDeviceRepository.setSensorMassage(deviceID, sensorMessage);
}
@Override
public int getSensorMassage(String deviceID) {
return mDeviceRepository.getSensorMassage(deviceID);
}
@Override
public String getLocalDeviceUUID() {
return mDeviceRepository.getLocalDeviceUUID();
}
}
@@ -1,105 +0,0 @@
package com.example.greenwatch.viewmodels;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;
import com.example.greenwatch.communication.WiFiCommunication;
import com.example.greenwatch.models.Device;
import com.example.greenwatch.repositories.DeviceRepository;
import java.util.List;
public class MainActivityViewModel extends ViewModel implements ViewModelInterface {
private MutableLiveData<List<Device>> mDeviceList;
private MutableLiveData<List<Device>> mAlarmHistoryList;
private DeviceRepository mDeviceRepository;
@Override
public void init() {
WiFiCommunication mWiFiCommunication;
if(mDeviceList != null) {
return;
}
//todo: check if WiFi instanz can be hold only by the repository
mDeviceRepository = DeviceRepository.getInstance();
mWiFiCommunication = WiFiCommunication.getInstance();
mDeviceRepository.setWiFiCommunication(mWiFiCommunication);
mWiFiCommunication.setDeviceRepository(mDeviceRepository);
mDeviceRepository.createNewDevice(mDeviceRepository.getSystemTimeStamp(), mDeviceRepository.getLocalDeviceUUID(), false, "No Sensor selected", 0);
mDeviceRepository.createNewDevice("00:00", "1234", true, "Test", 21);
mDeviceList = mDeviceRepository.getConnectedDeviceList();
mAlarmHistoryList = mDeviceRepository.getAlarmHistoryDeviceList();
}
@Override
public LiveData<List<Device>> getConnectedDeviceList() {
return mDeviceList;
}
@Override
public LiveData<List<Device>> getAlarmHistoryList() {
return mAlarmHistoryList;
}
@Override
public void updateDevice(String deviceID, String timeStamp, boolean sensorStatus, String sensorType, int sensorMassage) {
mDeviceRepository.updateDevice(deviceID, timeStamp, sensorStatus, sensorType, sensorMassage);
}
@Override
public void setTimeStamp(String deviceID, String timeStamp) {
mDeviceRepository.setTimeStamp(deviceID, timeStamp);
}
@Override
public String getTimeStamp(String deviceID) {
return mDeviceRepository.getTimeStamp(deviceID);
}
@Override
public void setDeviceID(String deviceID, String newDeviceID) {
mDeviceRepository.setDeviceID(deviceID, newDeviceID);
}
@Override
public String getDeviceID(String deviceID) {
return mDeviceRepository.getDeviceID(deviceID);
}
@Override
public void setSensorStatus(String deviceID, boolean sensorStatus) {
mDeviceRepository.setSensorStatus(deviceID, sensorStatus);
}
@Override
public boolean getSensorStatus(String deviceID) {
return mDeviceRepository.getSensorStatus(deviceID);
}
@Override
public void setSensorType(String deviceID, String sensorType) {
mDeviceRepository.setSensorType(deviceID, sensorType);
}
@Override
public String getSensorType(String deviceID) {
return mDeviceRepository.getSensorType(deviceID);
}
@Override
public void setSensorMassage(String deviceID, int sensorMessage) {
mDeviceRepository.setSensorMassage(deviceID, sensorMessage);
}
@Override
public int getSensorMassage(String deviceID) {
return mDeviceRepository.getSensorMassage(deviceID);
}
@Override
public String getLocalDeviceUUID() {
return mDeviceRepository.getLocalDeviceUUID();
}
}
@@ -1,25 +0,0 @@
package com.example.greenwatch.viewmodels;
import androidx.lifecycle.LiveData;
import com.example.greenwatch.models.Device;
import java.util.List;
public interface ViewModelInterface {
void init();
LiveData<List<Device>> getConnectedDeviceList();
LiveData<List<Device>> getAlarmHistoryList();
void updateDevice(String deviceID, String timeStamp, boolean sensorStatus, String sensorType, int sensorMassage);
void setTimeStamp(String deviceID, String timeStamp);
String getTimeStamp(String deviceID);
void setDeviceID(String deviceID, String newDeviceID);
String getDeviceID(String deviceID);
void setSensorStatus(String deviceID, boolean sensorStatus);
boolean getSensorStatus(String deviceID);
void setSensorType(String deviceID, String sensorType);
String getSensorType(String deviceID);
void setSensorMassage(String deviceID, int sensorMessage);
int getSensorMassage(String deviceID);
String getLocalDeviceUUID();
}
@@ -1,62 +0,0 @@
<?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
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/deviceListRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:listitem="@layout/device_item"
android:layout_weight="1">
</androidx.recyclerview.widget.RecyclerView>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/alarmHistoryListRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:listitem="@layout/alarm_history_item"
android:layout_weight="1">
</androidx.recyclerview.widget.RecyclerView>
</LinearLayout>
</LinearLayout>
@@ -1,25 +0,0 @@
<?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>
@@ -1,25 +0,0 @@
<?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>
+11 -76
View File
@@ -1,83 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.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="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp"
tools:context=".MainActivity">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/alarmHistoryListRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="3"
tools:listitem="@layout/alarm_history_item">
</androidx.recyclerview.widget.RecyclerView>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/deviceListRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="3"
tools:listitem="@layout/device_item">
</androidx.recyclerview.widget.RecyclerView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_weight="3">
<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>
<Button
android:id="@+id/buttonstartmicdetection"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Starte Mikrofon Detection"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -0,0 +1,78 @@
<?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>
@@ -1,25 +0,0 @@
<?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>
@@ -1,25 +0,0 @@
<?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>
@@ -1,51 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="8dp">
<TextView
android:id="@+id/tvAlarmHistoryDeviceSensorType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/sensor_type_placeholder"
android:textAppearance="@style/TextAppearance.AppCompat.Large"
android:maxLines="1"
android:layout_alignParentStart="true"
android:ellipsize="end">
</TextView>
<TextView
android:id="@+id/tvAlarmHistoryDeviceID"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/tvAlarmHistoryDeviceSensorType"
android:text="@string/deviceID_placeholder">
</TextView>
<TextView
android:id="@+id/tvAlarmHistoryDeviceTimeStamp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/tvAlarmHistoryDeviceID"
android:text="@string/sensor_time_stamp_placeholder">
</TextView>
<TextView
android:id="@+id/tvAlarmHistoryDeviceSensorMassage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/tvAlarmHistoryDeviceTimeStamp"
android:text="@string/sensor_message_placeholder">
</TextView>
</RelativeLayout>
</androidx.cardview.widget.CardView>
-61
View File
@@ -1,61 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="8dp">
<TextView
android:id="@+id/tvDeviceSensorStatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:text="@string/sensor_status_placeholder"
android:textAppearance="@style/TextAppearance.AppCompat.Large">
</TextView>
<TextView
android:id="@+id/tvDeviceSensorType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/sensor_type_placeholder"
android:textAppearance="@style/TextAppearance.AppCompat.Large"
android:maxLines="1"
android:layout_toStartOf="@id/tvDeviceSensorStatus"
android:layout_alignParentStart="true"
android:ellipsize="end">
</TextView>
<TextView
android:id="@+id/tvDeviceID"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/tvDeviceSensorType"
android:text="@string/deviceID_placeholder">
</TextView>
<TextView
android:id="@+id/tvDeviceTimeStamp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/tvDeviceID"
android:text="@string/sensor_time_stamp_placeholder">
</TextView>
<TextView
android:id="@+id/tvDeviceSensorMassage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/tvDeviceTimeStamp"
android:text="@string/sensor_message_placeholder">
</TextView>
</RelativeLayout>
</androidx.cardview.widget.CardView>
-5
View File
@@ -1,8 +1,3 @@
<resources>
<string name="app_name">GreenWatch</string>
<string name="sensor_type_placeholder">Sensortyp: %s</string>
<string name="sensor_status_placeholder">Sensorstatus: %s</string>
<string name="deviceID_placeholder">Sensor-ID: %s</string>
<string name="sensor_time_stamp_placeholder">Timestamp: %s</string>
<string name="sensor_message_placeholder">Sensormessage: %d</string>
</resources>
Vendored Executable → Regular
View File