Compare commits
17
Commits
a6fdf3f774
..
lm
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
81c3542654 | ||
|
|
d33ab299ab | ||
|
|
8a5d720685 | ||
|
|
90aea5b1bc | ||
|
|
8a357e0d26 | ||
|
|
83268c763b | ||
|
|
3d02d8d4c0 | ||
|
|
cafe763c4a | ||
|
|
2cff334056 | ||
|
|
6c4905d0e7 | ||
|
|
402b73e4bd | ||
|
|
9e5b669986 | ||
|
|
8275d8bd5a | ||
|
|
4999f1b998 | ||
|
|
620528302e | ||
|
|
065acefeb9 | ||
|
|
dda3d5693a |
No files matched your search
Whitespace-only changes.
@@ -0,0 +1,3 @@
|
|||||||
|
Sensor als Service einrichten, der aus Activity heraus gestartet werden kann.
|
||||||
|
Stichwort: Intent
|
||||||
|
Siehe Skript Teil 1
|
||||||
+3
-4
@@ -3,11 +3,11 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
namespace 'de.oklein.android.ueberwachungssystem'
|
namespace 'com.example.ueberwachungssystem'
|
||||||
compileSdk 33
|
compileSdk 33
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "de.oklein.android.ueberwachungssystem"
|
applicationId "com.example.ueberwachungssystem"
|
||||||
minSdk 28
|
minSdk 28
|
||||||
targetSdk 33
|
targetSdk 33
|
||||||
versionCode 1
|
versionCode 1
|
||||||
@@ -31,10 +31,9 @@ android {
|
|||||||
dependencies {
|
dependencies {
|
||||||
|
|
||||||
implementation 'androidx.appcompat:appcompat:1.6.1'
|
implementation 'androidx.appcompat:appcompat:1.6.1'
|
||||||
implementation 'com.google.android.material:material:1.9.0'
|
implementation 'com.google.android.material:material:1.8.0'
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||||
testImplementation 'junit:junit:4.13.2'
|
testImplementation 'junit:junit:4.13.2'
|
||||||
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
|
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
|
||||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
|
||||||
implementation "androidx.startup:startup-runtime:1.1.1"
|
|
||||||
}
|
}
|
||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
package de.oklein.android.ueberwachungssystem;
|
package com.example.ueberwachungssystem;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
@@ -21,6 +21,6 @@ public class ExampleInstrumentedTest {
|
|||||||
public void useAppContext() {
|
public void useAppContext() {
|
||||||
// Context of the app under test.
|
// Context of the app under test.
|
||||||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||||
assertEquals("de.oklein.android.ueberwachungssystem", appContext.getPackageName());
|
assertEquals("com.example.ueberwachungssystem", appContext.getPackageName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,28 +2,6 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools">
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
<!-- <!– If your app targets Android 13 (API level 33)-->
|
|
||||||
<!-- or higher, you must declare the NEARBY_WIFI_DEVICES permission. –>-->
|
|
||||||
<!-- <uses-permission android:name="android.permission.NEARBY_WIFI_DEVICES"-->
|
|
||||||
<!-- <!– If your app derives location information from Wi-Fi APIs,-->
|
|
||||||
<!-- don't include the "usesPermissionFlags" attribute. –>-->
|
|
||||||
<!-- android:usesPermissionFlags="neverForLocation" />-->
|
|
||||||
|
|
||||||
<uses-permission
|
|
||||||
android:required="true"
|
|
||||||
android:name="android.permission.ACCESS_FINE_LOCATION"/>
|
|
||||||
<!-- If any feature in your app relies on precise location information,
|
|
||||||
don't include the "maxSdkVersion" attribute. -->
|
|
||||||
<uses-permission
|
|
||||||
android:required="true"
|
|
||||||
android:name="android.permission.ACCESS_WIFI_STATE"/>
|
|
||||||
<uses-permission
|
|
||||||
android:required="true"
|
|
||||||
android:name="android.permission.CHANGE_WIFI_STATE"/>
|
|
||||||
<uses-permission
|
|
||||||
android:required="true"
|
|
||||||
android:name="android.permission.INTERNET"/>
|
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||||
|
|||||||
@@ -0,0 +1,109 @@
|
|||||||
|
package com.example.ueberwachungssystem.Detection;
|
||||||
|
|
||||||
|
import static java.lang.Math.sqrt;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.hardware.Sensor;
|
||||||
|
import android.hardware.SensorEvent;
|
||||||
|
import android.hardware.SensorEventListener;
|
||||||
|
import android.hardware.SensorManager;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Accelerometer inherits some methods from abstract Detector class (more info there)
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* USE FROM MAIN ACTIVITY:
|
||||||
|
*
|
||||||
|
* Accelerometer beschleunigungssensor = new Accelerometer(this);
|
||||||
|
* onCreate:
|
||||||
|
* //Accelerometer Setup
|
||||||
|
* beschleunigungssensor = new Accelerometer(this, logger, textViewLog); //logger and textview only for debugging necessary
|
||||||
|
* beschleunigungssensor.getSensor();
|
||||||
|
*
|
||||||
|
* //Starting Detection:
|
||||||
|
* beschleunigungssensor.startDetection();
|
||||||
|
* //Stopping Detection: also recommended at onPause to avoid unnecessary battery consumption
|
||||||
|
* beschleunigungssensor.stopDetection();
|
||||||
|
*
|
||||||
|
* */
|
||||||
|
|
||||||
|
public class Accelerometer extends Detector implements SensorEventListener {
|
||||||
|
|
||||||
|
public SensorManager sensorManager;
|
||||||
|
private static final int sensorType = Sensor.TYPE_LINEAR_ACCELERATION;
|
||||||
|
private Sensor accelerometer;
|
||||||
|
private Context context;
|
||||||
|
boolean alarm = false;
|
||||||
|
//Preallocate memory for the data of each axis of the acceleration sensor
|
||||||
|
float x;
|
||||||
|
float y;
|
||||||
|
float z;
|
||||||
|
float betrag; //Betrag aller drei Achsen sqrt(x*x + y*y + z*z)
|
||||||
|
private DetectionReport detectionReport;
|
||||||
|
|
||||||
|
// In constructor pass Activity, Context and TextView from MainActivity in Accelerometer class
|
||||||
|
public Accelerometer(Context context){
|
||||||
|
super(context); //von Detektor
|
||||||
|
this.context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void getSensor(){
|
||||||
|
sensorManager = (SensorManager)context.getSystemService(Context.SENSOR_SERVICE);
|
||||||
|
if(sensorManager.getSensorList(sensorType).size()==0) {
|
||||||
|
accelerometer = null;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
accelerometer = sensorManager.getSensorList(sensorType).get(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSensorChanged(SensorEvent event) {
|
||||||
|
try {
|
||||||
|
checkAlarm(event);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void checkAlarm (SensorEvent event) throws InterruptedException {
|
||||||
|
x = event.values[0];
|
||||||
|
y = event.values[1];
|
||||||
|
z = event.values[2];
|
||||||
|
betrag = (float) sqrt(x*x + y*y + z*z);
|
||||||
|
float threshold = 1.5F;
|
||||||
|
|
||||||
|
if (!alarm) {
|
||||||
|
if (betrag > threshold) {
|
||||||
|
alarm = true;
|
||||||
|
detectionReport = new DetectionReport("Accelerometer1", "Bewegung", betrag);
|
||||||
|
reportViolation("Accelo1", "Bewegung", betrag);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (betrag < threshold) {
|
||||||
|
alarm = false;
|
||||||
|
} else {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAccuracyChanged(Sensor sensor, int accuracy) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void startDetection() {
|
||||||
|
// entspricht void start()
|
||||||
|
//getSensor();
|
||||||
|
if (accelerometer != null) {
|
||||||
|
sensorManager.registerListener(this, accelerometer, SensorManager.SENSOR_DELAY_GAME);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stopDetection() {
|
||||||
|
// entspricht void stop()
|
||||||
|
sensorManager.unregisterListener(this, accelerometer);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package com.example.ueberwachungssystem.Detection;
|
||||||
|
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import java.util.Calendar;
|
||||||
|
|
||||||
|
/** Detection Report Class */
|
||||||
|
public class DetectionReport {
|
||||||
|
public String timeStamp;
|
||||||
|
public String detectionType;
|
||||||
|
public float detectedValue;
|
||||||
|
public String detectorID;
|
||||||
|
|
||||||
|
public DetectionReport(String detectorID, String detectionType, float detectedAmplitude) {
|
||||||
|
this.timeStamp = String.valueOf(Calendar.getInstance().getTime());
|
||||||
|
this.detectionType = detectionType;
|
||||||
|
this.detectedValue = detectedAmplitude;
|
||||||
|
this.detectorID = detectorID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** Get Detection Report in String format */
|
||||||
|
public String toString() {
|
||||||
|
String time = "Time: " + "[" + this.timeStamp + "]";
|
||||||
|
String type = "Type: " + "[" + this.detectionType + "]";
|
||||||
|
String value = "Value: " + "[" + this.detectedValue + "]";
|
||||||
|
String id = "ID: " + "[" + this.detectorID + "]";
|
||||||
|
|
||||||
|
return String.join("\t", time, type, value, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Debug Report */
|
||||||
|
public void log(String tag) {
|
||||||
|
Log.d(tag, this.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package com.example.ueberwachungssystem.Detection;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
|
||||||
|
abstract public class Detector {
|
||||||
|
private OnDetectionListener listener;
|
||||||
|
|
||||||
|
/** Constructor - takes context of current activity */
|
||||||
|
public Detector(Context context) {};
|
||||||
|
|
||||||
|
|
||||||
|
/** On Detection Listener - runs when violation is reported */
|
||||||
|
public interface OnDetectionListener {
|
||||||
|
void onDetection(@NonNull DetectionReport detectionReport);
|
||||||
|
}
|
||||||
|
public void setOnDetectionListener(@NonNull OnDetectionListener listener) {
|
||||||
|
this.listener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** Triggers onDetectionListener - call this to trigger violation/alarm */
|
||||||
|
public void reportViolation(String detectorID, String detectionType, float amplitude) {
|
||||||
|
if (listener != null) {
|
||||||
|
DetectionReport detectionReport = new DetectionReport(detectorID, detectionType, amplitude);
|
||||||
|
listener.onDetection(detectionReport);
|
||||||
|
} else {
|
||||||
|
throw new IllegalStateException("No listener set for violation reporting");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** Starts Detection (abstract method: needs to be overridden in child class) */
|
||||||
|
public abstract void startDetection();
|
||||||
|
|
||||||
|
/** Stops Detection (abstract method: needs to be overridden in child class) */
|
||||||
|
public abstract void stopDetection();
|
||||||
|
}
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
package com.example.ueberwachungssystem;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.text.method.ScrollingMovementMethod;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.ToggleButton;
|
||||||
|
|
||||||
|
import com.example.ueberwachungssystem.Detection.Accelerometer;
|
||||||
|
import com.example.ueberwachungssystem.Detection.DetectionReport;
|
||||||
|
import com.example.ueberwachungssystem.Detection.Detector;
|
||||||
|
|
||||||
|
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
|
||||||
|
|
||||||
|
private Accelerometer beschleunigungssensor;
|
||||||
|
private TextView textViewLog;
|
||||||
|
private Button button1;
|
||||||
|
ToggleButton toggleButton1;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setTitle(this.getClass().getSimpleName());
|
||||||
|
setContentView(R.layout.activity_main);
|
||||||
|
|
||||||
|
|
||||||
|
toggleButton1 = findViewById(R.id.toggleButton1); //togglebutton um Detektion zu steuern
|
||||||
|
toggleButton1.setOnClickListener(this);
|
||||||
|
|
||||||
|
//Button to clear Log while Debugging
|
||||||
|
button1 = (Button) findViewById(R.id.button1);
|
||||||
|
button1.setOnClickListener(this);
|
||||||
|
|
||||||
|
//Accelerometer Setup
|
||||||
|
beschleunigungssensor = new Accelerometer(this); //logger and textview only for debugging necessary
|
||||||
|
beschleunigungssensor.getSensor();
|
||||||
|
beschleunigungssensor.setOnDetectionListener(new Detector.OnDetectionListener() {
|
||||||
|
@Override
|
||||||
|
public void onDetection(@NonNull DetectionReport detectionReport) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
beschleunigungssensor.stopDetection();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if(v == toggleButton1) {
|
||||||
|
if (toggleButton1.isChecked()) {
|
||||||
|
beschleunigungssensor.startDetection();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
beschleunigungssensor.stopDetection();
|
||||||
|
}
|
||||||
|
} else if (v == button1) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
package de.oklein.android.ueberwachungssystem.Logger;
|
|
||||||
|
|
||||||
import android.util.Log;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import java.io.PrintWriter;
|
|
||||||
import java.io.StringWriter;
|
|
||||||
|
|
||||||
public class Logger {
|
|
||||||
private TextView textView;
|
|
||||||
private StringBuffer sb = new StringBuffer();
|
|
||||||
private String tag;
|
|
||||||
|
|
||||||
public Logger(String tag, TextView textView, String logInitText) {
|
|
||||||
this.tag = tag;
|
|
||||||
this.textView = textView;
|
|
||||||
sb.append(logInitText);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void log(String s) {
|
|
||||||
Log.d(tag, s);
|
|
||||||
sb.append(s).append("\n");
|
|
||||||
if (textView != null) {
|
|
||||||
textView.setText(sb.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void log(Exception e) {
|
|
||||||
StringWriter sw = new StringWriter();
|
|
||||||
e.printStackTrace(new PrintWriter(sw));
|
|
||||||
log(sw.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clearLog() {
|
|
||||||
sb.setLength(0);
|
|
||||||
if (textView != null) {
|
|
||||||
textView.setText("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLoggedText() {
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,170 +0,0 @@
|
|||||||
package de.oklein.android.ueberwachungssystem;
|
|
||||||
|
|
||||||
import androidx.fragment.app.Fragment;
|
|
||||||
import androidx.fragment.app.FragmentTransaction;
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.EditText;
|
|
||||||
import android.widget.ScrollView;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import org.w3c.dom.Text;
|
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity {
|
|
||||||
private Fragment aktuellesFragment;
|
|
||||||
private TextView alarm;
|
|
||||||
private String text = "Das ist ein Alarm des Sensors";
|
|
||||||
private void log(String nachricht) {
|
|
||||||
Log.d(this.getClass().getSimpleName(), nachricht);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setTitle(this.getClass().getSimpleName());
|
|
||||||
setContentView(R.layout.activity_main);
|
|
||||||
alarm = findViewById(R.id.Alarm);
|
|
||||||
alarm.setText(text);
|
|
||||||
}
|
|
||||||
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 ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public static class Fragment1 extends Fragment {
|
|
||||||
private String text;
|
|
||||||
private final static String KEY_TEXT = "KEY_TEXT";
|
|
||||||
|
|
||||||
private void log(String nachricht) {
|
|
||||||
Log.d(this.getClass().getSimpleName(), nachricht);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
|
|
||||||
log("onCreateView");
|
|
||||||
View view = inflater.inflate(R.layout.fragment1, container, false);
|
|
||||||
TextView Sensor = (TextView) view.findViewById(R.id.Sensor);
|
|
||||||
Sensor.setText(text);
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
public static Fragment1 erstellen(String text) {
|
|
||||||
Fragment1 fragment = new Fragment1();
|
|
||||||
Bundle b = new Bundle();
|
|
||||||
b.putString(KEY_TEXT, text);
|
|
||||||
fragment.setArguments(b);
|
|
||||||
return fragment;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onCreate(Bundle bundle) {
|
|
||||||
super .onCreate(bundle);
|
|
||||||
Bundle args = getArguments();
|
|
||||||
if (args != null ) {
|
|
||||||
text = args.getString(KEY_TEXT);
|
|
||||||
log("onCreate: text=" + text);
|
|
||||||
} else {
|
|
||||||
log("onCreate");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public static class Fragment2 extends Fragment {
|
|
||||||
private String text;
|
|
||||||
private final static String KEY_TEXT = "KEY_TEXT" ;
|
|
||||||
private void log(String nachricht) {
|
|
||||||
Log.d(this.getClass().getSimpleName(), nachricht);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
|
|
||||||
log( "onCreateView" );
|
|
||||||
View view = inflater.inflate(R.layout.fragment2, container, false );
|
|
||||||
TextView Sensor = (TextView) view.findViewById(R.id.Sensor);
|
|
||||||
Sensor.setText(text);
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
public static Fragment2 erstellen(String text) {
|
|
||||||
Fragment2 fragment = new Fragment2();
|
|
||||||
Bundle b = new Bundle();
|
|
||||||
b.putString(KEY_TEXT, text);
|
|
||||||
fragment.setArguments(b);
|
|
||||||
return fragment;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onCreate(Bundle bundle) {
|
|
||||||
super.onCreate(bundle);
|
|
||||||
Bundle args = getArguments();
|
|
||||||
if (args != null) {
|
|
||||||
text = args.getString(KEY_TEXT);
|
|
||||||
log("onCreate: text=" + text);
|
|
||||||
} else {
|
|
||||||
log("onCreate");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Fragment3 extends Fragment {
|
|
||||||
private String text;
|
|
||||||
private final static String KEY_TEXT = "KEY_TEXT" ;
|
|
||||||
private void log(String nachricht) {
|
|
||||||
Log.d(this.getClass().getSimpleName(), nachricht);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
|
|
||||||
log( "onCreateView" );
|
|
||||||
View view = inflater.inflate(R.layout.fragment2, container, false );
|
|
||||||
TextView Sensor = (TextView) view.findViewById(R.id.Sensor);
|
|
||||||
Sensor.setText(text);
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
public static Fragment3 erstellen(String text) {
|
|
||||||
Fragment3 fragment = new Fragment3();
|
|
||||||
Bundle b = new Bundle();
|
|
||||||
b.putString(KEY_TEXT, text);
|
|
||||||
fragment.setArguments(b);
|
|
||||||
return fragment;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onCreate(Bundle bundle) {
|
|
||||||
super.onCreate(bundle);
|
|
||||||
Bundle args = getArguments();
|
|
||||||
if (args != null) {
|
|
||||||
text = args.getString(KEY_TEXT);
|
|
||||||
log("onCreate: text=" + text);
|
|
||||||
} else {
|
|
||||||
log("onCreate");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
@@ -1,123 +1,63 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.constraintlayout.widget.ConstraintLayout 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:background="@android:color/holo_green_dark"
|
tools:context=".MainActivity">
|
||||||
android:visibility="visible"
|
|
||||||
tools:context="de.oklein.android.ueberwachungssystem.MainActivity"
|
<TextView
|
||||||
tools:visibility="visible">
|
android:id="@+id/textViewLog"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="32dp"
|
||||||
|
android:layout_marginTop="60dp"
|
||||||
|
android:layout_marginEnd="32dp"
|
||||||
|
android:maxLines="25"
|
||||||
|
android:scrollbars="vertical"
|
||||||
|
android:text="TextViewLoggerMain"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/textViewWorkerThread"
|
||||||
|
app:layout_constraintVertical_bias="0.0" />
|
||||||
|
|
||||||
<ToggleButton
|
<ToggleButton
|
||||||
android:id="@+id/toggleKamera"
|
android:id="@+id/toggleButton1"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignBottom="@id/toggleAudio"
|
android:layout_marginStart="161dp"
|
||||||
android:layout_marginRight="15dp"
|
android:layout_marginTop="115dp"
|
||||||
android:layout_toStartOf="@+id/toggleAudio"
|
android:layout_marginEnd="162dp"
|
||||||
android:layout_toLeftOf="@id/toggleAudio"
|
android:text="ToggleButton"
|
||||||
android:text="Kamera" />
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
<ToggleButton
|
<TextView
|
||||||
android:id="@+id/toggleAudio"
|
android:id="@+id/textViewWorkerThread"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentTop="true"
|
android:layout_marginStart="32dp"
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_marginTop="16dp"
|
||||||
android:text="Audio" />
|
android:layout_marginEnd="32dp"
|
||||||
|
android:text="textViewWorkerThreadTextView"
|
||||||
<ToggleButton
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
android:id="@+id/toggleBewegung"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
android:layout_width="wrap_content"
|
app:layout_constraintTop_toBottomOf="@+id/toggleButton1" />
|
||||||
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
|
<Button
|
||||||
android:id="@+id/btnAudio"
|
android:id="@+id/button1"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignBottom="@id/btnKamera"
|
android:layout_marginStart="35dp"
|
||||||
android:layout_marginRight="15dp"
|
android:layout_marginTop="31dp"
|
||||||
android:layout_toStartOf="@+id/btnKamera"
|
android:layout_marginEnd="282dp"
|
||||||
android:onClick="onClickZeigeFragment1"
|
android:layout_marginBottom="100dp"
|
||||||
android:text="Audio" />
|
android:text="Clear Log"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/textViewWorkerThread"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
<Button
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
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_height="200dp"
|
|
||||||
android:layout_below="@+id/btnZwischen"
|
|
||||||
android:layout_alignParentStart="true">
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
<ScrollView
|
|
||||||
android:id= "@+id/scrollView1"
|
|
||||||
android:layout_width= "wrap_content"
|
|
||||||
android:layout_height= "wrap_content"
|
|
||||||
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>
|
|
||||||
|
|
||||||
</RelativeLayout>
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:gravity="center_horizontal"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:background="@android:color/holo_green_light">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/Sensor"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/Alarm"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_below="@id/Sensor"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"/>
|
|
||||||
|
|
||||||
</RelativeLayout>
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:gravity="center_horizontal"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:background="@android:color/holo_blue_light" >
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/Sensor"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/Alarm"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_below="@id/Sensor"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:gravity="center_horizontal"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:background="@android:color/holo_blue_light" >
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/Sensor"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/Alarm"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_below="@id/Sensor"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package de.oklein.android.ueberwachungssystem;
|
package com.example.ueberwachungssystem;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
plugins {
|
plugins {
|
||||||
id 'com.android.application' version '7.4.2' apply false
|
id 'com.android.application' version '8.0.0' apply false
|
||||||
id 'com.android.library' version '7.4.2' apply false
|
id 'com.android.library' version '8.0.0' apply false
|
||||||
}
|
}
|
||||||
@@ -19,3 +19,5 @@ android.useAndroidX=true
|
|||||||
# resources declared in the library itself and none from the library's dependencies,
|
# resources declared in the library itself and none from the library's dependencies,
|
||||||
# thereby reducing the size of the R class for that library
|
# thereby reducing the size of the R class for that library
|
||||||
android.nonTransitiveRClass=true
|
android.nonTransitiveRClass=true
|
||||||
|
android.defaults.buildfeatures.buildconfig=true
|
||||||
|
android.nonFinalResIds=false
|
||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
#Thu May 11 15:19:24 CEST 2023
|
#Thu May 11 15:04:30 CEST 2023
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
Reference in new issue
Block a user