Compare commits
2 Commits
57bf2c2fb7
...
5f7e2a43f2
Author | SHA1 | Date | |
---|---|---|---|
5f7e2a43f2 | |||
07f60f974b |
@ -36,4 +36,5 @@ dependencies {
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
|
||||
implementation "androidx.startup:startup-runtime:1.1.1"
|
||||
}
|
@ -2,6 +2,28 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
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
|
||||
android:allowBackup="true"
|
||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||
|
@ -0,0 +1,44 @@
|
||||
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,15 +1,171 @@
|
||||
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.TextView;
|
||||
|
||||
import org.w3c.dom.Text;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
private Fragment aktuellesFragment;
|
||||
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);
|
||||
//penis
|
||||
}
|
||||
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);
|
||||
TextView Alarm = (TextView) view.findViewById(R.id.Alarm);
|
||||
Alarm.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);
|
||||
TextView Alarm = (TextView) view.findViewById(R.id.Alarm);
|
||||
Alarm.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);
|
||||
TextView Alarm = (TextView) view.findViewById(R.id.Alarm);
|
||||
Alarm.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,18 +1,70 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".MainActivity">
|
||||
tools:context="de.oklein.android.ueberwachungssystem.MainActivity"
|
||||
android:background="@android:color/holo_orange_light">
|
||||
|
||||
<TextView
|
||||
<Button
|
||||
android:id="@+id/btn1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Hello World!"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
android:layout_alignBottom="@id/btn2"
|
||||
android:layout_toLeftOf="@id/btn2"
|
||||
android:text="Audio"
|
||||
android:onClick="onClickZeigeFragment1"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
<Button
|
||||
android:id="@+id/btn2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:text="Kamera"
|
||||
android:onClick="onClickZeigeFragment2"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignBottom="@id/btn2"
|
||||
android:layout_toRightOf="@id/btn2"
|
||||
android:text="Bewegung"
|
||||
android:onClick="onClickZeigeFragment3"/>
|
||||
|
||||
<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/btnAufnahme"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/btnSensorWeg"
|
||||
android:text="Aufnahme"
|
||||
android:onClick="onClickEntferneFragment"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnWiedergabe"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toRightOf="@id/btnAufnahme"
|
||||
android:layout_below="@+id/btnSensorWeg"
|
||||
android:text="Wiedergabe"
|
||||
android:onClick="onClickEntferneFragment"/>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/frame"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_below="@+id/btnAufnahme">
|
||||
</FrameLayout>
|
||||
|
||||
</RelativeLayout>
|
22
app/src/main/res/layout/fragment1.xml
Normal file
22
app/src/main/res/layout/fragment1.xml
Normal file
@ -0,0 +1,22 @@
|
||||
<?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>
|
22
app/src/main/res/layout/fragment2.xml
Normal file
22
app/src/main/res/layout/fragment2.xml
Normal file
@ -0,0 +1,22 @@
|
||||
<?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>
|
22
app/src/main/res/layout/fragment3.xml
Normal file
22
app/src/main/res/layout/fragment3.xml
Normal file
@ -0,0 +1,22 @@
|
||||
<?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>
|
Loading…
x
Reference in New Issue
Block a user