|
|
|
|
|
|
|
|
import androidx.fragment.app.FragmentTransaction; |
|
|
import androidx.fragment.app.FragmentTransaction; |
|
|
import androidx.annotation.NonNull; |
|
|
import androidx.annotation.NonNull; |
|
|
import androidx.appcompat.app.AppCompatActivity; |
|
|
import androidx.appcompat.app.AppCompatActivity; |
|
|
import androidx.camera.core.ExperimentalGetImage; |
|
|
|
|
|
import androidx.camera.view.PreviewView; |
|
|
|
|
|
|
|
|
|
|
|
import android.content.ComponentName; |
|
|
import android.content.ComponentName; |
|
|
import android.content.Context; |
|
|
import android.content.Context; |
|
|
|
|
|
|
|
|
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.ImageView; |
|
|
|
|
|
import android.widget.Toast; |
|
|
import android.widget.Toast; |
|
|
import android.widget.ToggleButton; |
|
|
import android.widget.ToggleButton; |
|
|
|
|
|
|
|
|
import com.example.ueberwachungssystem.Fragments.Fragment1; |
|
|
import com.example.ueberwachungssystem.Fragments.Fragment1; |
|
|
import com.example.ueberwachungssystem.Fragments.Fragment2; |
|
|
import com.example.ueberwachungssystem.Fragments.Fragment2; |
|
|
import com.example.ueberwachungssystem.Detection.Accelerometer; |
|
|
|
|
|
import com.example.ueberwachungssystem.Detection.AudioRecorder; |
|
|
|
|
|
import com.example.ueberwachungssystem.Detection.DetectionReport; |
|
|
|
|
|
import com.example.ueberwachungssystem.Detection.Detector; |
|
|
|
|
|
import com.example.ueberwachungssystem.Detection.DetectorService; |
|
|
import com.example.ueberwachungssystem.Detection.DetectorService; |
|
|
import com.example.ueberwachungssystem.Detection.MicrophoneDetector; |
|
|
|
|
|
import com.example.ueberwachungssystem.Detection.VideoDetector; |
|
|
|
|
|
|
|
|
|
|
|
@ExperimentalGetImage |
|
|
@ExperimentalGetImage |
|
|
public class MainActivity extends AppCompatActivity implements View.OnClickListener { |
|
|
|
|
|
|
|
|
public class MainActivity extends AppCompatActivity { |
|
|
//Fragmente |
|
|
//Fragmente |
|
|
private Fragment aktuellesFragment; |
|
|
private Fragment aktuellesFragment; |
|
|
private Fragment1 fragment1; |
|
|
private Fragment1 fragment1; |
|
|
|
|
|
|
|
|
AoderA = findViewById(R.id.textAoderA); |
|
|
AoderA = findViewById(R.id.textAoderA); |
|
|
AoderA.setText(auswahlAoderA); |
|
|
AoderA.setText(auswahlAoderA); |
|
|
toggleKamera = findViewById(R.id.toggleKamera); |
|
|
toggleKamera = findViewById(R.id.toggleKamera); |
|
|
toggleKamera.setOnClickListener(this); |
|
|
|
|
|
toggleAudio = findViewById(R.id.toggleAudio); |
|
|
toggleAudio = findViewById(R.id.toggleAudio); |
|
|
toggleAudio.setOnClickListener(this); |
|
|
|
|
|
toggleBewegung = findViewById(R.id.toggleBewegung); |
|
|
toggleBewegung = findViewById(R.id.toggleBewegung); |
|
|
toggleBewegung.setOnClickListener(this); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
@Override |
|
|
|
|
|
public void onClick(View v) { |
|
|
|
|
|
if (v == toggleKamera) { |
|
|
|
|
|
if (toggleKamera.isChecked()) { |
|
|
|
|
|
vd.startDetection(); |
|
|
|
|
|
} else { |
|
|
|
|
|
vd.stopDetection(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
|
|
|
|
|
|
bindService(serviceIntent, serviceConnection, Context.BIND_AUTO_CREATE); |
|
|
bindService(serviceIntent, serviceConnection, Context.BIND_AUTO_CREATE); |
|
|
startService(serviceIntent); |
|
|
startService(serviceIntent); |
|
|
|
|
|
|
|
|
toggleButton.setOnClickListener(new View.OnClickListener() { |
|
|
|
|
|
|
|
|
toggleKamera.setOnClickListener(new View.OnClickListener() { |
|
|
@Override |
|
|
@Override |
|
|
public void onClick(View v) { |
|
|
public void onClick(View v) { |
|
|
if (toggleButton.isChecked()) |
|
|
|
|
|
{ |
|
|
|
|
|
if (detectorService != null){ |
|
|
|
|
|
|
|
|
|
|
|
detectorService.videoDetector.startDetection(); |
|
|
|
|
|
|
|
|
|
|
|
detectorService.audioDetector.startDetection(); |
|
|
|
|
|
|
|
|
if (toggleKamera.isChecked()) { |
|
|
|
|
|
|
|
|
detectorService.motionDetector.startDetection(); |
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
|
detectorService.audioRecorder.stopRecording(); |
|
|
|
|
|
|
|
|
|
|
|
detectorService.videoDetector.startRecording(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
else { |
|
|
|
|
|
detectorService.videoDetector.stopDetection(); |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
toggleAudio.setOnClickListener(new View.OnClickListener() { |
|
|
|
|
|
@Override |
|
|
|
|
|
public void onClick(View v) { |
|
|
|
|
|
if (toggleAudio.isChecked()) { |
|
|
|
|
|
|
|
|
detectorService.audioDetector.stopDetection(); |
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
|
detectorService.motionDetector.stopDetection(); |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
toggleBewegung.setOnClickListener(new View.OnClickListener() { |
|
|
|
|
|
@Override |
|
|
|
|
|
public void onClick(View v) { |
|
|
|
|
|
if (toggleBewegung.isChecked()) { |
|
|
|
|
|
|
|
|
detectorService.audioRecorder.stopRecording(); |
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
|
detectorService.videoDetector.stopRecording(); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
switch (item.getItemId()) { |
|
|
switch (item.getItemId()) { |
|
|
case R.id.Rechteverwaltung: |
|
|
case R.id.Rechteverwaltung: |
|
|
popUpClass = new PopUpClass(MainActivity.this); |
|
|
popUpClass = new PopUpClass(MainActivity.this); |
|
|
popUpClass.showPopupWindow(inputImageView); |
|
|
|
|
|
|
|
|
popUpClass.showPopupWindow(toggleAudio); |
|
|
popUpClass.RechtePrüfen(); |
|
|
popUpClass.RechtePrüfen(); |
|
|
return true; |
|
|
return true; |
|
|
case R.id.Sensoren: |
|
|
case R.id.Sensoren: |
|
|
popUpClass = new PopUpClass(MainActivity.this); |
|
|
popUpClass = new PopUpClass(MainActivity.this); |
|
|
popUpClass.showPopupWindow(inputImageView); |
|
|
|
|
|
|
|
|
popUpClass.showPopupWindow(toggleAudio); |
|
|
popUpClass.Sensoren(); |
|
|
popUpClass.Sensoren(); |
|
|
return true; |
|
|
return true; |
|
|
case R.id.Impressum: |
|
|
case R.id.Impressum: |
|
|
popUpClass = new PopUpClass(MainActivity.this); |
|
|
popUpClass = new PopUpClass(MainActivity.this); |
|
|
popUpClass.showPopupWindow(inputImageView); |
|
|
|
|
|
|
|
|
popUpClass.showPopupWindow(toggleAudio); |
|
|
popUpClass.Impressum(); |
|
|
popUpClass.Impressum(); |
|
|
return true; |
|
|
return true; |
|
|
case R.id.Detection: |
|
|
case R.id.Detection: |
|
|
popUpClass = new PopUpClass(MainActivity.this); |
|
|
popUpClass = new PopUpClass(MainActivity.this); |
|
|
popUpClass.showPopupWindow(inputImageView); |
|
|
|
|
|
|
|
|
popUpClass.showPopupWindow(toggleAudio); |
|
|
popUpClass.DetectionTotal(num); |
|
|
popUpClass.DetectionTotal(num); |
|
|
return true; |
|
|
return true; |
|
|
default: |
|
|
default: |
|
|
|
|
|
|
|
|
public void onServiceConnected(ComponentName name, IBinder service) { |
|
|
public void onServiceConnected(ComponentName name, IBinder service) { |
|
|
DetectorService.ServiceBinder binder = (DetectorService.ServiceBinder) service; |
|
|
DetectorService.ServiceBinder binder = (DetectorService.ServiceBinder) service; |
|
|
detectorService = binder.getBoundService(); |
|
|
detectorService = binder.getBoundService(); |
|
|
detectorService.videoDetector.debugProcessing(null, outputImageView); //inputImageView |
|
|
|
|
|
|
|
|
// detectorService.videoDetector.debugProcessing(null, outputImageView); //inputImageView |
|
|
|
|
|
|
|
|
detectorService.setOnDetectionListener(new DetectorService.OnDetectionListener() { |
|
|
detectorService.setOnDetectionListener(new DetectorService.OnDetectionListener() { |
|
|
@Override |
|
|
@Override |
|
|
|
|
|
|
|
|
aktuellesFragment = null ; |
|
|
aktuellesFragment = null ; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
@Override |
|
|
|
|
|
public void onClick(View v) { |
|
|
|
|
|
if (v == toggleKamera) { |
|
|
|
|
|
if (toggleKamera.isChecked()) { |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if (v == toggleAudio) { |
|
|
|
|
|
if (toggleAudio.isChecked()) { |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if (v == toggleBewegung) { |
|
|
|
|
|
if (toggleBewegung.isChecked()) { |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |