Compare commits
No commits in common. "1eba8e0f7c6f4edd841fb6f57650170e0877e5a5" and "94970885cf2c82439e7b401da4c0ed1126966e4f" have entirely different histories.
1eba8e0f7c
...
94970885cf
@ -1,13 +1,8 @@
|
|||||||
package com.example.ueberwachungssystem.Detection;
|
package com.example.ueberwachungssystem.Detection;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.example.ueberwachungssystem.WifiCommunication;
|
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/** Detection Report Class */
|
/** Detection Report Class */
|
||||||
public class DetectionReport {
|
public class DetectionReport {
|
||||||
@ -17,11 +12,7 @@ public class DetectionReport {
|
|||||||
public boolean detectionState;
|
public boolean detectionState;
|
||||||
|
|
||||||
public DetectionReport(boolean detectionState, String detectionType, float detectedAmplitude) {
|
public DetectionReport(boolean detectionState, String detectionType, float detectedAmplitude) {
|
||||||
// New Date Format
|
this.timeStamp = String.valueOf(Calendar.getInstance().getTime());
|
||||||
@SuppressLint("SimpleDateFormat") SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
|
|
||||||
Date curDate = new Date(System.currentTimeMillis());
|
|
||||||
this.timeStamp = formatter.format(curDate);
|
|
||||||
//Old Date Format: this.timeStamp = String.valueOf(Calendar.getInstance().getTime());
|
|
||||||
this.detectionType = detectionType;
|
this.detectionType = detectionType;
|
||||||
this.detectedValue = detectedAmplitude;
|
this.detectedValue = detectedAmplitude;
|
||||||
this.detectionState = detectionState;
|
this.detectionState = detectionState;
|
||||||
@ -40,16 +31,6 @@ public class DetectionReport {
|
|||||||
return String.join("\t", state, time, type, value);
|
return String.join("\t", state, time, type, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toMessage() {
|
|
||||||
String state;
|
|
||||||
if(detectionState)
|
|
||||||
state = "An";
|
|
||||||
else
|
|
||||||
state = "Aus";
|
|
||||||
|
|
||||||
return String.join(",", "1", timeStamp, "Gruppe2", WifiCommunication.getLocalIpAddress(), state, detectionType, String.valueOf(detectedValue));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Debug Report */
|
/** Debug Report */
|
||||||
public void log(String tag) {
|
public void log(String tag) {
|
||||||
Log.d(tag, this.toString());
|
Log.d(tag, this.toString());
|
||||||
|
@ -3,13 +3,17 @@ package com.example.ueberwachungssystem.Detection;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
|
import android.util.Log;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.camera.core.ExperimentalGetImage;
|
import androidx.camera.core.ExperimentalGetImage;
|
||||||
import androidx.lifecycle.LifecycleService;
|
import androidx.lifecycle.LifecycleService;
|
||||||
|
|
||||||
|
import com.example.ueberwachungssystem.WifiCommunication;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
@ExperimentalGetImage
|
@ExperimentalGetImage
|
||||||
@ -18,12 +22,14 @@ public class DetectorService extends LifecycleService {
|
|||||||
private DetectorService.OnDetectionListener listener;
|
private DetectorService.OnDetectionListener listener;
|
||||||
private boolean isServiceRunning = false;
|
private boolean isServiceRunning = false;
|
||||||
|
|
||||||
// Used Objects:
|
VideoDetector videoDetector = null;
|
||||||
public VideoDetector videoDetector = null;
|
AudioRecorder audioRecorder = null;
|
||||||
public AudioRecorder audioRecorder = null;
|
|
||||||
public Accelerometer motionDetector = null;
|
|
||||||
public MicrophoneDetector audioDetector = null;
|
|
||||||
|
|
||||||
|
/** Communication **/
|
||||||
|
|
||||||
|
WifiCommunication wifiCommunication;
|
||||||
|
|
||||||
|
StringBuffer dataFromWifi;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||||
@ -31,9 +37,7 @@ public class DetectorService extends LifecycleService {
|
|||||||
return START_NOT_STICKY;
|
return START_NOT_STICKY;
|
||||||
|
|
||||||
|
|
||||||
|
// Setup Service classes:
|
||||||
|
|
||||||
/** Video Detection/Recorder **/
|
|
||||||
videoDetector = new VideoDetector(this);
|
videoDetector = new VideoDetector(this);
|
||||||
videoDetector.setOnDetectionListener(new Detector.OnDetectionListener() {
|
videoDetector.setOnDetectionListener(new Detector.OnDetectionListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -41,35 +45,22 @@ public class DetectorService extends LifecycleService {
|
|||||||
passToServiceListener(detectionReport);
|
passToServiceListener(detectionReport);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
/** Motion Detection**/
|
|
||||||
motionDetector = new Accelerometer(this);
|
|
||||||
motionDetector.getSensor();
|
|
||||||
motionDetector.setOnDetectionListener(new Detector.OnDetectionListener() {
|
|
||||||
@Override
|
|
||||||
public void onDetection(@NonNull DetectionReport detectionReport) {
|
|
||||||
passToServiceListener(detectionReport);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
/** Audio Detection **/
|
|
||||||
audioDetector = new MicrophoneDetector(this);
|
|
||||||
audioDetector.setOnDetectionListener(new Detector.OnDetectionListener() {
|
|
||||||
@Override
|
|
||||||
public void onDetection(@NonNull DetectionReport detectionReport) {
|
|
||||||
passToServiceListener(detectionReport);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
/** Audio Recorder**/
|
|
||||||
audioRecorder = new AudioRecorder(this);
|
audioRecorder = new AudioRecorder(this);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
isServiceRunning = true;
|
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);
|
return super.onStartCommand(intent, flags, startId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
@ -91,7 +82,81 @@ public class DetectorService extends LifecycleService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Pass Detection Report to Service Detection Listener and trigger it */
|
/** 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) {
|
public void passToServiceListener(DetectionReport detectionReport) {
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
listener.onDetection(detectionReport);
|
listener.onDetection(detectionReport);
|
||||||
|
@ -42,6 +42,8 @@ import java.util.concurrent.ExecutionException;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Video Detector inherits some methods from abstract Detector class (more info there)
|
* Video Detector inherits some methods from abstract Detector class (more info there)
|
||||||
|
* USE FROM MAIN ACTIVITY:
|
||||||
|
* VideoDetector vd = new VideoDetector(this);
|
||||||
* */
|
* */
|
||||||
|
|
||||||
|
|
||||||
@ -173,10 +175,7 @@ public class VideoDetector extends Detector {
|
|||||||
public void stopDetection() {
|
public void stopDetection() {
|
||||||
if (!isDetecting || imageAnalysis == null)
|
if (!isDetecting || imageAnalysis == null)
|
||||||
return;
|
return;
|
||||||
if (!isRecording)
|
cameraProvider.unbind(imageAnalysis);
|
||||||
cameraProvider.unbindAll();
|
|
||||||
else
|
|
||||||
cameraProvider.unbind(imageAnalysis);
|
|
||||||
isDetecting = false;
|
isDetecting = false;
|
||||||
allowReportViolation = false;
|
allowReportViolation = false;
|
||||||
}
|
}
|
||||||
@ -188,11 +187,7 @@ public class VideoDetector extends Detector {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
videoCapture.stopRecording();
|
videoCapture.stopRecording();
|
||||||
|
cameraProvider.unbind(videoCapture);
|
||||||
if (!isDetecting())
|
|
||||||
cameraProvider.unbindAll();
|
|
||||||
else
|
|
||||||
cameraProvider.unbind(videoCapture);
|
|
||||||
isRecording = false;
|
isRecording = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,10 +219,10 @@ public class VideoDetector extends Detector {
|
|||||||
|
|
||||||
int n = OpenCVHelper.countNonZeroPixels(processed);
|
int n = OpenCVHelper.countNonZeroPixels(processed);
|
||||||
int pixelCount = image.getWidth() * image.getHeight();
|
int pixelCount = image.getWidth() * image.getHeight();
|
||||||
float percentChanged = ((float) n / pixelCount) * 100;
|
float percentChanged = (float) n / pixelCount;
|
||||||
|
|
||||||
// Violation Condition
|
// Violation Condition
|
||||||
if (percentChanged> ALARM_THRESHOLD) {
|
if (percentChanged * 100 > ALARM_THRESHOLD) {
|
||||||
if (allowReportViolation)
|
if (allowReportViolation)
|
||||||
reportViolation("Video", percentChanged);
|
reportViolation("Video", percentChanged);
|
||||||
}
|
}
|
||||||
@ -315,7 +310,7 @@ public class VideoDetector extends Detector {
|
|||||||
|
|
||||||
/** Start delay until Violation Report is allowed */
|
/** Start delay until Violation Report is allowed */
|
||||||
private void startViolationTimer(float setupTime) {
|
private void startViolationTimer(float setupTime) {
|
||||||
new CountDownTimer((long) (setupTime), 100) {
|
new CountDownTimer((long) (START_DELAY), 100) {
|
||||||
@Override
|
@Override
|
||||||
public void onTick(long millisUntilFinished) {
|
public void onTick(long millisUntilFinished) {
|
||||||
}
|
}
|
||||||
|
@ -1,114 +1,126 @@
|
|||||||
package com.example.ueberwachungssystem;
|
package com.example.ueberwachungssystem;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
|
||||||
import androidx.camera.core.ExperimentalGetImage;
|
import androidx.camera.core.ExperimentalGetImage;
|
||||||
import androidx.camera.view.PreviewView;
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.fragment.app.FragmentTransaction;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
import android.content.ComponentName;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.ServiceConnection;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.IBinder;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ImageView;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.ScrollView;
|
||||||
|
import android.widget.TextView;
|
||||||
import android.widget.ToggleButton;
|
import android.widget.ToggleButton;
|
||||||
|
|
||||||
import com.example.ueberwachungssystem.Detection.Accelerometer;
|
|
||||||
import com.example.ueberwachungssystem.Detection.AudioRecorder;
|
|
||||||
import com.example.ueberwachungssystem.Detection.DetectionReport;
|
import com.example.ueberwachungssystem.Detection.DetectionReport;
|
||||||
import com.example.ueberwachungssystem.Detection.Detector;
|
import com.example.ueberwachungssystem.Detection.Detector;
|
||||||
import com.example.ueberwachungssystem.Detection.DetectorService;
|
|
||||||
import com.example.ueberwachungssystem.Detection.MicrophoneDetector;
|
|
||||||
import com.example.ueberwachungssystem.Detection.VideoDetector;
|
import com.example.ueberwachungssystem.Detection.VideoDetector;
|
||||||
|
import com.example.ueberwachungssystem.Fragments.Fragment1;
|
||||||
|
import com.example.ueberwachungssystem.Fragments.Fragment2;
|
||||||
|
import com.example.ueberwachungssystem.Fragments.Fragment3;
|
||||||
|
|
||||||
|
import org.w3c.dom.Text;
|
||||||
|
|
||||||
@ExperimentalGetImage
|
@ExperimentalGetImage
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
|
||||||
|
private Fragment aktuellesFragment;
|
||||||
|
private Fragment1 fragment1;
|
||||||
|
private Fragment2 fragment2;
|
||||||
|
private Fragment3 fragment3;
|
||||||
|
|
||||||
private DetectorService detectorService = new DetectorService();
|
WifiCommunication communication;
|
||||||
ImageView inputImageView;
|
private TextView alarm;
|
||||||
ImageView outputImageView;
|
private String text = "Das ist ein Alarm des Sensors";
|
||||||
ToggleButton toggleButton;
|
//Buttons
|
||||||
|
private ToggleButton toggleKamera;
|
||||||
|
private ToggleButton btnAudio;
|
||||||
|
private ToggleButton btnBewegung;
|
||||||
|
//Detektoren
|
||||||
|
VideoDetector vd = new VideoDetector(this);
|
||||||
|
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);
|
||||||
|
alarm = findViewById(R.id.Alarm);
|
||||||
|
alarm.setText(text);
|
||||||
|
toggleKamera = findViewById(R.id.toggleKamera);
|
||||||
|
toggleKamera.setOnClickListener(this);
|
||||||
|
vd.setOnDetectionListener(new Detector.OnDetectionListener() {
|
||||||
|
@Override
|
||||||
|
public void onDetection(@NonNull DetectionReport detectionReport) {
|
||||||
|
DetectionReport dr = detectionReport;
|
||||||
|
String drString = dr.toString();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//boolean isRunning = vd.isRunning();
|
||||||
|
|
||||||
inputImageView = findViewById(R.id.inputImageView);
|
}
|
||||||
outputImageView = findViewById(R.id.outputImageView);
|
@Override
|
||||||
toggleButton = findViewById(R.id.toggleButton);
|
public void onClick(View v) {
|
||||||
|
if (v == toggleKamera) {
|
||||||
|
if (toggleKamera.isChecked()) {
|
||||||
PermissionHandler permissionHandler = new PermissionHandler(this);
|
vd.startDetection();
|
||||||
permissionHandler.getPermissions();
|
} else {
|
||||||
if (permissionHandler.hasPermissions()) {
|
vd.stopDetection();
|
||||||
|
}
|
||||||
|
|
||||||
Intent serviceIntent = new Intent(this, DetectorService.class);
|
|
||||||
bindService(serviceIntent, serviceConnection, Context.BIND_AUTO_CREATE);
|
|
||||||
startService(serviceIntent);
|
|
||||||
|
|
||||||
|
|
||||||
toggleButton.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
if (toggleButton.isChecked())
|
|
||||||
{
|
|
||||||
if (detectorService != null){
|
|
||||||
|
|
||||||
detectorService.videoDetector.debugProcessing(inputImageView, outputImageView);
|
|
||||||
detectorService.videoDetector.startDetection();
|
|
||||||
|
|
||||||
detectorService.audioDetector.startDetection();
|
|
||||||
|
|
||||||
detectorService.motionDetector.startDetection();
|
|
||||||
|
|
||||||
detectorService.audioRecorder.stopRecording();
|
|
||||||
|
|
||||||
detectorService.videoDetector.startRecording();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
detectorService.videoDetector.stopDetection();
|
|
||||||
|
|
||||||
detectorService.audioDetector.stopDetection();
|
|
||||||
|
|
||||||
detectorService.motionDetector.stopDetection();
|
|
||||||
|
|
||||||
detectorService.audioRecorder.stopRecording();
|
|
||||||
|
|
||||||
detectorService.videoDetector.stopRecording();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ServiceConnection serviceConnection = new ServiceConnection() {
|
@Override
|
||||||
@Override
|
protected void onPause() {
|
||||||
public void onServiceConnected(ComponentName name, IBinder service) {
|
super.onPause();
|
||||||
DetectorService.ServiceBinder binder = (DetectorService.ServiceBinder) service;
|
communication.stopCommunication();
|
||||||
detectorService = binder.getBoundService();
|
}
|
||||||
|
|
||||||
detectorService.setOnDetectionListener(new DetectorService.OnDetectionListener() {
|
@Override
|
||||||
@Override
|
protected void onResume() {
|
||||||
public void onDetection(@NonNull DetectionReport detectionReport) {
|
super.onResume();
|
||||||
Log.d("onDetection", detectionReport.toMessage());
|
communication = new WifiCommunication(1234);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
public void onClickZeigeFragment1(View view) {
|
||||||
|
Button button = (Button) view;
|
||||||
|
log(button.getText() + " ausgewählt");
|
||||||
|
zeigeFragment(fragment1.erstellen("Fragment 1 wurde angeklickt"));
|
||||||
|
}
|
||||||
|
public void onClickZeigeFragment2(View view) {
|
||||||
|
Button button = (Button) view;
|
||||||
|
log(button.getText() + " ausgewählt");
|
||||||
|
zeigeFragment(fragment2.erstellen("Fragment 2 wurde angeklickt"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onClickZeigeFragment3(View view) {
|
||||||
|
Button button = (Button) view;
|
||||||
|
log(button.getText() + " ausgewählt");
|
||||||
|
zeigeFragment(fragment3.erstellen("Fragment 3 wurde angeklickt"));
|
||||||
|
}
|
||||||
|
|
||||||
|
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 ;
|
||||||
}
|
}
|
||||||
@Override
|
}
|
||||||
public void onServiceDisconnected(ComponentName name) {}
|
|
||||||
};
|
|
||||||
}
|
}
|
@ -1,41 +1,123 @@
|
|||||||
<?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="@android:color/holo_green_dark"
|
||||||
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
|
<ToggleButton
|
||||||
android:id="@+id/toggleButton"
|
android:id="@+id/toggleKamera"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignBottom="@id/toggleAudio"
|
||||||
|
android:layout_marginRight="15dp"
|
||||||
|
android:layout_toStartOf="@+id/toggleAudio"
|
||||||
|
android:layout_toLeftOf="@id/toggleAudio"
|
||||||
|
android:text="Kamera" />
|
||||||
|
|
||||||
|
<ToggleButton
|
||||||
|
android:id="@+id/toggleAudio"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentTop="true"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:text="Audio" />
|
||||||
|
|
||||||
|
<ToggleButton
|
||||||
|
android:id="@+id/toggleBewegung"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignBottom="@id/toggleAudio"
|
||||||
|
android:layout_marginLeft="15dp"
|
||||||
|
android:layout_toEndOf="@+id/toggleAudio"
|
||||||
|
android:layout_toRightOf="@id/toggleAudio"
|
||||||
|
android:text="Bewegung" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btnAudio"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignBottom="@id/btnKamera"
|
||||||
|
android:layout_marginRight="15dp"
|
||||||
|
android:layout_toStartOf="@+id/btnKamera"
|
||||||
|
android:onClick="onClickZeigeFragment1"
|
||||||
|
android:text="Audio" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btnKamera"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@id/toggleAudio"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:onClick="onClickZeigeFragment2"
|
||||||
|
android:text="Kamera" />
|
||||||
|
|
||||||
|
<!--
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btnSensorWeg"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_below="@+id/btn1"
|
||||||
|
android:text="Entferne Sensordarstellung"
|
||||||
|
android:onClick="onClickEntferneFragment"/>
|
||||||
|
-->
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btnBewegung"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignBottom="@id/btnKamera"
|
||||||
|
android:layout_marginLeft="15dp"
|
||||||
|
android:layout_toEndOf="@+id/btnKamera"
|
||||||
|
android:layout_toRightOf="@id/btnKamera"
|
||||||
|
android:onClick="onClickZeigeFragment3"
|
||||||
|
android:text="Bewegung" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btnAufnahme"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@+id/btnKamera"
|
||||||
|
android:layout_toLeftOf="@id/btnKamera"
|
||||||
|
android:layout_marginRight="15dp"
|
||||||
|
android:onClick="onClickEntferneFragment"
|
||||||
|
android:text="Aufnahme" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btnWiedergabe"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@+id/btnKamera"
|
||||||
|
android:layout_toRightOf="@id/btnKamera"
|
||||||
|
android:layout_marginLeft="15dp"
|
||||||
|
android:onClick="onClickEntferneFragment"
|
||||||
|
android:text="Wiedergabe" />
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/frame"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="200dp"
|
||||||
android:text="ToggleButton" />
|
android:layout_below="@+id/btnAufnahme"
|
||||||
|
android:layout_alignParentStart="true">
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
<ImageView
|
<ScrollView
|
||||||
android:id="@+id/inputImageView"
|
android:id= "@+id/scrollView1"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width= "wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height= "wrap_content"
|
||||||
tools:srcCompat="@tools:sample/avatars" />
|
android:layout_below= "@id/frame">
|
||||||
|
<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" />
|
||||||
|
</LinearLayout>
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
<ImageView
|
</RelativeLayout>
|
||||||
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" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
Loading…
x
Reference in New Issue
Block a user