diff --git a/app/src/main/java/com/example/ueberwachungssystem/Detection/DetectorService.java b/app/src/main/java/com/example/ueberwachungssystem/Detection/DetectorService.java index 9c6d626..fd8faf3 100644 --- a/app/src/main/java/com/example/ueberwachungssystem/Detection/DetectorService.java +++ b/app/src/main/java/com/example/ueberwachungssystem/Detection/DetectorService.java @@ -73,7 +73,20 @@ public class DetectorService extends LifecycleService { @Override public void onDetection(@NonNull DetectionReport detectionReport) { //passToServiceListener(detectionReport); + + if(detectionReport.detectionState){ + detectedVideo = true; + videoDetector.startRecording(); + } else { + detectedVideo = false; + if(!(detectedVideo || detectedAudio || detectedMotion)) { + videoDetector.stopRecording(); + } + } + wifiCommunication.sendTrue(detectionReport.toMessage()); + + } }); /** Motion Detection**/ diff --git a/app/src/main/java/com/example/ueberwachungssystem/Detection/VideoDetector.java b/app/src/main/java/com/example/ueberwachungssystem/Detection/VideoDetector.java index 75ca0fb..5176505 100644 --- a/app/src/main/java/com/example/ueberwachungssystem/Detection/VideoDetector.java +++ b/app/src/main/java/com/example/ueberwachungssystem/Detection/VideoDetector.java @@ -134,7 +134,7 @@ public class VideoDetector extends Detector { if (isRecording){ return; } - + Toast.makeText(context, "video recording started", Toast.LENGTH_SHORT).show(); videoCapture = setupVideoCapture(); final ListenableFuture cameraProviderFuture = ProcessCameraProvider.getInstance(context); diff --git a/app/src/main/java/com/example/ueberwachungssystem/Fragments/VideoListFragment.java b/app/src/main/java/com/example/ueberwachungssystem/Fragments/VideoListFragment.java index 74546fe..531f387 100644 --- a/app/src/main/java/com/example/ueberwachungssystem/Fragments/VideoListFragment.java +++ b/app/src/main/java/com/example/ueberwachungssystem/Fragments/VideoListFragment.java @@ -9,6 +9,7 @@ import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.ArrayAdapter; +import android.widget.Button; import android.widget.ListView; import android.widget.PopupWindow; import android.widget.Toast; @@ -25,12 +26,28 @@ import java.util.List; public class VideoListFragment extends Fragment { private ListView listView; + private Button button; private ArrayAdapter adapter; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.videolist_fragment, container, false); + + button = rootView.findViewById(R.id.button); + button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + File dir = getContext().getFilesDir(); + File[] files = dir.listFiles(); + for (File file: files) { + file.delete(); + } + } + }); + + + listView = rootView.findViewById(R.id.listView); adapter = new ArrayAdapter<>(requireContext(), android.R.layout.simple_list_item_1, getFileNames()); listView.setAdapter(adapter); diff --git a/app/src/main/res/layout/videolist_fragment.xml b/app/src/main/res/layout/videolist_fragment.xml index b31a228..4da0c31 100644 --- a/app/src/main/res/layout/videolist_fragment.xml +++ b/app/src/main/res/layout/videolist_fragment.xml @@ -1,5 +1,6 @@ +