Compare commits
No commits in common. "2b5b997192fb2d3cfd2a3e7eb7f6f36c9044665e" and "812c1d7dfa284d2fb8abc48c63d3fd5c43ebbaa2" have entirely different histories.
2b5b997192
...
812c1d7dfa
6
.idea/vcs.xml
generated
6
.idea/vcs.xml
generated
@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="VcsDirectoryMappings">
|
|
||||||
<mapping directory="" vcs="Git" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
@ -1,17 +1,11 @@
|
|||||||
package de.edotzlaff.detection;
|
package de.edotzlaff.detection;
|
||||||
|
|
||||||
import android.hardware.Sensor;
|
|
||||||
import android.hardware.SensorEvent;
|
|
||||||
import android.hardware.SensorEventListener;
|
|
||||||
import android.hardware.SensorManager;
|
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.CountDownTimer;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import androidx.annotation.RequiresApi;
|
import androidx.annotation.RequiresApi;
|
||||||
import androidx.fragment.app.FragmentActivity;
|
import androidx.fragment.app.FragmentActivity;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import com.google.android.gms.maps.CameraUpdateFactory;
|
import com.google.android.gms.maps.CameraUpdateFactory;
|
||||||
import com.google.android.gms.maps.GoogleMap;
|
import com.google.android.gms.maps.GoogleMap;
|
||||||
@ -50,13 +44,15 @@ public class EarthquakeLocation extends FragmentActivity implements OnMapReadyCa
|
|||||||
//################################################################## ^^^^ DB Code ^^^^ ###################################################################################
|
//################################################################## ^^^^ DB Code ^^^^ ###################################################################################
|
||||||
//##########################################################################################################################################################################
|
//##########################################################################################################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//##########################################################################################################################################################################
|
//##########################################################################################################################################################################
|
||||||
//################################################################## vvv Calculate Epicenter vvv #########################################################################
|
//################################################################## vvv Calculate Epicenter vvv #########################################################################
|
||||||
|
|
||||||
//TODO Jan
|
//TODO Jan
|
||||||
|
|
||||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||||
/* public Epizentrum ermittleEpizentrum(DataSnapshot data)
|
public Epizentrum ermittleEpizentrum(DataSnapshot data)
|
||||||
{
|
{
|
||||||
Erdbeben erdbeben = new Erdbeben();
|
Erdbeben erdbeben = new Erdbeben();
|
||||||
erdbeben.addDetektionssignalList(mapToDetektionssignale(data));
|
erdbeben.addDetektionssignalList(mapToDetektionssignale(data));
|
||||||
@ -75,8 +71,8 @@ public class EarthquakeLocation extends FragmentActivity implements OnMapReadyCa
|
|||||||
return epizentrum;
|
return epizentrum;
|
||||||
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
/* public ArrayList<Detektionssignal> mapToDetektionssignale(DataSnapshot data)
|
public ArrayList<Detektionssignal> mapToDetektionssignale(DataSnapshot data)
|
||||||
{
|
{
|
||||||
ArrayList<Detektionssignal> detektionssignale = new ArrayList<>();
|
ArrayList<Detektionssignal> detektionssignale = new ArrayList<>();
|
||||||
for(data.child("overviewnodes").getChildernKey)
|
for(data.child("overviewnodes").getChildernKey)
|
||||||
@ -94,8 +90,6 @@ public class EarthquakeLocation extends FragmentActivity implements OnMapReadyCa
|
|||||||
return detektionssignale;
|
return detektionssignale;
|
||||||
}
|
}
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
//################################################################## ^^^^ Calculate Epicenter ^^^^ #######################################################################
|
//################################################################## ^^^^ Calculate Epicenter ^^^^ #######################################################################
|
||||||
//##########################################################################################################################################################################
|
//##########################################################################################################################################################################
|
||||||
|
@ -7,16 +7,10 @@ import androidx.core.content.ContextCompat;
|
|||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.hardware.Sensor;
|
|
||||||
import android.hardware.SensorEvent;
|
|
||||||
import android.hardware.SensorEventListener;
|
|
||||||
import android.hardware.SensorManager;
|
|
||||||
import android.location.Location;
|
import android.location.Location;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.CountDownTimer;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
@ -37,12 +31,10 @@ import com.google.android.gms.tasks.Task;
|
|||||||
import org.w3c.dom.Text;
|
import org.w3c.dom.Text;
|
||||||
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
private static final String TAG = "MainActivity";
|
private static final String TAG = "MainActivity";
|
||||||
|
|
||||||
private static final int ERROR_DIALOG_REQUEST = 9001;
|
private static final int ERROR_DIALOG_REQUEST = 9001;
|
||||||
|
|
||||||
private static final String FINE_LOCATION = Manifest.permission.ACCESS_FINE_LOCATION;
|
private static final String FINE_LOCATION = Manifest.permission.ACCESS_FINE_LOCATION;
|
||||||
@ -58,21 +50,6 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
private double laengengrad;
|
private double laengengrad;
|
||||||
private boolean useOwnGPS = true;
|
private boolean useOwnGPS = true;
|
||||||
private int indexID = 1;
|
private int indexID = 1;
|
||||||
//##########################################################################################################################################################################
|
|
||||||
//################################################################## vvv SensorParameter vvv ##############################################################################
|
|
||||||
private SensorManager mSensorManager;
|
|
||||||
private static final float mUpperThreshold = 1.0f; // für Emulator auf 1.5 setzen
|
|
||||||
private static final float mLowerThreshold = 0.5f; // für Emulator auf 0.5 setzen
|
|
||||||
private static final long mShakeDetectionLockTimeMicroSeconds = 1000;
|
|
||||||
private float mAccel;
|
|
||||||
private float mAccelCurrent;
|
|
||||||
private float mAccelLast;
|
|
||||||
private boolean mShakeDetectionIsActive = false;
|
|
||||||
private boolean mShakeDetected = false;
|
|
||||||
private boolean allowShakeEvent = true;
|
|
||||||
|
|
||||||
//################################################################## ^^^^ SensorParameter ^^^^ ############################################################################
|
|
||||||
//##########################################################################################################################################################################
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -84,7 +61,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Detection funktion here
|
//Detection funktion here
|
||||||
sensorManagementInit();
|
|
||||||
getLocationPermission();
|
getLocationPermission();
|
||||||
|
|
||||||
//DB function here
|
//DB function here
|
||||||
@ -92,94 +69,15 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//################################################################## vvv Detection Code vvv ###################################################################################
|
|
||||||
//##########################################################################################################################################################################
|
//##########################################################################################################################################################################
|
||||||
private void sensorManagementInit()
|
//################################################################## vvv Detect Vibration vvv ############################################################################
|
||||||
{
|
|
||||||
//TextView txtEarthquake = (TextView) findViewById(R.id.txtEarthquake);
|
|
||||||
mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
|
|
||||||
Objects.requireNonNull(mSensorManager).registerListener(mSensorListener, mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_NORMAL);
|
|
||||||
mAccel = 1f;
|
|
||||||
mAccelCurrent = SensorManager.GRAVITY_EARTH;
|
|
||||||
mAccelLast = SensorManager.GRAVITY_EARTH;
|
|
||||||
mShakeDetectionIsActive = true;
|
|
||||||
mShakeDetected = false;
|
|
||||||
}
|
|
||||||
private final SensorEventListener mSensorListener = new SensorEventListener() {
|
|
||||||
@Override
|
|
||||||
public void onSensorChanged(SensorEvent event) {
|
|
||||||
float x = event.values[0];
|
|
||||||
float y = event.values[1];
|
|
||||||
float z = event.values[2];
|
|
||||||
mAccelLast = mAccelCurrent;
|
|
||||||
mAccelCurrent = (float) Math.sqrt((double) (x * x + y * y + z * z));
|
|
||||||
float delta = mAccelCurrent - mAccelLast;
|
|
||||||
mAccel = mAccel * 0.9f + delta;
|
|
||||||
Log.d(TAG,"mAccel: "+ mAccel);
|
|
||||||
if (mShakeDetectionIsActive && !mShakeDetected) {
|
|
||||||
if(Math.abs(mAccel) > mUpperThreshold) {
|
|
||||||
new CountDownTimer(500, 10) {
|
|
||||||
|
|
||||||
public void onTick(long millisUntilFinished) {
|
//TODO Böbbi
|
||||||
mShakeDetectionIsActive = false;
|
|
||||||
/* if (Math.abs(mAccel) > mUpperThreshold) {
|
|
||||||
mShakeDetectionIsActive = false;
|
|
||||||
} else if (Math.abs(mAccel) < mLowerThreshold) {
|
|
||||||
mShakeDetectionIsActive = true;
|
|
||||||
this.cancel();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
|
//################################################################## ^^^^ Detect Vibration ^^^^ ##########################################################################
|
||||||
public void onFinish() {
|
|
||||||
if (Math.abs(mAccel) > mUpperThreshold) {
|
|
||||||
mShakeDetectionIsActive = false;
|
|
||||||
mShakeDetected = true;
|
|
||||||
|
|
||||||
earthquakeDetected();
|
|
||||||
|
|
||||||
} else {
|
|
||||||
mShakeDetectionIsActive = true;
|
|
||||||
mShakeDetected = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}.start();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void onAccuracyChanged(Sensor sensor, int accuracy) {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private void earthquakeDetected()
|
|
||||||
{
|
|
||||||
Toast.makeText(getApplicationContext(), "!Earthquake detected!", Toast.LENGTH_SHORT).show();
|
|
||||||
Log.d(TAG,"!Earthquake detected!");
|
|
||||||
//setDataBaseValues();
|
|
||||||
new CountDownTimer(mShakeDetectionLockTimeMicroSeconds, 100) {
|
|
||||||
|
|
||||||
public void onTick(long millisUntilFinished) {
|
|
||||||
Log.d(TAG,"Earthquake: "+ millisUntilFinished + " ms");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void onFinish() {
|
|
||||||
Log.d(TAG,"Earthquake Detection is Unlocked: ");
|
|
||||||
mShakeDetectionIsActive = true;
|
|
||||||
mShakeDetected = false;
|
|
||||||
|
|
||||||
}
|
|
||||||
}.start();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//################################################################## ^^^^ Detection Code ^^^^ ###################################################################################
|
|
||||||
//##########################################################################################################################################################################
|
//##########################################################################################################################################################################
|
||||||
|
|
||||||
|
|
||||||
//##########################################################################################################################################################################
|
//##########################################################################################################################################################################
|
||||||
//################################################################## vvv Get Location from Device vvv ####################################################################
|
//################################################################## vvv Get Location from Device vvv ####################################################################
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ buildscript {
|
|||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:4.2.1'
|
classpath "com.android.tools.build:gradle:4.1.3"
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
// in the individual module build.gradle files
|
// in the individual module build.gradle files
|
||||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
|||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
|
||||||
|
Loading…
x
Reference in New Issue
Block a user