Browse Source

Version 4 working

ms_service_copie
Miguel Siebenhaar 1 year ago
parent
commit
61cad34931

+ 0
- 2
app/src/main/java/com/example/ueberwachungssystem/Detection/DetectorService.java View File

} }






public boolean checkState(String string){ public boolean checkState(String string){
Log.d("state", String.valueOf(splitString(string)[4].equals("An"))); Log.d("state", String.valueOf(splitString(string)[4].equals("An")));
return splitString(string)[4].equals("An"); return splitString(string)[4].equals("An");

+ 19
- 7
app/src/main/java/com/example/ueberwachungssystem/MainActivity.java View File

ImageView inputImageView; ImageView inputImageView;
ImageView outputImageView; ImageView outputImageView;
ToggleButton toggleButton; ToggleButton toggleButton;
int num=0;


@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); setContentView(R.layout.activity_main);



inputImageView = findViewById(R.id.inputImageView); inputImageView = findViewById(R.id.inputImageView);
outputImageView = findViewById(R.id.outputImageView); outputImageView = findViewById(R.id.outputImageView);
toggleButton = findViewById(R.id.toggleButton); toggleButton = findViewById(R.id.toggleButton);


}

@Override
protected void onResume() {
super.onResume();


PermissionHandler permissionHandler = new PermissionHandler(this); PermissionHandler permissionHandler = new PermissionHandler(this);
permissionHandler.getPermissions();
//permissionHandler.getPermissions();
if (permissionHandler.hasPermissions()) { if (permissionHandler.hasPermissions()) {



Intent serviceIntent = new Intent(this, DetectorService.class); Intent serviceIntent = new Intent(this, DetectorService.class);
bindService(serviceIntent, serviceConnection, Context.BIND_AUTO_CREATE); bindService(serviceIntent, serviceConnection, Context.BIND_AUTO_CREATE);
startService(serviceIntent); startService(serviceIntent);



toggleButton.setOnClickListener(new View.OnClickListener() { toggleButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
{ {
if (detectorService != null){ if (detectorService != null){


detectorService.videoDetector.debugProcessing(inputImageView, outputImageView);
detectorService.videoDetector.startDetection(); detectorService.videoDetector.startDetection();


detectorService.audioDetector.startDetection(); detectorService.audioDetector.startDetection();
} }
}); });
}else{ }else{
Toast.makeText(getApplicationContext(),"Bitte Zugriffsrechte gewähren",Toast.LENGTH_SHORT).show();
Toast.makeText(this,"Bitte Rechte geben", Toast.LENGTH_SHORT).show();
} }

} }

public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.options_menu, menu); getMenuInflater().inflate(R.menu.options_menu, menu);
return true; return true;
popUpClass.showPopupWindow(inputImageView); popUpClass.showPopupWindow(inputImageView);
popUpClass.Impressum(); popUpClass.Impressum();
return true; return true;
case R.id.Detection:
popUpClass = new PopUpClass(MainActivity.this);
popUpClass.showPopupWindow(inputImageView);
popUpClass.DetectionTotal(num);
return true;
default: default:
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
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.setOnDetectionListener(new DetectorService.OnDetectionListener() { detectorService.setOnDetectionListener(new DetectorService.OnDetectionListener() {
@Override @Override
public void onDetection(@NonNull StringBuffer stringBuffer) { public void onDetection(@NonNull StringBuffer stringBuffer) {
Log.d("onDetection", stringBuffer.toString()); //Für oli hier Textview einbauen Log.d("onDetection", stringBuffer.toString()); //Für oli hier Textview einbauen
num++;
} }
}); });
} }
@Override @Override
public void onServiceDisconnected(ComponentName name) {}
public void onServiceDisconnected(ComponentName name) {
}
}; };
} }

+ 1
- 1
app/src/main/java/com/example/ueberwachungssystem/PermissionRequest.java View File

handler.post(new Runnable() { handler.post(new Runnable() {
@Override @Override
public void run() { public void run() {
Toast.makeText(mainActivity.getApplicationContext(),"Es werden Rechte benötigt", Toast.LENGTH_LONG).show();
Toast.makeText(mainActivity.getApplicationContext(),"Es werden Rechte benötigt", Toast.LENGTH_SHORT).show();
} }
}); });
} }

+ 3
- 1
app/src/main/java/com/example/ueberwachungssystem/PopUpClass.java View File

public void Impressum(){ public void Impressum(){
PopUpText.setText("Die Ueberwachungsapp wurde im Rahmen eines Praktikums der TH-Nürnberg programmiert"); PopUpText.setText("Die Ueberwachungsapp wurde im Rahmen eines Praktikums der TH-Nürnberg programmiert");
} }

public void DetectionTotal(int num) {
PopUpText.setText("Total Detektions:" +num);
}
} }

+ 2
- 0
app/src/main/res/menu/options_menu.xml View File

android:title="Rechteverwaltung" /> android:title="Rechteverwaltung" />
<item android:id="@+id/Sensoren" <item android:id="@+id/Sensoren"
android:title="Sensoren" /> android:title="Sensoren" />
<item android:id="@+id/Detection"
android:title="Detektionen" />
<item android:id="@+id/Impressum" <item android:id="@+id/Impressum"
android:title="Impressum" /> android:title="Impressum" />
</menu> </menu>

Loading…
Cancel
Save