|
|
|
|
|
|
|
|
import android.widget.Toast;
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
|
|
import androidx.annotation.RequiresApi;
|
|
|
import androidx.core.app.ActivityCompat;
|
|
|
import androidx.core.app.ActivityCompat;
|
|
|
import androidx.core.content.ContextCompat;
|
|
|
import androidx.core.content.ContextCompat;
|
|
|
import androidx.fragment.app.FragmentActivity;
|
|
|
import androidx.fragment.app.FragmentActivity;
|
|
|
|
|
|
|
|
|
import com.google.firebase.database.ValueEventListener;
|
|
|
import com.google.firebase.database.ValueEventListener;
|
|
|
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
|
import java.time.ZoneOffset;
|
|
|
import java.util.Calendar;
|
|
|
import java.util.Calendar;
|
|
|
import java.util.Date;
|
|
|
import java.util.Date;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getVibrationAbility();
|
|
|
getVibrationAbility();
|
|
|
System.out.println("Global Shit: " + globalShit);
|
|
|
System.out.println("Global Shit: " + globalShit);
|
|
|
}
|
|
|
}
|
|
|
@Override
|
|
|
|
|
|
protected void onPause()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
super.onPause();
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected void onResume()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
super.onResume();
|
|
|
|
|
|
}
|
|
|
|
|
|
//#####################################################################################################################################################################
|
|
|
//#####################################################################################################################################################################
|
|
|
//################################################################## vvv ShakeCode vvv ##############################################################################
|
|
|
//################################################################## vvv ShakeCode vvv ##############################################################################
|
|
|
private void getVibrationAbility()
|
|
|
private void getVibrationAbility()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void setVibrationTimer(long msDelay, int duration, int amplitude, int index)
|
|
|
private void setVibrationTimer(long msDelay, int duration, int amplitude, int index)
|
|
|
{
|
|
|
{
|
|
|
System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!setVibrationTimer wurde getriggert mit Index " + index);
|
|
|
|
|
|
new CountDownTimer(msDelay, 1000) {
|
|
|
new CountDownTimer(msDelay, 1000) {
|
|
|
public void onTick(long millisUntilFinished) {
|
|
|
public void onTick(long millisUntilFinished) {
|
|
|
((TextView) findViewById(R.id.txtSensor)).setText("Earthquake hits in " + millisUntilFinished / 1000 + " s");
|
|
|
((TextView) findViewById(R.id.txtSensor)).setText("Earthquake hits in " + millisUntilFinished / 1000 + " s");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@RequiresApi(api = Build.VERSION_CODES.O)
|
|
|
public void onFinish() {
|
|
|
public void onFinish() {
|
|
|
Toast.makeText(getApplicationContext(), "The Ground is shaking!", Toast.LENGTH_SHORT).show();
|
|
|
Toast.makeText(getApplicationContext(), "The Ground is shaking!", Toast.LENGTH_SHORT).show();
|
|
|
performVibration(duration, amplitude);
|
|
|
performVibration(duration, amplitude);
|
|
|
|
|
|
|
|
|
if(!mDeviceCanVibrate)
|
|
|
if(!mDeviceCanVibrate)
|
|
|
return;
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
|
|
|
Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
|
|
|
if(amplitude > 255 || amplitude < 1)
|
|
|
|
|
|
amplitude = VibrationEffect.DEFAULT_AMPLITUDE;
|
|
|
|
|
|
if (Build.VERSION.SDK_INT >= 26) {
|
|
|
|
|
|
|
|
|
if (Build.VERSION.SDK_INT >= 26) {
|
|
|
|
|
|
if(amplitude > 255 || amplitude < 1)
|
|
|
|
|
|
amplitude = VibrationEffect.DEFAULT_AMPLITUDE;
|
|
|
if(duration == 0)
|
|
|
if(duration == 0)
|
|
|
{
|
|
|
{
|
|
|
v.cancel(); //stop vibration if still running
|
|
|
v.cancel(); //stop vibration if still running
|
|
|
|
|
|
|
|
|
useOwnGPS = false;
|
|
|
useOwnGPS = false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
System.out.println("useOWNgps: " + useOwnGPS);
|
|
|
//Wichtig zur Verwendung von GPS-Daten explizit aus der Datenbank
|
|
|
//Wichtig zur Verwendung von GPS-Daten explizit aus der Datenbank
|
|
|
if(!useOwnGPS && grabGPSandID)
|
|
|
if(!useOwnGPS && grabGPSandID)
|
|
|
{
|
|
|
{
|
|
|
|
|
|
System.out.println("Entry: ");
|
|
|
for (int f = 1; f<=indexMax; f++)
|
|
|
for (int f = 1; f<=indexMax; f++)
|
|
|
{
|
|
|
{
|
|
|
|
|
|
System.out.println("1Entry: ");
|
|
|
if(f>=2 && f<=indexMax)
|
|
|
if(f>=2 && f<=indexMax)
|
|
|
{
|
|
|
{
|
|
|
|
|
|
System.out.println("2Entry: ");
|
|
|
if(analyzeIfAnroidIdIsEmpty(data,f))
|
|
|
if(analyzeIfAnroidIdIsEmpty(data,f))
|
|
|
{
|
|
|
{
|
|
|
|
|
|
System.out.println("3Entry: ");
|
|
|
String breitengradString = data.child("overviewnodes").child("IDG" + f).child("d_breitengrad").getValue().toString();
|
|
|
String breitengradString = data.child("overviewnodes").child("IDG" + f).child("d_breitengrad").getValue().toString();
|
|
|
String laengengradString = data.child("overviewnodes").child("IDG" + f).child("e_laengengrad").getValue().toString();
|
|
|
String laengengradString = data.child("overviewnodes").child("IDG" + f).child("e_laengengrad").getValue().toString();
|
|
|
|
|
|
System.out.println("4Entry: ");
|
|
|
breitengrad = Double.parseDouble(breitengradString);
|
|
|
breitengrad = Double.parseDouble(breitengradString);
|
|
|
laengengrad = Double.parseDouble(laengengradString);
|
|
|
laengengrad = Double.parseDouble(laengengradString);
|
|
|
|
|
|
System.out.println("5Entry: ");
|
|
|
allocateIDtoDatabaseSlot(f);
|
|
|
allocateIDtoDatabaseSlot(f);
|
|
|
grabGPSandID = false;
|
|
|
grabGPSandID = false;
|
|
|
|
|
|
System.out.println("6Entry: ");
|
|
|
break;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequiresApi(api = Build.VERSION_CODES.O)
|
|
|
public void setVibrationInDataBase(int k)
|
|
|
public void setVibrationInDataBase(int k)
|
|
|
{
|
|
|
{
|
|
|
mDatenbank = FirebaseDatabase.getInstance().getReference();
|
|
|
mDatenbank = FirebaseDatabase.getInstance().getReference();
|
|
|
mDatenbank.child("overviewnodes").child("IDG" + k).child("a_androidid").setValue(getandroidid());
|
|
|
mDatenbank.child("overviewnodes").child("IDG" + k).child("a_androidid").setValue(getandroidid());
|
|
|
|
|
|
/*
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
|
mDatenbank.child("overviewnodes").child("IDG" + k).child("b_localdatetime").setValue(LocalDateTime.now().toString());
|
|
|
mDatenbank.child("overviewnodes").child("IDG" + k).child("b_localdatetime").setValue(LocalDateTime.now().toString());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
mDatenbank.child("overviewnodes").child("IDG" + k).child("b_localdatetime").setValue(LocalDateTime.now(ZoneOffset.UTC).toString());
|
|
|
mDatenbank.child("overviewnodes").child("IDG" + k).child("c_ip").setValue(getDeviceIpAdress());
|
|
|
mDatenbank.child("overviewnodes").child("IDG" + k).child("c_ip").setValue(getDeviceIpAdress());
|
|
|
if (useOwnGPS)
|
|
|
if (useOwnGPS)
|
|
|
{
|
|
|
{
|
|
|
|
|
|
mDatenbank.child("overviewnodes").child("IDG" + k).child("f_nativegps").setValue(true);
|
|
|
mDatenbank.child("overviewnodes").child("IDG" + k).child("d_breitengrad").setValue(currentLocation.getLatitude()); //aktueller Breitengrad
|
|
|
mDatenbank.child("overviewnodes").child("IDG" + k).child("d_breitengrad").setValue(currentLocation.getLatitude()); //aktueller Breitengrad
|
|
|
mDatenbank.child("overviewnodes").child("IDG" + k).child("e_laengengrad").setValue(currentLocation.getLongitude()); //aktueller Längergrad
|
|
|
mDatenbank.child("overviewnodes").child("IDG" + k).child("e_laengengrad").setValue(currentLocation.getLongitude()); //aktueller Längergrad
|
|
|
}else{
|
|
|
}else{
|
|
|
mDatenbank.child("overviewnodes").child("IDG" + k).child("d_breitengrad").setValue(breitengrad); //aktueller Breitengrad
|
|
|
mDatenbank.child("overviewnodes").child("IDG" + k).child("d_breitengrad").setValue(breitengrad); //aktueller Breitengrad
|
|
|
mDatenbank.child("overviewnodes").child("IDG" + k).child("e_laengengrad").setValue(laengengrad); //aktueller Längergrad
|
|
|
mDatenbank.child("overviewnodes").child("IDG" + k).child("e_laengengrad").setValue(laengengrad); //aktueller Längergrad
|
|
|
|
|
|
mDatenbank.child("overviewnodes").child("IDG" + k).child("f_nativegps").setValue(false);
|
|
|
}
|
|
|
}
|
|
|
mDatenbank.child("overviewnodes").child("IDG" + k).child("f_nativegps").setValue(false);
|
|
|
|
|
|
mDatenbank.child("overviewnodes").child("IDG" + k).child("g_vibration").setValue(true);
|
|
|
mDatenbank.child("overviewnodes").child("IDG" + k).child("g_vibration").setValue(true);
|
|
|
mDatenbank.child("overviewnodes").child("IDG" + k).child("h_timestamp").setValue(Calendar.getInstance().getTimeInMillis()); //aktueller Zeitstempel wird in Datenbank eingetragen
|
|
|
mDatenbank.child("overviewnodes").child("IDG" + k).child("h_timestamp").setValue(Calendar.getInstance().getTimeInMillis()); //aktueller Zeitstempel wird in Datenbank eingetragen
|
|
|
mDatenbank.child("overviewnodes").child("IDG" + k).child("i_amplitude").setValue(1000);
|
|
|
mDatenbank.child("overviewnodes").child("IDG" + k).child("i_amplitude").setValue(1000);
|