|
|
@@ -17,6 +17,7 @@ import android.widget.TextView; |
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
import androidx.annotation.RequiresApi;
|
|
|
|
import androidx.core.app.ActivityCompat;
|
|
|
|
import androidx.core.content.ContextCompat;
|
|
|
|
import androidx.fragment.app.FragmentActivity;
|
|
|
@@ -38,6 +39,7 @@ import com.google.firebase.database.FirebaseDatabase; |
|
|
|
import com.google.firebase.database.ValueEventListener;
|
|
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
import java.time.ZoneOffset;
|
|
|
|
import java.util.Calendar;
|
|
|
|
import java.util.Date;
|
|
|
|
|
|
|
@@ -91,18 +93,8 @@ public class SensorMapsActivity extends FragmentActivity implements OnMapReadyCa |
|
|
|
getVibrationAbility();
|
|
|
|
System.out.println("Global Shit: " + globalShit);
|
|
|
|
}
|
|
|
|
@Override
|
|
|
|
protected void onPause()
|
|
|
|
{
|
|
|
|
|
|
|
|
super.onPause();
|
|
|
|
}
|
|
|
|
@Override
|
|
|
|
protected void onResume()
|
|
|
|
{
|
|
|
|
|
|
|
|
super.onResume();
|
|
|
|
}
|
|
|
|
//#####################################################################################################################################################################
|
|
|
|
//################################################################## vvv ShakeCode vvv ##############################################################################
|
|
|
|
private void getVibrationAbility()
|
|
|
@@ -126,12 +118,12 @@ public class SensorMapsActivity extends FragmentActivity implements OnMapReadyCa |
|
|
|
|
|
|
|
private void setVibrationTimer(long msDelay, int duration, int amplitude, int index)
|
|
|
|
{
|
|
|
|
System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!setVibrationTimer wurde getriggert mit Index " + index);
|
|
|
|
new CountDownTimer(msDelay, 1000) {
|
|
|
|
public void onTick(long millisUntilFinished) {
|
|
|
|
((TextView) findViewById(R.id.txtSensor)).setText("Earthquake hits in " + millisUntilFinished / 1000 + " s");
|
|
|
|
}
|
|
|
|
|
|
|
|
@RequiresApi(api = Build.VERSION_CODES.O)
|
|
|
|
public void onFinish() {
|
|
|
|
Toast.makeText(getApplicationContext(), "The Ground is shaking!", Toast.LENGTH_SHORT).show();
|
|
|
|
performVibration(duration, amplitude);
|
|
|
@@ -146,11 +138,10 @@ public class SensorMapsActivity extends FragmentActivity implements OnMapReadyCa |
|
|
|
if(!mDeviceCanVibrate)
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
v.cancel(); //stop vibration if still running
|
|
|
@@ -417,21 +408,29 @@ public class SensorMapsActivity extends FragmentActivity implements OnMapReadyCa |
|
|
|
useOwnGPS = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
System.out.println("useOWNgps: " + useOwnGPS);
|
|
|
|
//Wichtig zur Verwendung von GPS-Daten explizit aus der Datenbank
|
|
|
|
if(!useOwnGPS && grabGPSandID)
|
|
|
|
{
|
|
|
|
System.out.println("Entry: ");
|
|
|
|
for (int f = 1; f<=indexMax; f++)
|
|
|
|
{
|
|
|
|
System.out.println("1Entry: ");
|
|
|
|
if(f>=2 && f<=indexMax)
|
|
|
|
{
|
|
|
|
System.out.println("2Entry: ");
|
|
|
|
if(analyzeIfAnroidIdIsEmpty(data,f))
|
|
|
|
{
|
|
|
|
System.out.println("3Entry: ");
|
|
|
|
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();
|
|
|
|
System.out.println("4Entry: ");
|
|
|
|
breitengrad = Double.parseDouble(breitengradString);
|
|
|
|
laengengrad = Double.parseDouble(laengengradString);
|
|
|
|
System.out.println("5Entry: ");
|
|
|
|
allocateIDtoDatabaseSlot(f);
|
|
|
|
grabGPSandID = false;
|
|
|
|
System.out.println("6Entry: ");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
@@ -507,23 +506,29 @@ public class SensorMapsActivity extends FragmentActivity implements OnMapReadyCa |
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@RequiresApi(api = Build.VERSION_CODES.O)
|
|
|
|
public void setVibrationInDataBase(int k)
|
|
|
|
{
|
|
|
|
mDatenbank = FirebaseDatabase.getInstance().getReference();
|
|
|
|
mDatenbank.child("overviewnodes").child("IDG" + k).child("a_androidid").setValue(getandroidid());
|
|
|
|
/*
|
|
|
|
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(ZoneOffset.UTC).toString());
|
|
|
|
mDatenbank.child("overviewnodes").child("IDG" + k).child("c_ip").setValue(getDeviceIpAdress());
|
|
|
|
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("e_laengengrad").setValue(currentLocation.getLongitude()); //aktueller Längergrad
|
|
|
|
}else{
|
|
|
|
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("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("h_timestamp").setValue(Calendar.getInstance().getTimeInMillis()); //aktueller Zeitstempel wird in Datenbank eingetragen
|
|
|
|
mDatenbank.child("overviewnodes").child("IDG" + k).child("i_amplitude").setValue(1000);
|