Compare commits
40
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
076db89147 | ||
|
|
061646a7d6 | ||
|
|
6f78836c4d | ||
|
|
272daf9fae | ||
|
|
55ae95e661 | ||
|
|
8e47934beb | ||
|
|
c60a14b6ac | ||
|
|
b9c66f7533 | ||
|
|
7e1143880e | ||
|
|
4381ae78f8 | ||
|
|
81c3542654 | ||
|
|
81e04e370a | ||
|
|
d33ab299ab | ||
|
|
8a5d720685 | ||
|
|
90aea5b1bc | ||
|
|
8a357e0d26 | ||
|
|
83268c763b | ||
|
|
3d02d8d4c0 | ||
|
|
cafe763c4a | ||
|
|
2cff334056 | ||
|
|
b94a1d98b7 | ||
|
|
746eec18ba | ||
|
|
44e056b5fe | ||
|
|
df1fefef5f | ||
|
|
5bcd465ecc | ||
|
|
a6fdf3f774 | ||
|
|
b46db4cdfc | ||
|
|
6c4905d0e7 | ||
|
|
402b73e4bd | ||
|
|
9e5b669986 | ||
|
|
8275d8bd5a | ||
|
|
74eb3e0d98 | ||
|
|
5f7e2a43f2 | ||
|
|
07f60f974b | ||
|
|
7c8610facb | ||
|
|
4999f1b998 | ||
|
|
620528302e | ||
|
|
90a2aad491 | ||
|
|
57bf2c2fb7 | ||
|
|
5c0263198c |
@@ -0,0 +1,3 @@
|
|||||||
|
Sensor als Service einrichten, der aus Activity heraus gestartet werden kann.
|
||||||
|
Stichwort: Intent
|
||||||
|
Siehe Skript Teil 1
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
package com.example.ueberwachungssystem.Detection;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.media.MediaPlayer;
|
|
||||||
import android.media.MediaRecorder;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
|
|
||||||
public class AudioRecorder {
|
|
||||||
private final Context context;
|
|
||||||
private MediaRecorder mediaRecorder = null;
|
|
||||||
private boolean isRecording = false;
|
|
||||||
private File outputDir; // Default: in app files directory
|
|
||||||
|
|
||||||
|
|
||||||
public AudioRecorder (Context context) {
|
|
||||||
this.context = context;
|
|
||||||
this.outputDir = context.getFilesDir();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void startRecording() {
|
|
||||||
// Handle logic
|
|
||||||
if (outputDir == null)
|
|
||||||
return;
|
|
||||||
if (isRecording)
|
|
||||||
return;
|
|
||||||
isRecording = true;
|
|
||||||
|
|
||||||
// Setup Audio Recorder for output Format: 3GP
|
|
||||||
mediaRecorder = new MediaRecorder();
|
|
||||||
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
|
|
||||||
mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
|
|
||||||
mediaRecorder.setOutputFile(outputDir + "/" + generateFileName() + ".3gp");
|
|
||||||
mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
|
|
||||||
try {
|
|
||||||
mediaRecorder.prepare();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
mediaRecorder.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void stopRecording() {
|
|
||||||
if (mediaRecorder != null) {
|
|
||||||
mediaRecorder.stop();
|
|
||||||
mediaRecorder.reset();
|
|
||||||
mediaRecorder.release();
|
|
||||||
mediaRecorder = null;
|
|
||||||
isRecording = false;
|
|
||||||
Toast.makeText(context, "audio recording saved", Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isRecording(){
|
|
||||||
return isRecording;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOutputDir(File outputDir) {
|
|
||||||
this.outputDir = outputDir;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String generateFileName(){
|
|
||||||
// Get the current timestamp
|
|
||||||
LocalDateTime currentTime = LocalDateTime.now();
|
|
||||||
// Define the format for the timestamp
|
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd_HHmmss");
|
|
||||||
// Return the timestamp as a string
|
|
||||||
return currentTime.format(formatter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
package com.example.ueberwachungssystem.Detection;
|
|
||||||
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import java.util.Calendar;
|
|
||||||
|
|
||||||
/** Detection Report Class */
|
|
||||||
public class DetectionReport {
|
|
||||||
public String timeStamp;
|
|
||||||
public String detectionType;
|
|
||||||
public float detectedValue;
|
|
||||||
public boolean detectionState;
|
|
||||||
|
|
||||||
public DetectionReport(boolean detectionState, String detectionType, float detectedAmplitude) {
|
|
||||||
this.timeStamp = String.valueOf(Calendar.getInstance().getTime());
|
|
||||||
this.detectionType = detectionType;
|
|
||||||
this.detectedValue = detectedAmplitude;
|
|
||||||
this.detectionState = detectionState;
|
|
||||||
|
|
||||||
//this.detectorID = detectorID;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/** Get Detection Report in String format */
|
|
||||||
public String toString() {
|
|
||||||
String state = "State: " + "[" + this.detectionState + "]";
|
|
||||||
String time = "Time: " + "[" + this.timeStamp + "]";
|
|
||||||
String type = "Type: " + "[" + this.detectionType + "]";
|
|
||||||
String value = "Value: " + "[" + this.detectedValue + "]";
|
|
||||||
|
|
||||||
return String.join("\t", state, time, type, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Debug Report */
|
|
||||||
public void log(String tag) {
|
|
||||||
Log.d(tag, this.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,76 +0,0 @@
|
|||||||
package com.example.ueberwachungssystem.Detection;
|
|
||||||
|
|
||||||
import android.os.CountDownTimer;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.camera.core.ExperimentalGetImage;
|
|
||||||
|
|
||||||
|
|
||||||
abstract public class Detector {
|
|
||||||
private OnDetectionListener listener;
|
|
||||||
private boolean isDetecting = false;
|
|
||||||
private boolean extendViolation = false;
|
|
||||||
|
|
||||||
// Countdown parameters
|
|
||||||
private final int COUNTDOWN_TIME = 10000; // milliseconds
|
|
||||||
private final int COUNTDOWN_POLLING_TIME = 100; // milliseconds
|
|
||||||
|
|
||||||
/** Constructor - takes context of current activity */
|
|
||||||
public Detector() {}
|
|
||||||
|
|
||||||
|
|
||||||
/** On Detection Listener - runs when violation is reported */
|
|
||||||
public interface OnDetectionListener {
|
|
||||||
void onDetection(@NonNull DetectionReport detectionReport);
|
|
||||||
}
|
|
||||||
public void setOnDetectionListener(@NonNull OnDetectionListener listener) {
|
|
||||||
this.listener = listener;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Triggers onDetectionListener - call this to trigger violation/alarm */
|
|
||||||
public void reportViolation(String detectionType, float amplitude) {
|
|
||||||
if (listener != null) {
|
|
||||||
if (!isDetecting) {
|
|
||||||
isDetecting = true;
|
|
||||||
DetectionReport detectionReport = new DetectionReport(true, detectionType, amplitude);
|
|
||||||
listener.onDetection(detectionReport);
|
|
||||||
startDetectionTimer(detectionType, amplitude);
|
|
||||||
} else {
|
|
||||||
extendViolation = true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
isDetecting = false;
|
|
||||||
extendViolation = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void startDetectionTimer(String detectionType, float amplitude) {
|
|
||||||
isDetecting = true;
|
|
||||||
new CountDownTimer((long) COUNTDOWN_TIME, COUNTDOWN_POLLING_TIME) {
|
|
||||||
@Override
|
|
||||||
public void onTick(long millisUntilFinished) {
|
|
||||||
if (extendViolation) {
|
|
||||||
extendViolation = false;
|
|
||||||
startDetectionTimer(detectionType, amplitude);
|
|
||||||
this.cancel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onFinish() {
|
|
||||||
isDetecting = false;
|
|
||||||
DetectionReport detectionReport = new DetectionReport(false, detectionType, amplitude);
|
|
||||||
listener.onDetection(detectionReport);
|
|
||||||
}
|
|
||||||
}.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void extendViolation(){
|
|
||||||
this.extendViolation = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Starts Detection (abstract method: needs to be overridden in child class) */
|
|
||||||
public abstract void startDetection();
|
|
||||||
|
|
||||||
/** Stops Detection (abstract method: needs to be overridden in child class) */
|
|
||||||
public abstract void stopDetection();
|
|
||||||
}
|
|
||||||
@@ -1,174 +0,0 @@
|
|||||||
package com.example.ueberwachungssystem.Detection;
|
|
||||||
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.Binder;
|
|
||||||
import android.os.IBinder;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.camera.core.ExperimentalGetImage;
|
|
||||||
import androidx.lifecycle.LifecycleService;
|
|
||||||
|
|
||||||
import com.example.ueberwachungssystem.WifiCommunication;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
@ExperimentalGetImage
|
|
||||||
public class DetectorService extends LifecycleService {
|
|
||||||
public ServiceBinder serviceBinder = new ServiceBinder();
|
|
||||||
private DetectorService.OnDetectionListener listener;
|
|
||||||
private boolean isServiceRunning = false;
|
|
||||||
|
|
||||||
VideoDetector videoDetector = null;
|
|
||||||
AudioRecorder audioRecorder = null;
|
|
||||||
|
|
||||||
/** Communication **/
|
|
||||||
|
|
||||||
WifiCommunication wifiCommunication;
|
|
||||||
|
|
||||||
StringBuffer dataFromWifi;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
|
||||||
if (isServiceRunning)
|
|
||||||
return START_NOT_STICKY;
|
|
||||||
|
|
||||||
|
|
||||||
// Setup Service classes:
|
|
||||||
videoDetector = new VideoDetector(this);
|
|
||||||
videoDetector.setOnDetectionListener(new Detector.OnDetectionListener() {
|
|
||||||
@Override
|
|
||||||
public void onDetection(@NonNull DetectionReport detectionReport) {
|
|
||||||
passToServiceListener(detectionReport);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
audioRecorder = new AudioRecorder(this);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
isServiceRunning = true;
|
|
||||||
|
|
||||||
wifiCommunication = new WifiCommunication (1234);
|
|
||||||
wifiCommunication.setOnConnectionListener(new WifiCommunication.OnConnectionListener() {
|
|
||||||
@Override
|
|
||||||
public void onConnection(StringBuffer data) {
|
|
||||||
dataFromWifi = data;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return super.onStartCommand(intent, flags, startId);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onDestroy() {
|
|
||||||
super.onDestroy();
|
|
||||||
isServiceRunning = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Service methods */
|
|
||||||
public class ServiceBinder extends Binder {
|
|
||||||
public DetectorService getBoundService() {
|
|
||||||
// Return an instance of the TestService
|
|
||||||
return DetectorService.this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public IBinder onBind(Intent intent) {
|
|
||||||
super.onBind(intent);
|
|
||||||
return serviceBinder;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/** Video Detection */
|
|
||||||
public void startVideoDetection() {
|
|
||||||
if(videoDetector != null)
|
|
||||||
videoDetector.startDetection();
|
|
||||||
}
|
|
||||||
public void stopVideoDetection() {
|
|
||||||
if(videoDetector != null)
|
|
||||||
videoDetector.stopDetection();
|
|
||||||
}
|
|
||||||
public boolean isVideoDetectionRunning() {
|
|
||||||
if(videoDetector != null)
|
|
||||||
return videoDetector.isDetecting();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
public void debugVideoProcessing(ImageView input, ImageView output) {
|
|
||||||
if(videoDetector != null)
|
|
||||||
videoDetector.debugProcessing(input, output);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Audio Detection */
|
|
||||||
public void startAudioDetection() {
|
|
||||||
|
|
||||||
}
|
|
||||||
public void stopAudioDetection() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Motion Detection */
|
|
||||||
public void startMotionDetection() {
|
|
||||||
|
|
||||||
}
|
|
||||||
public void stopMotionDetection() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Video Recording */
|
|
||||||
public void startVideoRecording() {
|
|
||||||
if(videoDetector != null)
|
|
||||||
videoDetector.startRecording();
|
|
||||||
}
|
|
||||||
public void stopVideoRecording() {
|
|
||||||
if(videoDetector != null)
|
|
||||||
videoDetector.stopRecording();
|
|
||||||
}
|
|
||||||
public boolean isVideoRecordingRunning() {
|
|
||||||
if(videoDetector != null)
|
|
||||||
return videoDetector.isRecording();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
public void setVideoRecordingDir(File outputDir) {
|
|
||||||
if (videoDetector != null)
|
|
||||||
videoDetector.setOutputDir(outputDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Audio Recording */
|
|
||||||
public void startAudioRecording() {
|
|
||||||
if(audioRecorder != null)
|
|
||||||
audioRecorder.startRecording();
|
|
||||||
}
|
|
||||||
public void stopAudioRecording() {
|
|
||||||
if(audioRecorder != null)
|
|
||||||
audioRecorder.stopRecording();
|
|
||||||
}
|
|
||||||
public boolean isAudioRecordingRunning() {
|
|
||||||
if(videoDetector != null)
|
|
||||||
return audioRecorder.isRecording();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
public void setAudioRecordingDir(File outputDir) {
|
|
||||||
if (audioRecorder != null)
|
|
||||||
audioRecorder.setOutputDir(outputDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/** pass Detection Report to Service Detection Listener and trigger it */
|
|
||||||
public void passToServiceListener(DetectionReport detectionReport) {
|
|
||||||
if (listener != null) {
|
|
||||||
listener.onDetection(detectionReport);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/** On Detection Listener - runs when violation is reported */
|
|
||||||
public interface OnDetectionListener {
|
|
||||||
void onDetection(@NonNull DetectionReport detectionReport);
|
|
||||||
}
|
|
||||||
public void setOnDetectionListener(@NonNull DetectorService.OnDetectionListener listener) {
|
|
||||||
this.listener = listener;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,109 +0,0 @@
|
|||||||
package com.example.ueberwachungssystem.Detection;
|
|
||||||
|
|
||||||
import android.graphics.Bitmap;
|
|
||||||
import android.media.Image;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.camera.core.ExperimentalGetImage;
|
|
||||||
import androidx.camera.core.ImageProxy;
|
|
||||||
|
|
||||||
import org.opencv.android.Utils;
|
|
||||||
import org.opencv.core.Core;
|
|
||||||
import org.opencv.core.CvType;
|
|
||||||
import org.opencv.core.Mat;
|
|
||||||
import org.opencv.core.MatOfPoint;
|
|
||||||
import org.opencv.core.Scalar;
|
|
||||||
import org.opencv.core.Size;
|
|
||||||
import org.opencv.imgproc.Imgproc;
|
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
|
||||||
@ExperimentalGetImage
|
|
||||||
public class OpenCVHelper {
|
|
||||||
|
|
||||||
/** OpenCV helper methods **/
|
|
||||||
public static Mat addGaussianBlur(Mat inputMat, Size kernelSize){
|
|
||||||
Mat outputMat = new Mat();
|
|
||||||
Imgproc.GaussianBlur(inputMat, outputMat, kernelSize, 0);
|
|
||||||
return outputMat;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Mat addBlur(Mat inputMat, Size kernelSize){
|
|
||||||
Mat outputMat = new Mat();
|
|
||||||
Imgproc.blur(inputMat, outputMat, kernelSize);
|
|
||||||
return outputMat;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Mat extractYChannel(@NonNull ImageProxy imgProxy) {
|
|
||||||
Image img = imgProxy.getImage();
|
|
||||||
|
|
||||||
assert img != null;
|
|
||||||
ByteBuffer yBuffer = img.getPlanes()[0].getBuffer();
|
|
||||||
byte[] yData = new byte[yBuffer.remaining()];
|
|
||||||
yBuffer.get(yData);
|
|
||||||
|
|
||||||
Mat yMat = new Mat(img.getHeight(), img.getWidth(), CvType.CV_8UC1);
|
|
||||||
yMat.put(0, 0, yData);
|
|
||||||
|
|
||||||
return yMat;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Mat thresholdPixels(Mat inputMat, Mat previousImage, int threshold){
|
|
||||||
Mat diffImage = new Mat();
|
|
||||||
Core.absdiff(inputMat, previousImage, diffImage);
|
|
||||||
Mat binaryMat = new Mat();
|
|
||||||
Imgproc.threshold(diffImage, binaryMat, threshold, 255, Imgproc.THRESH_BINARY);
|
|
||||||
return binaryMat;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static Mat thresholdContourArea(Mat inputMat, float areaThreshold){
|
|
||||||
List<MatOfPoint> contours = new ArrayList<>();
|
|
||||||
Mat hierarchy = new Mat();
|
|
||||||
Imgproc.findContours(inputMat, contours, hierarchy, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE);
|
|
||||||
|
|
||||||
Mat outputMat = new Mat(inputMat.size(), inputMat.type(), new Scalar(0));
|
|
||||||
// Iterate over the contours and draw only the larger contours on the outputMat
|
|
||||||
for (MatOfPoint contour : contours) {
|
|
||||||
double contourArea = Imgproc.contourArea(contour);
|
|
||||||
if (contourArea > areaThreshold) {
|
|
||||||
Imgproc.drawContours(outputMat, Collections.singletonList(contour), 0, new Scalar(255), -1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Apply the outputMat as a mask to the dilatedImage
|
|
||||||
Mat maskedImage = new Mat();
|
|
||||||
inputMat.copyTo(maskedImage, outputMat);
|
|
||||||
return outputMat;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Mat dilateBinaryMat(Mat inputMat, Size kernelSize){
|
|
||||||
Mat dilatedMat = new Mat();
|
|
||||||
Mat kernel = Imgproc.getStructuringElement(Imgproc.MORPH_ELLIPSE, kernelSize);
|
|
||||||
Imgproc.dilate(inputMat, dilatedMat, kernel);
|
|
||||||
return dilatedMat;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int countNonZeroPixels(Mat inputImage) {
|
|
||||||
if (inputImage != null)
|
|
||||||
return Core.countNonZero(inputImage);
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static void debugMat(Mat mat, ImageView imageView) {
|
|
||||||
if (imageView == null || mat == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Bitmap bitmap = Bitmap.createBitmap(mat.cols(), mat.rows(), Bitmap.Config.ARGB_8888);
|
|
||||||
Utils.matToBitmap(mat, bitmap);
|
|
||||||
|
|
||||||
// Display the bitmap in an ImageView
|
|
||||||
imageView.setImageBitmap(bitmap);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,327 +0,0 @@
|
|||||||
package com.example.ueberwachungssystem.Detection;
|
|
||||||
|
|
||||||
import android.Manifest;
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.graphics.ImageFormat;
|
|
||||||
import android.media.Image;
|
|
||||||
import android.os.CountDownTimer;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.Display;
|
|
||||||
import android.view.Surface;
|
|
||||||
import android.view.WindowManager;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.camera.core.CameraSelector;
|
|
||||||
import androidx.camera.core.ExperimentalGetImage;
|
|
||||||
import androidx.camera.core.ImageAnalysis;
|
|
||||||
import androidx.camera.core.ImageProxy;
|
|
||||||
import androidx.camera.core.Preview;
|
|
||||||
import androidx.camera.core.VideoCapture;
|
|
||||||
import androidx.camera.lifecycle.ProcessCameraProvider;
|
|
||||||
import androidx.camera.view.PreviewView;
|
|
||||||
import androidx.core.app.ActivityCompat;
|
|
||||||
import androidx.core.content.ContextCompat;
|
|
||||||
import androidx.lifecycle.LifecycleOwner;
|
|
||||||
|
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
|
||||||
|
|
||||||
import org.opencv.android.OpenCVLoader;
|
|
||||||
import org.opencv.core.Mat;
|
|
||||||
import org.opencv.core.Size;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Video Detector inherits some methods from abstract Detector class (more info there)
|
|
||||||
* USE FROM MAIN ACTIVITY:
|
|
||||||
* VideoDetector vd = new VideoDetector(this);
|
|
||||||
* */
|
|
||||||
|
|
||||||
|
|
||||||
@ExperimentalGetImage
|
|
||||||
public class VideoDetector extends Detector {
|
|
||||||
// Calling Activity
|
|
||||||
private final Context context;
|
|
||||||
|
|
||||||
// Camera Provider
|
|
||||||
private ProcessCameraProvider cameraProvider;
|
|
||||||
private ImageAnalysis imageAnalysis;
|
|
||||||
private VideoCapture videoCapture;
|
|
||||||
//private Preview preview;
|
|
||||||
|
|
||||||
// Logic
|
|
||||||
private boolean isDetecting = false;
|
|
||||||
private boolean isRecording = false;
|
|
||||||
private boolean allowReportViolation = false;
|
|
||||||
|
|
||||||
// Image Processing
|
|
||||||
private Mat previousImage = null;
|
|
||||||
|
|
||||||
// Debugging
|
|
||||||
private ImageView inputImageView = null;
|
|
||||||
private ImageView outputImageView = null;
|
|
||||||
|
|
||||||
// Recorder
|
|
||||||
private File outputDir; // Default: in app files directory
|
|
||||||
|
|
||||||
|
|
||||||
// Parameters
|
|
||||||
private static final float ALARM_THRESHOLD = 0f; // Percent of pixels changed
|
|
||||||
private static final float AREA_THRESHOLD = 10f;
|
|
||||||
private static final int DILATE_ITERATIONS = 2;
|
|
||||||
private static final float START_DELAY = 20000; // milliseconds
|
|
||||||
private static final android.util.Size IMAGE_RES = new android.util.Size(640, 480);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** Constructor */
|
|
||||||
public VideoDetector(Context context) {
|
|
||||||
super();
|
|
||||||
this.context = context;
|
|
||||||
this.imageAnalysis = setupImageAnalysis();
|
|
||||||
this.videoCapture = setupVideoCapture();
|
|
||||||
this.outputDir = context.getFilesDir();
|
|
||||||
//this.preview = new Preview.Builder().build();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get States */
|
|
||||||
public boolean isDetecting() {
|
|
||||||
return isDetecting;
|
|
||||||
}
|
|
||||||
public boolean isRecording(){
|
|
||||||
return isRecording;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/** Starts the Video Detection */
|
|
||||||
@Override
|
|
||||||
public void startDetection() {
|
|
||||||
// Check States
|
|
||||||
if (isDetecting)
|
|
||||||
return;
|
|
||||||
// Configure Image Analysis
|
|
||||||
imageAnalysis = setupImageAnalysis();
|
|
||||||
// Open CV startup check
|
|
||||||
if (!OpenCVLoader.initDebug()) {
|
|
||||||
Log.e("OpenCV", "Unable to load OpenCV!");
|
|
||||||
return;
|
|
||||||
} else
|
|
||||||
Log.d("OpenCV", "OpenCV loaded Successfully!");
|
|
||||||
// Get Process Camera Provider and start
|
|
||||||
final ListenableFuture<ProcessCameraProvider> cameraProviderFuture = ProcessCameraProvider.getInstance(context);
|
|
||||||
cameraProviderFuture.addListener(() -> {
|
|
||||||
try {
|
|
||||||
cameraProvider = cameraProviderFuture.get();
|
|
||||||
isDetecting = true;
|
|
||||||
bindCameraProvider();
|
|
||||||
} catch (ExecutionException | InterruptedException e) {}
|
|
||||||
}, ContextCompat.getMainExecutor(context));
|
|
||||||
// Disable Violation Calling for Setup Time
|
|
||||||
startViolationTimer(START_DELAY);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Starts the Recorder */
|
|
||||||
@SuppressLint("RestrictedApi")
|
|
||||||
public void startRecording() {
|
|
||||||
// Check States
|
|
||||||
if (isRecording){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
videoCapture = setupVideoCapture();
|
|
||||||
|
|
||||||
final ListenableFuture<ProcessCameraProvider> cameraProviderFuture = ProcessCameraProvider.getInstance(context);
|
|
||||||
cameraProviderFuture.addListener(() -> {
|
|
||||||
try {
|
|
||||||
cameraProvider = cameraProviderFuture.get();
|
|
||||||
isRecording = true;
|
|
||||||
bindCameraProvider();
|
|
||||||
|
|
||||||
File vidFile = new File(context.getFilesDir() + "/" + generateFileName() + ".mp4");
|
|
||||||
if (ActivityCompat.checkSelfPermission(context, Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
videoCapture.startRecording(
|
|
||||||
new VideoCapture.OutputFileOptions.Builder(vidFile).build(),
|
|
||||||
context.getMainExecutor(),
|
|
||||||
new VideoCapture.OnVideoSavedCallback() {
|
|
||||||
@Override
|
|
||||||
public void onVideoSaved(@NonNull VideoCapture.OutputFileResults outputFileResults) {
|
|
||||||
isRecording = false;
|
|
||||||
Toast.makeText(context, "video recording saved", Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onError(int videoCaptureError, @NonNull String message, @Nullable Throwable cause) {
|
|
||||||
isRecording = false;
|
|
||||||
Toast.makeText(context, "video recording failed", Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
} catch (ExecutionException | InterruptedException ignored) {}
|
|
||||||
}, ContextCompat.getMainExecutor(context));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Stops the Video Detection */
|
|
||||||
@Override
|
|
||||||
public void stopDetection() {
|
|
||||||
if (!isDetecting || imageAnalysis == null)
|
|
||||||
return;
|
|
||||||
cameraProvider.unbind(imageAnalysis);
|
|
||||||
isDetecting = false;
|
|
||||||
allowReportViolation = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Stops the Recording */
|
|
||||||
@SuppressLint("RestrictedApi")
|
|
||||||
public void stopRecording(){
|
|
||||||
if(!isRecording)
|
|
||||||
return;
|
|
||||||
|
|
||||||
videoCapture.stopRecording();
|
|
||||||
cameraProvider.unbind(videoCapture);
|
|
||||||
isRecording = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Bind Camera Provider */
|
|
||||||
private void bindCameraProvider() {
|
|
||||||
// Specify which Camera to use
|
|
||||||
CameraSelector cameraSelector = new CameraSelector.Builder().requireLensFacing(CameraSelector.LENS_FACING_BACK).build();
|
|
||||||
cameraProvider.unbindAll();
|
|
||||||
cameraProvider.bindToLifecycle((LifecycleOwner) context, cameraSelector, imageAnalysis, videoCapture);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Setup Use Cases */
|
|
||||||
private ImageAnalysis setupImageAnalysis() {
|
|
||||||
// Configure and create Image Analysis
|
|
||||||
ImageAnalysis.Builder builder = new ImageAnalysis.Builder();
|
|
||||||
builder.setTargetResolution(IMAGE_RES);
|
|
||||||
builder.setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST);
|
|
||||||
builder.setOutputImageFormat(ImageAnalysis.OUTPUT_IMAGE_FORMAT_YUV_420_888);
|
|
||||||
builder.setTargetRotation(Surface.ROTATION_90);
|
|
||||||
ImageAnalysis imageAnalysis = builder.build();
|
|
||||||
// Set Analyzer
|
|
||||||
imageAnalysis.setAnalyzer(ContextCompat.getMainExecutor(context), imageProxy -> {
|
|
||||||
if (imageProxy.getFormat() == ImageFormat.YUV_420_888) {
|
|
||||||
Image image = imageProxy.getImage();
|
|
||||||
assert image != null;
|
|
||||||
|
|
||||||
// Violation Handling
|
|
||||||
Mat processed = processImage(imageProxy);
|
|
||||||
|
|
||||||
int n = OpenCVHelper.countNonZeroPixels(processed);
|
|
||||||
int pixelCount = image.getWidth() * image.getHeight();
|
|
||||||
float percentChanged = (float) n / pixelCount;
|
|
||||||
|
|
||||||
// Violation Condition
|
|
||||||
if (percentChanged * 100 > ALARM_THRESHOLD) {
|
|
||||||
if (allowReportViolation)
|
|
||||||
reportViolation("Video", percentChanged);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
imageProxy.close();
|
|
||||||
});
|
|
||||||
return imageAnalysis;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("RestrictedApi")
|
|
||||||
private VideoCapture setupVideoCapture() {
|
|
||||||
int rotation = getDisplayRotation();
|
|
||||||
return new VideoCapture.Builder()
|
|
||||||
.setTargetRotation(rotation)
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Process Image to be used for Motion Detection */
|
|
||||||
private Mat processImage(ImageProxy imageProxy){
|
|
||||||
if (imageProxy == null)
|
|
||||||
return null;
|
|
||||||
// Image Transformation
|
|
||||||
Mat imageMat = OpenCVHelper.extractYChannel(imageProxy);
|
|
||||||
// Show Input Image
|
|
||||||
if (inputImageView != null)
|
|
||||||
OpenCVHelper.debugMat(imageMat, inputImageView);
|
|
||||||
// Preprocess Image
|
|
||||||
Mat preprocessed = imageMat;
|
|
||||||
preprocessed = OpenCVHelper.addGaussianBlur(preprocessed, new Size(21, 21));
|
|
||||||
preprocessed = OpenCVHelper.addBlur(preprocessed, new Size(3, 3));
|
|
||||||
// Set Previous Image
|
|
||||||
if (previousImage == null) {
|
|
||||||
previousImage = preprocessed;
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
// Process Image
|
|
||||||
Mat processed = preprocessed.clone();
|
|
||||||
processed = OpenCVHelper.thresholdPixels(processed, previousImage, 25);
|
|
||||||
|
|
||||||
for(int i = 0; i < DILATE_ITERATIONS; i++)
|
|
||||||
processed = OpenCVHelper.dilateBinaryMat(processed, new Size(3,3));
|
|
||||||
|
|
||||||
processed = OpenCVHelper.thresholdContourArea(processed, AREA_THRESHOLD);
|
|
||||||
// Output
|
|
||||||
previousImage = preprocessed.clone();
|
|
||||||
// Show Output Image
|
|
||||||
if (outputImageView != null)
|
|
||||||
OpenCVHelper.debugMat(processed, outputImageView);
|
|
||||||
return processed;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/** Debug input and result of processing */
|
|
||||||
public void debugProcessing(@NonNull ImageView inputImageView, @NonNull ImageView outputImageView){
|
|
||||||
this.inputImageView = inputImageView;
|
|
||||||
this.outputImageView = outputImageView;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
private void setPreviewView(@NonNull PreviewView previewView) {
|
|
||||||
// Create Preview
|
|
||||||
if (this.preview != null)
|
|
||||||
this.preview.setSurfaceProvider(previewView.getSurfaceProvider());
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/** Generate File Name */
|
|
||||||
private String generateFileName(){
|
|
||||||
// Get the current timestamp
|
|
||||||
LocalDateTime currentTime = LocalDateTime.now();
|
|
||||||
// Define the format for the timestamp
|
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd_HHmmss");
|
|
||||||
// Return the timestamp as a string
|
|
||||||
return currentTime.format(formatter);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/** Get current Display Rotation */
|
|
||||||
private int getDisplayRotation() {
|
|
||||||
WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
|
|
||||||
Display display = windowManager.getDefaultDisplay();
|
|
||||||
return display.getRotation();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Start delay until Violation Report is allowed */
|
|
||||||
private void startViolationTimer(float setupTime) {
|
|
||||||
new CountDownTimer((long) (START_DELAY), 100) {
|
|
||||||
@Override
|
|
||||||
public void onTick(long millisUntilFinished) {
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onFinish() {
|
|
||||||
allowReportViolation = true;
|
|
||||||
}
|
|
||||||
}.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOutputDir(File outputDir) {
|
|
||||||
this.outputDir = outputDir;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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,113 +1,126 @@
|
|||||||
package com.example.ueberwachungssystem;
|
package com.example.ueberwachungssystem;
|
||||||
|
|
||||||
import static android.content.ContentValues.TAG;
|
import androidx.camera.core.ExperimentalGetImage;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.fragment.app.FragmentTransaction;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.net.wifi.WifiInfo;
|
|
||||||
import android.net.wifi.WifiManager;
|
|
||||||
import android.net.wifi.WifiInfo;
|
|
||||||
import android.net.wifi.WifiManager;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.widget.Toast;
|
|
||||||
import android.view.Menu;
|
|
||||||
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 {
|
||||||
|
//Fragmente
|
||||||
|
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
|
||||||
boolean communicationRunning = true;
|
private ToggleButton toggleKamera;
|
||||||
String dataRecieved;
|
private ToggleButton toggleAudio;
|
||||||
TextView textview1;
|
private ToggleButton toggleBewegung;
|
||||||
|
|
||||||
@Override
|
//Überprüfungswerte
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
boolean wahr;
|
||||||
super.onCreate(savedInstanceState);
|
private void log(String nachricht) {
|
||||||
setContentView(R.layout.activity_main);
|
Log.d(this.getClass().getSimpleName(), nachricht);
|
||||||
textview1 = findViewById(R.id.textView1);
|
}
|
||||||
|
|
||||||
Button button1 = findViewById(R.id.buttonSend);
|
|
||||||
button1.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
communication.sendTrue("Testmessage");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onResume();
|
super.onCreate(savedInstanceState);
|
||||||
if (communicationRunning){
|
setTitle(this.getClass().getSimpleName());
|
||||||
communication = new WifiCommunication(1234);
|
setContentView(R.layout.activity_main);
|
||||||
communication.setOnConnectionListener(new WifiCommunication.OnConnectionListener() {
|
Auswahl = findViewById(R.id.textAuswahl);
|
||||||
@Override
|
Auswahl.setText(auswahltext);
|
||||||
public void onConnection(StringBuffer data) {
|
AoderA = findViewById(R.id.textAoderA);
|
||||||
//Log.d("Test", data.toString());
|
AoderA.setText(auswahlAoderA);
|
||||||
runOnUiThread(new Runnable() {
|
toggleKamera = findViewById(R.id.toggleKamera);
|
||||||
@Override
|
toggleKamera.setOnClickListener(this);
|
||||||
public void run() {
|
toggleAudio = findViewById(R.id.toggleAudio);
|
||||||
textview1.setText(data);
|
toggleAudio.setOnClickListener(this);
|
||||||
}
|
toggleBewegung = findViewById(R.id.toggleBewegung);
|
||||||
});
|
toggleBewegung.setOnClickListener(this);
|
||||||
}
|
|
||||||
});
|
|
||||||
communicationRunning = false;
|
|
||||||
}
|
|
||||||
permission = new PermissionRequest(MainActivity.this);
|
|
||||||
permission.rechtePruefen();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (v == toggleKamera) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
//communication.stopCommunication();
|
communication.stopCommunication();
|
||||||
}
|
}
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
|
||||||
getMenuInflater().inflate(R.menu.options_menu, menu);
|
@Override
|
||||||
return true;
|
protected void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
communication = new WifiCommunication(1234);
|
||||||
}
|
}
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
|
||||||
Toast.makeText(this, "Selected Item: " + item.getTitle(), Toast.LENGTH_SHORT).show();
|
public void onClickZeigeFragment1(View view) {
|
||||||
PopUpClass popUpClass;
|
Button button = (Button) view;
|
||||||
switch (item.getItemId()) {
|
log(button.getText() + " ausgewählt");
|
||||||
case R.id.Rechteverwaltung:
|
zeigeFragment(fragment1.erstellen("Hier stehen dann die Alarme"));
|
||||||
popUpClass = new PopUpClass(MainActivity.this);
|
}
|
||||||
//popUpClass.showPopupWindow(tvMessages);
|
|
||||||
popUpClass.RechtePrüfen();
|
public void onClickZeigeFragment2(View view) {
|
||||||
return true;
|
Button button = (Button) view;
|
||||||
case R.id.Sensoren:
|
log(button.getText() + " ausgewählt");
|
||||||
popUpClass = new PopUpClass(MainActivity.this);
|
zeigeFragment(fragment2.erstellen("Hier stehen dann die Videos"));
|
||||||
//popUpClass.showPopupWindow(tvMessages);
|
}
|
||||||
popUpClass.Sensoren();
|
|
||||||
return true;
|
public void onClickEntferneFragment(View view) {
|
||||||
case R.id.Impressum:
|
entferneFragment();
|
||||||
popUpClass = new PopUpClass(MainActivity.this);
|
}
|
||||||
//popUpClass.showPopupWindow(tvMessages);
|
private void zeigeFragment(Fragment fragment) {
|
||||||
popUpClass.Impressum();
|
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
||||||
return true;
|
ft.replace(R.id.frame, fragment);
|
||||||
default:
|
ft.commit();
|
||||||
return super.onOptionsItemSelected(item);
|
aktuellesFragment = fragment;
|
||||||
|
}
|
||||||
|
private void entferneFragment() {
|
||||||
|
if (aktuellesFragment != null) {
|
||||||
|
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
||||||
|
ft.remove(aktuellesFragment);
|
||||||
|
ft.commit();
|
||||||
|
aktuellesFragment = null ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private String getLocalIpAddress() throws UnknownHostException {
|
}
|
||||||
WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService(WIFI_SERVICE);
|
|
||||||
assert wifiManager != null;
|
|
||||||
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
|
|
||||||
int ipInt = wifiInfo.getIpAddress();
|
|
||||||
return InetAddress.getByAddress(ByteBuffer.allocate(4).order(ByteOrder.LITTLE_ENDIAN).putInt(ipInt).array()).getHostAddress();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -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,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,13 +1,8 @@
|
|||||||
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 androidx.annotation.NonNull;
|
||||||
|
|
||||||
import com.example.ueberwachungssystem.Detection.DetectionReport;
|
|
||||||
import com.example.ueberwachungssystem.Detection.Detector;
|
|
||||||
import com.example.ueberwachungssystem.Detection.DetectorService;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.DatagramPacket;
|
import java.net.DatagramPacket;
|
||||||
import java.net.DatagramSocket;
|
import java.net.DatagramSocket;
|
||||||
|
|||||||
@@ -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>
|
||||||
@@ -1,53 +1,129 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout 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"
|
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_gravity="center"
|
android:background="#010C49"
|
||||||
android:gravity="top"
|
android:visibility="visible"
|
||||||
android:orientation="vertical"
|
tools:context="com.example.ueberwachungssystem.MainActivity"
|
||||||
tools:context=".MainActivity">
|
tools:visibility="visible">
|
||||||
|
|
||||||
|
|
||||||
<androidx.camera.view.PreviewView
|
|
||||||
android:id="@+id/previewView"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:backgroundTint="@android:color/black"/>
|
|
||||||
|
|
||||||
<ToggleButton
|
|
||||||
android:id="@+id/toggleButton"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="ToggleButton" />
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/inputImageView"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
tools:srcCompat="@tools:sample/avatars" />
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/outputImageView"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
tools:srcCompat="@tools:sample/avatars" />
|
|
||||||
|
|
||||||
<androidx.camera.view.PreviewView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/textView1"
|
android:id="@+id/textAuswahl"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="TextView" />
|
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_height="wrap_content"
|
||||||
|
android:layout_alignBottom="@id/toggleAudio"
|
||||||
|
android:layout_marginRight="30dp"
|
||||||
|
android:layout_toLeftOf="@id/toggleAudio"
|
||||||
|
android:textColor="@color/yellow"
|
||||||
|
android:textOn="Kamera an"
|
||||||
|
android:textOff="Kamera aus"
|
||||||
|
android:background="@drawable/toggle_btn"/>
|
||||||
|
|
||||||
|
<ToggleButton
|
||||||
|
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
|
<Button
|
||||||
android:id="@+id/buttonSend"
|
android:id="@+id/btnAlarme"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Button" />
|
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" />
|
||||||
|
|
||||||
</LinearLayout>
|
<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_height="match_parent"
|
||||||
|
android:layout_below="@+id/btnAufnahmen"
|
||||||
|
android:layout_marginTop="25dp"
|
||||||
|
android:layout_alignParentStart="true"
|
||||||
|
android:background="@color/white">
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
<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>
|
||||||
|
-->
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
@@ -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>
|
||||||
@@ -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>
|
||||||
@@ -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>
|
||||||
@@ -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>
|
||||||
@@ -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
@@ -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
|
||||||
}
|
}
|
||||||
+3
-1
@@ -18,4 +18,6 @@ android.useAndroidX=true
|
|||||||
# Enables namespacing of each library's R class so that its R class includes only the
|
# Enables namespacing of each library's R class so that its R class includes only the
|
||||||
# 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
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user