Compare commits
5 Commits
7e4e885fe0
...
2c9b2523a4
Author | SHA1 | Date | |
---|---|---|---|
2c9b2523a4 | |||
bd8371d96d | |||
b976e9ae32 | |||
0082602bea | |||
4b720c3a33 |
@ -29,6 +29,7 @@ public class DetectorService extends LifecycleService {
|
|||||||
|
|
||||||
public WifiCommunication wifiCommunication;
|
public WifiCommunication wifiCommunication;
|
||||||
|
|
||||||
|
|
||||||
String wifiData;
|
String wifiData;
|
||||||
StringBuffer stringBufferWifi = new StringBuffer();
|
StringBuffer stringBufferWifi = new StringBuffer();
|
||||||
|
|
||||||
@ -54,7 +55,6 @@ public class DetectorService extends LifecycleService {
|
|||||||
passToServiceListener(stringBufferWifi);
|
passToServiceListener(stringBufferWifi);
|
||||||
checkState(data);
|
checkState(data);
|
||||||
checkTyp(data);
|
checkTyp(data);
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -68,7 +68,16 @@ public class DetectorService extends LifecycleService {
|
|||||||
@Override
|
@Override
|
||||||
public void onDetection(@NonNull DetectionReport detectionReport) {
|
public void onDetection(@NonNull DetectionReport detectionReport) {
|
||||||
//passToServiceListener(detectionReport);
|
//passToServiceListener(detectionReport);
|
||||||
|
|
||||||
|
if(detectionReport.detectionState){
|
||||||
|
videoDetector.startRecording();
|
||||||
|
} else {
|
||||||
|
videoDetector.stopRecording();
|
||||||
|
}
|
||||||
|
|
||||||
wifiCommunication.sendTrue(detectionReport.toMessage());
|
wifiCommunication.sendTrue(detectionReport.toMessage());
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
/** Motion Detection**/
|
/** Motion Detection**/
|
||||||
|
@ -134,7 +134,7 @@ public class VideoDetector extends Detector {
|
|||||||
if (isRecording){
|
if (isRecording){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Toast.makeText(context, "video recording started", Toast.LENGTH_SHORT).show();
|
||||||
videoCapture = setupVideoCapture();
|
videoCapture = setupVideoCapture();
|
||||||
|
|
||||||
final ListenableFuture<ProcessCameraProvider> cameraProviderFuture = ProcessCameraProvider.getInstance(context);
|
final ListenableFuture<ProcessCameraProvider> cameraProviderFuture = ProcessCameraProvider.getInstance(context);
|
||||||
|
@ -0,0 +1,104 @@
|
|||||||
|
package com.example.ueberwachungssystem.Fragments;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.Gravity;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.MotionEvent;
|
||||||
|
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;
|
||||||
|
import android.widget.VideoView;
|
||||||
|
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
|
import com.example.ueberwachungssystem.R;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class VideoListFragment extends Fragment {
|
||||||
|
|
||||||
|
private ListView listView;
|
||||||
|
private Button button;
|
||||||
|
private ArrayAdapter<String> 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);
|
||||||
|
|
||||||
|
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
|
// Handle item click event here
|
||||||
|
String selectedItem = getContext().getFilesDir().toString() + "/" + adapter.getItem(position);
|
||||||
|
//Toast.makeText(requireContext(), selectedItem, Toast.LENGTH_SHORT).show();
|
||||||
|
|
||||||
|
openVideoPopup(selectedItem);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return rootView;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<String> getFileNames() {
|
||||||
|
// Add your data source here, e.g., an array or a list
|
||||||
|
File dir = getContext().getFilesDir();
|
||||||
|
File[] files = dir.listFiles();
|
||||||
|
Log.d("files", getContext().getFilesDir().toString());
|
||||||
|
|
||||||
|
|
||||||
|
List<String> fileNamesList = new ArrayList<>();
|
||||||
|
assert files != null;
|
||||||
|
for (File file : files) {
|
||||||
|
fileNamesList.add(file.getName());
|
||||||
|
}
|
||||||
|
return fileNamesList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void openVideoPopup(String videoPath) {
|
||||||
|
LayoutInflater inflater = LayoutInflater.from(requireContext());
|
||||||
|
View popupView = inflater.inflate(R.layout.videolist_popup, null);
|
||||||
|
|
||||||
|
VideoView videoView = popupView.findViewById(R.id.videoView);
|
||||||
|
videoView.setVideoPath(videoPath);
|
||||||
|
videoView.start();
|
||||||
|
|
||||||
|
PopupWindow popupWindow = new PopupWindow(popupView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, true);
|
||||||
|
|
||||||
|
popupView.setOnTouchListener(new View.OnTouchListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onTouch(View v, MotionEvent event) {
|
||||||
|
//Close the window when clicked
|
||||||
|
popupWindow.dismiss();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
popupWindow.showAtLocation(listView, Gravity.CENTER, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
@ -25,6 +25,7 @@ import com.example.ueberwachungssystem.Fragments.Fragment1;
|
|||||||
import com.example.ueberwachungssystem.Fragments.Fragment2;
|
import com.example.ueberwachungssystem.Fragments.Fragment2;
|
||||||
import com.example.ueberwachungssystem.Detection.DetectorService;
|
import com.example.ueberwachungssystem.Detection.DetectorService;
|
||||||
import com.example.ueberwachungssystem.Fragments.Fragment3;
|
import com.example.ueberwachungssystem.Fragments.Fragment3;
|
||||||
|
import com.example.ueberwachungssystem.Fragments.VideoListFragment;
|
||||||
|
|
||||||
@ExperimentalGetImage
|
@ExperimentalGetImage
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
@ -36,8 +37,9 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
private Fragment1 fragment1;
|
private Fragment1 fragment1;
|
||||||
private Fragment2 fragment2;
|
private Fragment2 fragment2;
|
||||||
private Fragment3 fragment3;
|
private Fragment3 fragment3;
|
||||||
|
private VideoListFragment videoListFragment = new VideoListFragment();
|
||||||
private DetectorService detectorService = new DetectorService();
|
private DetectorService detectorService = new DetectorService();
|
||||||
int num=0;
|
int num = 0;
|
||||||
//Textviews
|
//Textviews
|
||||||
private TextView Auswahl;
|
private TextView Auswahl;
|
||||||
private TextView AoderA;
|
private TextView AoderA;
|
||||||
@ -185,7 +187,8 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
public void onClickZeigeFragment2(View view) {
|
public void onClickZeigeFragment2(View view) {
|
||||||
Button button = (Button) view;
|
Button button = (Button) view;
|
||||||
zeigeFragment(fragment2.erstellen("Hier stehen dann die Videos"));
|
//zeigeFragment(fragment2.erstellen("Hier stehen dann die Videos"));
|
||||||
|
zeigeFragment(videoListFragment);
|
||||||
}
|
}
|
||||||
public void onClickZeigeFragment3(View view) {
|
public void onClickZeigeFragment3(View view) {
|
||||||
Button button = (Button) view;
|
Button button = (Button) view;
|
||||||
|
@ -125,5 +125,9 @@
|
|||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
-->
|
-->
|
||||||
|
<ListView
|
||||||
|
android:id = "@+id/listView"
|
||||||
|
android:layout_width = "wrap_content"
|
||||||
|
android:layout_height = "wrap_content"/>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
28
app/src/main/res/layout/videolist_fragment.xml
Normal file
28
app/src/main/res/layout/videolist_fragment.xml
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.appcompat.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:background="@android:color/holo_blue_light">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/button"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Aufnahmen Löschen"
|
||||||
|
android:backgroundTint="#010C49"
|
||||||
|
tools:ignore="MissingConstraints" />
|
||||||
|
|
||||||
|
<ListView
|
||||||
|
android:id="@+id/listView"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
tools:ignore="MissingConstraints"
|
||||||
|
tools:layout_editor_absoluteX="0dp"
|
||||||
|
tools:layout_editor_absoluteY="0dp" />
|
||||||
|
|
||||||
|
|
||||||
|
</androidx.appcompat.widget.LinearLayoutCompat>
|
12
app/src/main/res/layout/videolist_popup.xml
Normal file
12
app/src/main/res/layout/videolist_popup.xml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<VideoView
|
||||||
|
android:id="@+id/videoView"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="center"/>
|
||||||
|
|
||||||
|
</FrameLayout>
|
Loading…
x
Reference in New Issue
Block a user