Compare commits

..
Author SHA1 Message Date
kleineckeol72024 076db89147 removed Fragment classes from MainActivity
- changed buttons, added fragments
2023-06-21 18:21:52 +02:00
kleineckeol72024 061646a7d6 Merge remote-tracking branch 'origin/master'
# Conflicts:
#	app/src/main/AndroidManifest.xml
#	app/src/main/java/com/example/ueberwachungssystem/MainActivity.java
#	app/src/main/res/layout/activity_main.xml
2023-06-20 23:05:14 +02:00
siebenhaarmi76624 6f78836c4d Merge remote-tracking branch 'origin/master' 2023-06-20 22:34:42 +02:00
siebenhaarmi76624 b667e70fef Kommunikationcopie Version 1.8 UDP Socket 2023-06-20 22:30:30 +02:00
wolzto94552 272daf9fae Adjustment to fit master 2023-06-20 22:25:20 +02:00
wolzto94552 55ae95e661 Merge of MicrophoneDetector 2023-06-20 21:58:09 +02:00
wolzto94552 8e47934beb Merge branch 'tw' into master
# Conflicts:
#	app/build.gradle
#	app/src/main/AndroidManifest.xml
#	app/src/main/java/com/example/ueberwachungssystem/MainActivity.java
#	app/src/main/res/layout/activity_main.xml
#	gradle.properties
2023-06-20 21:42:25 +02:00
wolzto94552 c60a14b6ac Clean project for merge 2023-06-20 21:37:17 +02:00
Leon Market b9c66f7533 Updated detection report constructor in Accelerometer 2023-06-20 21:23:57 +02:00
Leon Market 7e1143880e Merge branch 'lm'
# Conflicts:
#	app/src/main/java/com/example/ueberwachungssystem/Detection/DetectionReport.java
#	app/src/main/java/com/example/ueberwachungssystem/Detection/Detector.java
#	app/src/main/java/com/example/ueberwachungssystem/MainActivity.java
#	app/src/main/res/layout/activity_main.xml
2023-06-20 21:20:04 +02:00
wolzto94552 4381ae78f8 Commit before cleaning project for merge (minor changes) 2023-06-20 21:16:18 +02:00
siebenhaarmi76624 c198292fbf Merge remote-tracking branch 'origin/master' into Kommunikationcopie
# Conflicts:
#	app/src/main/AndroidManifest.xml
#	app/src/main/java/com/example/ueberwachungssystem/MainActivity.java
#	app/src/main/java/com/example/ueberwachungssystem/WifiCommunication.java
#	app/src/main/res/layout/activity_main.xml
2023-06-20 21:13:26 +02:00
Leon Market 81c3542654 Removed unnecessary packages 2023-06-20 21:13:08 +02:00
siebenhaarmi76624 35d52088aa merge Kommunikationcopie Version 1.7 UDP Socket 2023-06-20 21:06:51 +02:00
wolzto94552 81e04e370a Commit before cleaning project for merge 2023-06-20 21:04:33 +02:00
Leon Market d33ab299ab Added reportViolation() 2023-06-20 20:59:18 +02:00
kohlerba68671 f8f1fd23fb Merge branch 'bk_video'
# Conflicts:
#	app/src/main/java/com/example/ueberwachungssystem/MainActivity.java
2023-06-20 15:34:24 +02:00
kohlerba68671 e01e23eccd Refactor 2023-06-20 14:29:10 +02:00
kohlerba68671 a493bafb79 Refactor 2023-06-20 11:16:26 +02:00
kohlerba68671 aed079377f Refactor 2023-06-20 11:07:57 +02:00
kohlerba68671 bff6abbd29 Removed Permission Handling from Video Detector, Added PermissionHandler.java class 2023-06-20 11:00:26 +02:00
kohlerba68671 5d31f0bb46 Adapted Parameters 2023-06-19 15:47:40 +02:00
kohlerba68671 ea0e88ed89 Refactor in DetectorService class 2023-06-19 14:51:04 +02:00
kohlerba68671 7dee124378 Refactor in DetectorService class 2023-06-19 14:41:41 +02:00
kohlerba68671 0ee1446cbc Merge branch 'bk_video_service' into bk_video
# Conflicts:
#	app/src/main/java/com/example/ueberwachungssystem/MainActivity.java
2023-06-19 14:40:06 +02:00
kohlerba68671 bc5227ba4f Refactor of DetectorService 2023-06-19 14:37:49 +02:00
kohlerba68671 4185cb5200 Proper display of Toasts in Audio Recorder 2023-06-19 14:34:07 +02:00
kohlerba68671 0a3600d0d6 Refactor 2023-06-19 14:27:04 +02:00
kohlerba68671 9b2d57ad37 Refactor 2023-06-19 13:35:02 +02:00
kohlerba68671 847e90f5ac Fixed Bug in VideoDetector 2023-06-19 13:17:17 +02:00
kohlerba68671 ab41217f0e Added DetectionService 2023-06-19 13:13:23 +02:00
kohlerba68671 e088b0afa3 Working Recorder and Video Detector 2023-06-18 20:17:19 +02:00
kohlerba68671 493fa8ca83 Fixed Grey Stripes and Rotation Problems 2023-06-18 18:12:03 +02:00
kohlerba68671 6954d38143 Moved OpenCV Helper to its own Java File 2023-06-18 13:43:10 +02:00
Leon Market 8a5d720685 Changed to a (hopefully) working version of the Accelerometer 2023-06-18 13:13:30 +02:00
kohlerba68671 057c7fc139 Added Audio Recorder 2023-06-18 13:03:38 +02:00
kohlerba68671 29c193b716 Removed Preview Use Case, Audio still not working 2023-06-18 10:55:21 +02:00
Leon Market 90aea5b1bc Added LinkedBlockingQueue to collect data, added Thread to evaluate data from queue 2023-06-17 23:58:34 +02:00
kohlerba68671 76442888f7 Working Video Detector + Recorder WIP: Use Case logic 2023-06-17 19:44:08 +02:00
Leon Market 8a357e0d26 Fixed errors after merge with origin:lm 2023-06-17 19:20:32 +02:00
Leon Market 83268c763b Merge remote-tracking branch 'origin/lm' into lm
# Conflicts:
#	app/src/main/java/com/example/ueberwachungssystem/Beschleunigungssensor.java
2023-06-17 19:17:11 +02:00
Leon Market 3d02d8d4c0 Added 2023-06-17 19:16:48 +02:00
Leon Market cafe763c4a Removed unnecessary code parts 2023-06-17 19:14:34 +02:00
Leon Market 2cff334056 Added detection report 2023-06-17 19:00:44 +02:00
kohlerba68671 d32e0a11f5 Fixed bug in Detector and VideoDetector 2023-06-17 11:20:56 +02:00
wolzto94552 b94a1d98b7 Working detection with calibration and dB signals. FFT also implemented, but does not work properly at the moment. (Added Complex class, FFT class and imported jjoe64 Graphview (in gradle and gradle.properties) for visualising FFT results) 2023-06-16 16:49:20 +02:00
kleineckeol72024 746eec18ba removed Fragment classes from MainActivity 2023-06-15 17:19:35 +02:00
kleineckeol72024 44e056b5fe Merge branch 'ko'
# Conflicts:
#	app/src/main/java/com/example/ueberwachungssystem/MainActivity.java
2023-06-15 17:06:56 +02:00
kleineckeol72024 df1fefef5f added Toggle Button to start Cam Detection 2023-06-15 16:59:17 +02:00
siebenhaarmi76624 df9b28c830 merge Kommunikation Version 1.2 UDP Socket 2023-06-15 16:56:59 +02:00
siebenhaarmi76624 6ec0b175e4 merge Kommunikation Version 1.2 UDP Socket 2023-06-15 16:56:21 +02:00
kleineckeol72024 5bcd465ecc Merge branch 'master' into ko
# Conflicts:
#	app/build.gradle
#	app/src/main/AndroidManifest.xml
#	app/src/main/res/layout/activity_main.xml
#	gradle/wrapper/gradle-wrapper.properties
2023-06-15 16:20:40 +02:00
kleineckeol72024 a6fdf3f774 added landscape xml file 2023-06-15 16:12:30 +02:00
kleineckeol72024 b46db4cdfc reworked Button Positions 2023-06-15 16:04:50 +02:00
Leon Market 6c4905d0e7 Added constructors for activity and textView in ThreadDemo 2023-06-15 14:27:25 +02:00
kohlerba68671 fb8bdcd895 Fixed up Video detector 2023-06-15 12:40:54 +02:00
Leon Market 402b73e4bd Removed calibration code and added method checkAlarm 2023-06-14 22:28:05 +02:00
Leon Market 9e5b669986 Added Accelerometer as Runnable Class and ThreadDemo as example 2023-06-14 22:25:54 +02:00
Leon Market 8275d8bd5a Added 2023-06-14 22:11:17 +02:00
kohlerba68671 7ef0df48dd Refactored Detector 2023-06-14 20:14:06 +02:00
kohlerba68671 50b579705e Detector based on OpenCV working 2023-06-14 19:43:18 +02:00
kohlerba68671 8551abfc5d Changde Detector class 2023-06-14 16:38:33 +02:00
kohlerba68671 bbd333426d unfinished changes in Detector 2023-06-13 20:55:30 +02:00
kleineckeol72024 74eb3e0d98 Added Toggle Buttons for Detection Mode
Added Scrollview for alarm
2023-06-12 20:23:42 +02:00
kleineckeol72024 5f7e2a43f2 added new Project ueberwachungssystem 2023-06-12 19:04:22 +02:00
kohlerba68671 e98ae10267 refactor 2023-06-12 19:03:52 +02:00
kleineckeol72024 07f60f974b added new Project ueberwachungssystem 2023-06-12 14:15:39 +02:00
kohlerba68671 7d29ed1ca9 Rebuild to use openCV. Alarm not yet implemented 2023-06-09 20:56:14 +02:00
kohlerba68671 f98079d431 Readded main and main xml 2023-06-09 09:09:50 +02:00
kohlerba68671 11dbcd0362 Merge branch 'bk_video' of siebenhaarmi76624/MDT5_1_Ueberwachungssystem_G1 into master 2023-06-02 15:51:55 +00:00
kohlerba68671 047d45f1cb Added comments to VideoDetector class 2023-06-02 17:48:41 +02:00
kohlerba68671 95919a6602 preparing branch for merge 2023-06-02 14:56:57 +02:00
kohlerba68671 19d1bfe1e3 Refactor 2023-05-29 10:43:51 +02:00
kohlerba68671 e9da712882 Merge remote-tracking branch 'origin/bk_video' into bk_video 2023-05-28 22:30:58 +02:00
kohlerba68671 804c5aba36 Removed old Luminosity detection 2023-05-28 22:30:22 +02:00
kohlerba68671 c5577b125f Changed VideoDetector.java to detect based on changed pixel count instead of average luminosity 2023-05-28 22:30:22 +02:00
kohlerba68671 6100d17bd2 Refactored in Main 2023-05-28 22:30:22 +02:00
kohlerba68671 74a291bdd6 Removed olf Luminosity detection 2023-05-28 22:28:23 +02:00
kohlerba68671 ba6765b1fb Changed VideoDetector.java to detect based on changed pixel count instead of average luminosity 2023-05-28 22:20:56 +02:00
kohlerba68671 9fce3be6a8 Refactored some stuff in Main 2023-05-28 22:19:30 +02:00
kohlerba68671 9892fc35bc Refactor of Detector.java 2023-05-28 22:19:05 +02:00
kohlerba68671 62a528d33b Implemented VideoDetector as a child class of abstract class Detector 2023-05-28 21:16:17 +02:00
wolzto94552 7c8610facb Move from Mikrofon to MicrophoneDetector class and add of abstract Detector class 2023-05-25 16:58:08 +02:00
Leon Market 4999f1b998 added Detector, DetectorReport, Logger 2023-05-25 16:46:12 +02:00
kohlerba68671 37617dbd54 Fixed a bug in Detector.java 2023-05-25 10:54:08 +02:00
kohlerba68671 569bd43163 Adjusted some values in xml and video detector for showcase 2023-05-25 10:20:11 +02:00
kohlerba68671 fdb0036ea6 Added comments to abstract class "Detector" 2023-05-25 10:19:21 +02:00
kohlerba68671 f9797f2dca Added Abstract class Detector 2023-05-24 23:51:49 +02:00
kohlerba68671 ba75c58a23 Refactor 2023-05-24 22:16:54 +02:00
Leon Market 620528302e added Beschleunigungssensor 2023-05-24 20:40:18 +02:00
kohlerba68671 3d799ae461 Rebuild Demo in Main Activity 2023-05-18 15:05:09 +02:00
kohlerba68671 2501662737 Fixed a bug in the video decoder 2023-05-18 12:02:18 +02:00
kohlerba68671 d04d166e14 Added log function to detection report 2023-05-18 12:01:45 +02:00
kohlerba68671 1576719d10 Added onDetectionListener to VideoDecoder 2023-05-16 22:35:50 +02:00
kohlerba68671 362af75b9a Added DetectionReportCalss 2023-05-16 22:34:32 +02:00
kohlerba68671 bef5d03494 Added functions for checking luminosity violation 2023-05-16 19:15:57 +02:00
kohlerba68671 80ebf77eb6 Removed empty Text File 2023-05-16 17:48:33 +02:00
kohlerba68671 c4ed247a05 added Functions to VideoDetector:
startDetection(), stopDetection(), isRunning()
2023-05-16 17:42:10 +02:00
kohlerba68671 323786859e added Video Decoder Class 2023-05-12 18:45:13 +02:00
kohlerba68671 354bf937b2 added camerax libraries to build.gradle 2023-05-12 09:37:58 +02:00
kohlerba68671 39bb37f5c3 removed VideoDetection.java 2023-05-11 21:46:15 +02:00
kohlerba68671 b198dc2e06 small refactor 2023-05-11 21:33:40 +02:00
BepsiKohler d83cd3dc32 Added camera access permission 2023-05-11 20:58:01 +02:00
unknown 90a2aad491 new class Mikrofon 2023-05-11 16:21:59 +02:00
kleineckeol72024 57bf2c2fb7 added new Project ueberwachungssystem 2023-05-11 15:31:47 +02:00
kohlerba68671 065acefeb9 Merge branch 'ms' of siebenhaarmi76624/MDT5_1_Ueberwachungssystem_G1 into master 2023-05-11 13:29:40 +00:00
kleineckeol72024 5c0263198c added new Project ueberwachungssystem 2023-05-11 15:25:28 +02:00
24 changed files with 704 additions and 128 deletions
View File
+3
View File
@@ -0,0 +1,3 @@
Sensor als Service einrichten, der aus Activity heraus gestartet werden kann.
Stichwort: Intent
Siehe Skript Teil 1
+17
View File
@@ -40,4 +40,21 @@ dependencies {
testImplementation 'junit:junit:4.13.2' testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
// OpenCV (from: https://github.com/QuickBirdEng/opencv-android)
def opencv_version = "4.5.3.0"
implementation "com.quickbirdstudios:opencv:${opencv_version}"
implementation "androidx.lifecycle:lifecycle-extensions:2.0.0"
// Required for CameraX
def camerax_version = "1.2.2"
implementation "androidx.camera:camera-core:${camerax_version}"
implementation "androidx.camera:camera-camera2:${camerax_version}"
implementation "androidx.camera:camera-lifecycle:${camerax_version}"
implementation "androidx.camera:camera-video:${camerax_version}"
implementation "androidx.camera:camera-view:${camerax_version}"
implementation "androidx.camera:camera-extensions:${camerax_version}"
} }
+6 -5
View File
@@ -2,11 +2,13 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"> xmlns:tools="http://schemas.android.com/tools">
<uses-feature android:name="android.hardware.camera"/>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" /> <!-- §permissionCamera§ -->
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<application <application
android:allowBackup="true" android:allowBackup="true"
@@ -14,20 +16,19 @@
android:fullBackupContent="@xml/backup_rules" android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:label="@string/app_name" android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/Theme.Ueberwachungssystem" android:theme="@style/Theme.Ueberwachungssystem"
tools:targetApi="31"> tools:targetApi="31">
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:exported="true" android:exported="true">
android:label="Ueberwachungsapp">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>
<service android:name=".Detection.DetectorService"/>
</application> </application>
</manifest> </manifest>
@@ -0,0 +1,53 @@
package com.example.ueberwachungssystem.Fragments;
import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.VideoView;
import androidx.fragment.app.Fragment;
import com.example.ueberwachungssystem.R;
import java.io.File;
public class Fragment1 extends Fragment {
private String text;
private final static String KEY_TEXT = "KEY_TEXT";
private void log(String nachricht) {
Log.d(this.getClass().getSimpleName(), nachricht);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
log("onCreateView");
View view = inflater.inflate(R.layout.fragment1, container, false);
TextView Sensor = (TextView) view.findViewById(R.id.Alarm);
Sensor.setText(text);
return view;
}
public static Fragment1 erstellen(String text) {
Fragment1 fragment = new Fragment1();
Bundle b = new Bundle();
b.putString(KEY_TEXT, text);
fragment.setArguments(b);
return fragment;
}
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
Bundle args = getArguments();
if (args != null ) {
text = args.getString(KEY_TEXT);
log("onCreate: text=" + text);
} else {
log("onCreate");
}
}
}
@@ -0,0 +1,66 @@
package com.example.ueberwachungssystem.Fragments;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import androidx.fragment.app.Fragment;
import com.example.ueberwachungssystem.MeinAdapter;
import com.example.ueberwachungssystem.R;
import java.io.File;
import java.util.Arrays;
import java.util.List;
public class Fragment2 extends Fragment {
private String text;
private Context c;
private final static String KEY_TEXT = "KEY_TEXT" ;
private void log(String nachricht) {
Log.d(this.getClass().getSimpleName(), nachricht);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
log( "onCreateView" );
View view = inflater.inflate(R.layout.fragment2, container, false );
// TextView Sensor = (TextView) view.findViewById(R.id.Aufzeichnungen);
// Sensor.setText(text);
return view;
}
public static Fragment2 erstellen(String text) {
Fragment2 fragment = new Fragment2();
Bundle b = new Bundle();
b.putString(KEY_TEXT, text);
fragment.setArguments(b);
return fragment;
}
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
Bundle args = getArguments();
c = getContext();
ListView listView = new ListView(c);
setContentView(R.layout.fragment2);
listView.setAdapter(new MeinAdapter(c, getVideoFiles()));
if (args != null) {
text = args.getString(KEY_TEXT);
log("onCreate: text=" + text);
} else {
log("onCreate");
}
}
public List<File> getVideoFiles(){
File directory = c.getFilesDir();
File[] files = directory.listFiles();
assert files != null;
return Arrays.asList(files);
}
}
@@ -0,0 +1,46 @@
package com.example.ueberwachungssystem.Fragments;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.fragment.app.Fragment;
import com.example.ueberwachungssystem.R;
public class Fragment3 extends Fragment {
private String text;
private final static String KEY_TEXT = "KEY_TEXT" ;
private void log(String nachricht) {
Log.d(this.getClass().getSimpleName(), nachricht);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
log( "onCreateView" );
View view = inflater.inflate(R.layout.fragment2, container, false );
TextView Sensor = (TextView) view.findViewById(R.id.Sensor);
Sensor.setText(text);
return view;
}
public static Fragment3 erstellen(String text) {
Fragment3 fragment = new Fragment3();
Bundle b = new Bundle();
b.putString(KEY_TEXT, text);
fragment.setArguments(b);
return fragment;
}
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
Bundle args = getArguments();
if (args != null) {
text = args.getString(KEY_TEXT);
log("onCreate: text=" + text);
} else {
log("onCreate");
}
}
}
@@ -0,0 +1,44 @@
package com.example.ueberwachungssystem.Logger;
import android.util.Log;
import android.widget.TextView;
import java.io.PrintWriter;
import java.io.StringWriter;
public class Logger {
private TextView textView;
private StringBuffer sb = new StringBuffer();
private String tag;
public Logger(String tag, TextView textView, String logInitText) {
this.tag = tag;
this.textView = textView;
sb.append(logInitText);
}
public void log(String s) {
Log.d(tag, s);
sb.append(s).append("\n");
if (textView != null) {
textView.setText(sb.toString());
}
}
public void log(Exception e) {
StringWriter sw = new StringWriter();
e.printStackTrace(new PrintWriter(sw));
log(sw.toString());
}
public void clearLog() {
sb.setLength(0);
if (textView != null) {
textView.setText("");
}
}
public String getLoggedText() {
return sb.toString();
}
}
@@ -1,103 +1,126 @@
package com.example.ueberwachungssystem; package com.example.ueberwachungssystem;
import android.annotation.SuppressLint; import androidx.camera.core.ExperimentalGetImage;
import android.net.wifi.WifiInfo; import androidx.fragment.app.Fragment;
import android.net.wifi.WifiManager; import androidx.fragment.app.FragmentTransaction;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle; import android.os.Bundle;
import android.view.Menu; import android.util.Log;
import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.ToggleButton;
import androidx.appcompat.app.AppCompatActivity; import com.example.ueberwachungssystem.Fragments.Fragment1;
import java.net.InetAddress; import com.example.ueberwachungssystem.Fragments.Fragment2;
import java.net.UnknownHostException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
@SuppressLint("SetTextI18n") @ExperimentalGetImage
public class MainActivity extends AppCompatActivity { public class MainActivity extends AppCompatActivity implements View.OnClickListener {
TextView tvMessages; //Fragmente
TextView tvConnectionInfos; private Fragment aktuellesFragment;
private Fragment1 fragment1;
private Fragment2 fragment2;
//Textviews
private TextView Auswahl;
private TextView AoderA;
private String auswahltext = "Wahl des Detektionsmodus";
private String auswahlAoderA = "Wahl von Alarmmeldungen oder Auswahl von Alarmaufzeichnungen";
//Sensoren und Kommunikation
WifiCommunication communication; WifiCommunication communication;
PermissionRequest permission; //Buttons
public static String SERVER_IP = ""; private ToggleButton toggleKamera;
public static final int SERVER_PORT = 1234; private ToggleButton toggleAudio;
//private static final int PERMISSION_REQUEST_CODE = 123; private ToggleButton toggleBewegung;
float i=0;
boolean communicationRunning = false; //Überprüfungswerte
boolean wahr;
private void log(String nachricht) {
Log.d(this.getClass().getSimpleName(), nachricht);
}
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setTitle(this.getClass().getSimpleName());
setContentView(R.layout.activity_main); setContentView(R.layout.activity_main);
tvMessages = findViewById(R.id.tvMessages); Auswahl = findViewById(R.id.textAuswahl);
tvConnectionInfos = findViewById(R.id.tvConnectionInfos); Auswahl.setText(auswahltext);
try { AoderA = findViewById(R.id.textAoderA);
SERVER_IP = getLocalIpAddress(); AoderA.setText(auswahlAoderA);
tvConnectionInfos.setText("Connection Infos: \n Own IP-Adress: " + SERVER_IP+ " Port: " + SERVER_PORT); toggleKamera = findViewById(R.id.toggleKamera);
} catch (UnknownHostException e) { toggleKamera.setOnClickListener(this);
e.printStackTrace(); toggleAudio = findViewById(R.id.toggleAudio);
} toggleAudio.setOnClickListener(this);
Button btnSend = findViewById(R.id.btnSend); toggleBewegung = findViewById(R.id.toggleBewegung);
btnSend.setOnClickListener(new View.OnClickListener() { toggleBewegung.setOnClickListener(this);
@Override
public void onClick(View v) {
i++;
communication.sendTrue(String.valueOf(i));
}
});
}
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.options_menu, menu);
return true;
}
public boolean onOptionsItemSelected(MenuItem item) {
Toast.makeText(this, "Selected Item: " +item.getTitle(), Toast.LENGTH_SHORT).show();
PopUpClass popUpClass;
switch (item.getItemId()) {
case R.id.Rechteverwaltung:
popUpClass = new PopUpClass(MainActivity.this);
popUpClass.showPopupWindow(tvMessages);
popUpClass.RechtePrüfen();
return true;
case R.id.Sensoren:
popUpClass = new PopUpClass(MainActivity.this);
popUpClass.showPopupWindow(tvMessages);
popUpClass.Sensoren();
return true;
case R.id.Impressum:
popUpClass = new PopUpClass(MainActivity.this);
popUpClass.showPopupWindow(tvMessages);
popUpClass.Impressum();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
protected void onResume() { }
super.onResume(); @Override
if (!communicationRunning){ public void onClick(View v) {
communication = new WifiCommunication(MainActivity.this, SERVER_PORT); if (v == toggleKamera) {
communicationRunning = true; if (toggleKamera.isChecked()) {
wahr = true;
} else {
wahr = false;
}
}
if (v == toggleAudio) {
if (toggleAudio.isChecked()) {
wahr = true;
} else {
wahr = false;
}
}
if (v == toggleBewegung) {
if (toggleBewegung.isChecked()) {
wahr = true;
} else {
wahr = false;
}
} }
permission = new PermissionRequest(MainActivity.this);
permission.rechtePruefen();
} }
@Override @Override
protected void onPause() { protected void onPause() {
super.onPause(); super.onPause();
communication.stopCommunication(); communication.stopCommunication();
} }
private String getLocalIpAddress() throws UnknownHostException {
WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService(WIFI_SERVICE); @Override
assert wifiManager != null; protected void onResume() {
WifiInfo wifiInfo = wifiManager.getConnectionInfo(); super.onResume();
int ipInt = wifiInfo.getIpAddress(); communication = new WifiCommunication(1234);
return InetAddress.getByAddress(ByteBuffer.allocate(4).order(ByteOrder.LITTLE_ENDIAN).putInt(ipInt).array()).getHostAddress(); }
public void onClickZeigeFragment1(View view) {
Button button = (Button) view;
log(button.getText() + " ausgewählt");
zeigeFragment(fragment1.erstellen("Hier stehen dann die Alarme"));
}
public void onClickZeigeFragment2(View view) {
Button button = (Button) view;
log(button.getText() + " ausgewählt");
zeigeFragment(fragment2.erstellen("Hier stehen dann die Videos"));
}
public void onClickEntferneFragment(View view) {
entferneFragment();
}
private void zeigeFragment(Fragment fragment) {
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.replace(R.id.frame, fragment);
ft.commit();
aktuellesFragment = fragment;
}
private void entferneFragment() {
if (aktuellesFragment != null) {
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.remove(aktuellesFragment);
ft.commit();
aktuellesFragment = null ;
}
} }
} }
@@ -0,0 +1,31 @@
package com.example.ueberwachungssystem;
import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import java.io.File;
import java.util.List;
public class MeinAdapter extends ArrayAdapter<File> {
private Context context;
private File[] files;
public MeinAdapter(Context context, List<File> listf) {
super(context, android.R.layout.simple_list_item_1, listf);
this.context = context;
}
@Override
public View getView(final int pos, View cv, ViewGroup vg) {
View v = super.getView(pos, cv, vg);
v.setOnClickListener( new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.d("DerLog","nicht null");
}
});
return v;
}
}
@@ -0,0 +1,43 @@
package com.example.ueberwachungssystem;
import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageManager;
import android.widget.Toast;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
public class PermissionHandler {
private final Context context;
private static final int PERMISSION_REQUEST_CODE = 23409;
private static final String[] permissions = new String[]{
android.Manifest.permission.CAMERA,
android.Manifest.permission.RECORD_AUDIO
};
public PermissionHandler(Context context) {
this.context = context;
}
public boolean hasPermissions() {
boolean permissionState = true;
for (String permission: permissions) {
permissionState = permissionState && ContextCompat.checkSelfPermission(context, permission) == PackageManager.PERMISSION_GRANTED;
}
return permissionState;
}
public void getPermissions() {
if (!hasPermissions())
ActivityCompat.requestPermissions((Activity) context, permissions, PERMISSION_REQUEST_CODE);
}
public void showPermissionToast() {
if (hasPermissions())
Toast.makeText(context, "permissions available", Toast.LENGTH_SHORT).show();
else
Toast.makeText(context, "permissions missing", Toast.LENGTH_SHORT).show();
}
}
@@ -0,0 +1,36 @@
package com.example.ueberwachungssystem;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import java.io.File;
import java.util.List;
public class VideoListAdapter extends ArrayAdapter<File> {
public VideoListAdapter(Context context, List<File> videoList) {
super(context, 0, videoList);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = LayoutInflater.from(getContext()).inflate(R.layout.list_item_video, parent, false);
}
File videoFile = getItem(position);
ImageView thumbnailImageView = convertView.findViewById(R.id.imageViewThumbnail);
TextView titleTextView = convertView.findViewById(R.id.textViewTitle);
// Set tag to identify the clicked item
convertView.setTag(videoFile.getAbsolutePath());
return convertView;
    }
}
@@ -1,6 +1,7 @@
package com.example.ueberwachungssystem; package com.example.ueberwachungssystem;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.widget.Toast;
import androidx.annotation.NonNull;
import java.io.IOException; import java.io.IOException;
import java.net.DatagramPacket; import java.net.DatagramPacket;
@@ -15,7 +16,7 @@ import java.util.Date;
import java.util.Enumeration; import java.util.Enumeration;
public class WifiCommunication { public class WifiCommunication {
private final MainActivity mainActivity; //private final MainActivity mainActivity;
private final InetAddress address; private final InetAddress address;
private final int port; private final int port;
@@ -23,9 +24,11 @@ public class WifiCommunication {
volatile private boolean send; volatile private boolean send;
private final DatagramSocket socket; private final DatagramSocket socket;
volatile private boolean running; volatile private boolean running;
private OnConnectionListener listener;
@SuppressLint("SetTextI18n") @SuppressLint("SetTextI18n")
public WifiCommunication(MainActivity mainActivity, int port) { public WifiCommunication(int port) {
this.mainActivity = mainActivity; //this.mainActivity = mainActivity;
this.port = port; this.port = port;
try { try {
socket = new DatagramSocket(this.port); socket = new DatagramSocket(this.port);
@@ -38,10 +41,23 @@ public class WifiCommunication {
} catch (SocketException | UnknownHostException e) { } catch (SocketException | UnknownHostException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
Toast.makeText(mainActivity.getApplicationContext(),"Communication running", Toast.LENGTH_SHORT).show(); //Toast.makeText(mainActivity.getApplicationContext(),"Communication running", Toast.LENGTH_SHORT).show();
//mainActivity.runOnUiThread(() -> mainActivity.tvMessages.setText("Communication running")); //mainActivity.runOnUiThread(() -> mainActivity.tvMessages.setText("Communication running"));
} }
public interface OnConnectionListener {
void onConnection(StringBuffer data);
}
public void setOnConnectionListener(@NonNull OnConnectionListener listener) {
this.listener = listener;
}
public void sendWifiData(StringBuffer wifiMessage) {
if (listener != null) {
listener.onConnection(wifiMessage);
}
}
private class ReceiveThread extends Thread { private class ReceiveThread extends Thread {
private StringBuffer rxStringBuffer = new StringBuffer(); private StringBuffer rxStringBuffer = new StringBuffer();
private String rxString=""; private String rxString="";
@@ -54,11 +70,12 @@ public class WifiCommunication {
byte[] receiveData = new byte[512]; byte[] receiveData = new byte[512];
DatagramPacket rxPacket = new DatagramPacket(receiveData, receiveData.length); DatagramPacket rxPacket = new DatagramPacket(receiveData, receiveData.length);
socket.receive(rxPacket); socket.receive(rxPacket);
rxString = new String(rxPacket.getData()); rxString = new String(receiveData, 0, rxPacket.getLength());
String[] splitrxString = rxString.split(","); String[] splitrxString = rxString.split(",");
if(!previousRxString.equals(rxString) && splitrxString[0].equals("1") && splitrxString.length==7) { if(!previousRxString.equals(rxString) && splitrxString[0].equals("1") && splitrxString.length==7) {
rxStringBuffer.append(rxString).append("\n"); rxStringBuffer.append(rxString).append("\n");
mainActivity.runOnUiThread(() -> mainActivity.tvMessages.setText(rxStringBuffer)); sendWifiData(rxStringBuffer);
//mainActivity.runOnUiThread(() -> mainActivity.tvMessages.setText(rxStringBuffer));
previousRxString = rxString; previousRxString = rxString;
} }
} while (running); } while (running);
@@ -86,7 +103,7 @@ public class WifiCommunication {
DatagramPacket txPacket = new DatagramPacket(send_Data, txString.length(), address, port); DatagramPacket txPacket = new DatagramPacket(send_Data, txString.length(), address, port);
for(int i = 0; i < 500; i++) { for(int i = 0; i < 300; i++) {
socket.send(txPacket); socket.send(txPacket);
} }
} }
+5
View File
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="false" android:drawable="@color/redbright" />
<item android:state_checked="true" android:drawable="@color/greenbright" />
</selector>
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
</LinearLayout>
+122 -30
View File
@@ -1,37 +1,129 @@
<?xml version = "1.0" encoding = "utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android = "http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
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:layout_margin = "16dp" android:background="#010C49"
tools:context = ".MainActivity"> android:visibility="visible"
<TextView tools:context="com.example.ueberwachungssystem.MainActivity"
android:id = "@+id/tvConnectionInfos" tools:visibility="visible">
android:layout_width = "match_parent"
android:layout_height = "wrap_content"
android:inputType = "textMultiLine"
android:hint="ConnectionInfos"
android:textAppearance = "@style/Base.TextAppearance.AppCompat.Medium" />
<Button <TextView
android:id="@+id/btnSend" android:id="@+id/textAuswahl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:textSize="20sp"
android:textColor="@color/white"/>
<TextView
android:id="@+id/textAoderA"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/toggleAudio"
android:layout_alignParentLeft="true"
android:layout_marginTop="15dp"
android:textSize="20sp"
android:textColor="@color/white"/>
<ToggleButton
android:id="@+id/toggleKamera"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@id/scrollView" android:layout_alignBottom="@id/toggleAudio"
android:layout_centerHorizontal="true" android:layout_marginRight="30dp"
android:text="SEND" /> android:layout_toLeftOf="@id/toggleAudio"
android:textColor="@color/yellow"
android:textOn="Kamera an"
android:textOff="Kamera aus"
android:background="@drawable/toggle_btn"/>
<ScrollView <ToggleButton
android:id="@+id/scrollView" android:id="@+id/toggleAudio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/textAuswahl"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:textColor="@color/yellow"
android:textOn="Audio an"
android:textOff="Audio aus"
android:background="@drawable/toggle_btn"/>
<ToggleButton
android:id="@+id/toggleBewegung"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@id/toggleAudio"
android:layout_marginLeft="30dp"
android:layout_toEndOf="@+id/toggleAudio"
android:layout_toRightOf="@id/toggleAudio"
android:textColor="@color/yellow"
android:textOn="Bewegung an"
android:textOff="Bewegung aus"
android:background="@drawable/toggle_btn"/>
<Button
android:id="@+id/btnAlarme"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/btnAufnahmen"
android:layout_toLeftOf="@id/btnAufnahmen"
android:layout_marginRight="15dp"
android:theme="@style/Button.Green"
android:onClick="onClickZeigeFragment1"
android:text="Alarme" />
<Button
android:id="@+id/btnAufnahmen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textAoderA"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp"
android:theme="@style/Button.Green"
android:onClick="onClickZeigeFragment2"
android:text="Aufnahmen" />
<Button
android:id="@+id/btnAnzeigeVerb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/btnAufnahmen"
android:layout_toRightOf="@id/btnAufnahmen"
android:layout_marginLeft="15dp"
android:text="Anzeige verbergen"
android:onClick="onClickEntferneFragment"/>
<FrameLayout
android:id="@+id/frame"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_below="@id/tvConnectionInfos" android:layout_height="match_parent"
android:layout_height="300dp"> android:layout_below="@+id/btnAufnahmen"
<TextView android:layout_marginTop="25dp"
android:id = "@+id/tvMessages" android:layout_alignParentStart="true"
android:layout_width = "match_parent" android:background="@color/white">
android:layout_height = "wrap_content" </FrameLayout>
android:hint="Messages"
android:inputType = "textMultiLine" <!--
android:textAppearance = "@style/Base.TextAppearance.AppCompat.Medium" /> <ScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/btnAufnahmen"
android:layout_marginTop="25dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/Alarm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/red"/>
</LinearLayout>
</ScrollView> </ScrollView>
-->
</RelativeLayout> </RelativeLayout>
+26
View File
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical"
android:background="@color/bluedark">
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="25dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/Alarm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/yellow"/>
</LinearLayout>
</ScrollView>
</RelativeLayout>
+33
View File
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical"
android:background="@android:color/holo_blue_light" >
<ScrollView
android:id="@+id/scrollView2"
android:layout_width="match_parent"
android:layout_height="250dp"
android:layout_marginTop="25dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/Aufzeichnungen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/yellow"/>
</LinearLayout>
</ScrollView>
<VideoView
android:id="@+id/AusAuf"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/scrollView2"
android:textAppearance="?android:attr/textAppearanceLarge"/>
</LinearLayout>
+22
View File
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical"
android:background="@android:color/holo_blue_light" >
<TextView
android:id="@+id/Sensor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"/>
<TextView
android:id="@+id/Alarm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/Sensor"
android:textAppearance="?android:attr/textAppearanceLarge"/>
</LinearLayout>
+5
View File
@@ -7,4 +7,9 @@
<color name="teal_700">#FF018786</color> <color name="teal_700">#FF018786</color>
<color name="black">#FF000000</color> <color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color> <color name="white">#FFFFFFFF</color>
<color name="red">#5C0000</color>
<color name="redbright">#EF3434</color>
<color name="greenbright">#469733</color>
<color name="bluedark">#053C8E</color>
<color name="yellow">#FFEB3B</color>
</resources> </resources>
+5
View File
@@ -13,4 +13,9 @@
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item> <item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. --> <!-- Customize your theme here. -->
</style> </style>
<style name="Button.Green" parent="ThemeOverlay.AppCompat">
<item name="colorAccent">#0F3E01</item>
</style>
</resources> </resources>
+2 -2
View File
@@ -1,5 +1,5 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules. // Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins { plugins {
id 'com.android.application' version '7.4.2' apply false id 'com.android.application' version '8.0.0' apply false
id 'com.android.library' version '7.4.2' apply false id 'com.android.library' version '8.0.0' apply false
} }
+2
View File
@@ -19,3 +19,5 @@ android.useAndroidX=true
# resources declared in the library itself and none from the library's dependencies, # resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library # thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true android.nonTransitiveRClass=true
android.defaults.buildfeatures.buildconfig=true
android.nonFinalResIds=false
+2 -2
View File
@@ -1,6 +1,6 @@
#Thu May 11 15:04:30 CEST 2023 #Thu May 11 15:19:24 CEST 2023
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME