Compare commits

...

No commits in common. "ea351e5789fb0379da83f72ecf39b4fa2426e501" and "437a401a5dd868c546a700be8a49b2b53974eb8c" have entirely different histories.

20 changed files with 210 additions and 99 deletions

1
.idea/gradle.xml generated
View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>

6
.idea/vcs.xml generated Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

View File

@ -7,8 +7,8 @@ android {
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "de.edotzlaff.maps0123"
minSdkVersion 24
applicationId "de.edotzlaff.schockwelle"
minSdkVersion 23
targetSdkVersion 30
versionCode 1
versionName "1.0"
@ -30,12 +30,12 @@ android {
dependencies {
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'com.google.android.gms:play-services-maps:17.0.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'com.google.android.gms:play-services-maps:17.0.1'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation "com.google.android.gms:play-services-location:15.0.1" //Import to find the location from the device
implementation "com.google.android.gms:play-services-location:15.0.1" //Important to find the location from the device
}

View File

@ -1,4 +1,4 @@
package de.edotzlaff.maps0123;
package de.edotzlaff.schockwelle;
import android.content.Context;
@ -21,6 +21,6 @@ public class ExampleInstrumentedTest {
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("de.edotzlaff.maps0123", appContext.getPackageName());
assertEquals("de.edotzlaff.schockwelle", appContext.getPackageName());
}
}

View File

@ -1,24 +1,4 @@
<resources>
<!--
TODO: Before you run your application, you need a Google Maps API key.
To get one, follow this link, follow the directions and press "Create" at the end:
https://console.developers.google.com/flows/enableapi?apiid=maps_android_backend&keyType=CLIENT_SIDE_ANDROID&r=D2:BC:D8:1A:07:E8:86:EC:AB:EC:EC:EF:CB:1B:C0:A6:B7:FB:69:56%3Bde.edotzlaff.maps0123
You can also add your credentials to an existing key, using these values:
Package name:
de.edotzlaff.maps0123
SHA-1 certificate fingerprint:
D2:BC:D8:1A:07:E8:86:EC:AB:EC:EC:EF:CB:1B:C0:A6:B7:FB:69:56
Alternatively, follow the directions here:
https://developers.google.com/maps/documentation/android/start#get-key
Once you have your key (it starts with "AIza"), replace the "google_maps_key"
string in this file.
-->
<string name="google_maps_key" templateMergeStrategy="preserve" translatable="false">AIzaSyCCnjanFAzxuH91tD206IjaAU4_ymSgug0</string>
</resources>

View File

@ -1,11 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.edotzlaff.maps0123">
package="de.edotzlaff.schockwelle">
<!--
The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
Google Maps Android API v2, but you must specify either coarse or fine
location permissions for the "MyLocation" functionality.
-->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
@ -13,8 +17,8 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Maps0123">
<activity android:name=".map"></activity>
android:theme="@style/Theme.Schockwelle">
<!--
The API key for Google Maps-based APIs is defined as a string resource.
(See the file "res/values/google_maps_api.xml").
@ -28,8 +32,12 @@
android:value="@string/google_maps_key" />
<activity
android:name=".MapsActivity"
android:label="@string/title_activity_maps">
android:name=".SensorMapsActivity"
android:label="@string/title_activity_sensor_maps"></activity>
<activity
android:name=".EarthquakeMapsActivity"
android:label="@string/title_activity_earthquake_maps" />
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

View File

@ -1,4 +1,4 @@
package de.edotzlaff.maps0123;
package de.edotzlaff.schockwelle;
import android.Manifest;
import android.content.pm.PackageManager;
@ -8,9 +8,9 @@ import android.util.Log;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.FragmentActivity;
import com.google.android.gms.location.FusedLocationProviderClient;
import com.google.android.gms.location.LocationServices;
@ -23,8 +23,7 @@ import com.google.android.gms.maps.model.MarkerOptions;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
public class map extends AppCompatActivity implements OnMapReadyCallback {
public class EarthquakeMapsActivity extends FragmentActivity implements OnMapReadyCallback {
private static final String TAG = "MainActivity";
private static final String FINE_LOCATION = Manifest.permission.ACCESS_FINE_LOCATION;
@ -38,7 +37,7 @@ public class map extends AppCompatActivity implements OnMapReadyCallback {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
setContentView(R.layout.activity_earthquake_maps);
getLocationPermission();
}
@ -55,6 +54,7 @@ public class map extends AppCompatActivity implements OnMapReadyCallback {
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
mLocationPermissionsGranted = false;
switch (requestCode) {
@ -68,11 +68,13 @@ public class map extends AppCompatActivity implements OnMapReadyCallback {
}
}
private void initMap() {
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
@Override
public void onMapReady(GoogleMap googleMap) {
Toast.makeText(this, "Map is ready", Toast.LENGTH_SHORT).show();
mMap = googleMap;
@ -88,11 +90,11 @@ public class map extends AppCompatActivity implements OnMapReadyCallback {
}
mMap.setMyLocationEnabled(true);
}
// Add a marker in Sydney and move the camera
//LatLng sydney = new LatLng(-50, 151);
//LatLng sydney = new LatLng(-34, 151);
//mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
//mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
}
private void getDeviceLocation(){
@ -108,12 +110,12 @@ public class map extends AppCompatActivity implements OnMapReadyCallback {
public void onComplete(@NonNull Task task) {
if (task.isSuccessful()){
Location currentLocation = (Location) task.getResult();
Location currentLocation = (Location) task.getResult(); //TODO Aron hier erhält die Anwendung die GPS Positionen
moveCamera(new LatLng(currentLocation.getLatitude(), currentLocation.getLongitude()),15f);
}
else{
Toast.makeText(map.this, "Current Location unavailable", Toast.LENGTH_SHORT).show();
Toast.makeText(EarthquakeMapsActivity.this, "Current Location unavailable", Toast.LENGTH_SHORT).show();
}
}
});
@ -128,4 +130,6 @@ public class map extends AppCompatActivity implements OnMapReadyCallback {
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latlng, zoom));
}
//TODO Aron Daten an DB senden
}

View File

@ -1,9 +1,11 @@
package de.edotzlaff.maps0123;
package de.edotzlaff.schockwelle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentActivity;
import android.app.Dialog;
import android.content.Intent;
import android.hardware.Sensor;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
@ -12,22 +14,18 @@ import android.widget.Toast;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GoogleApiAvailability;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
public class MapsActivity extends FragmentActivity {
public class MainActivity extends FragmentActivity {
private static final String TAG = "MainActivity";
private static final int ERROR_DIALOG_REQUEST = 9001;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map); //IMPORTANT: MapsActivity führt zur activity_map.xml (nicht zur activity_maps)
setContentView(R.layout.activity_main);
if (isServiceOK()){
init();
@ -35,21 +33,33 @@ public class MapsActivity extends FragmentActivity {
}
private void init(){
Button btnMap = (Button) findViewById(R.id.btnMap);
btnMap.setOnClickListener(new View.OnClickListener() {
Button btnEarthquake = (Button) findViewById(R.id.btnEarthquake);
btnEarthquake.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MapsActivity.this, map.class);
Intent intent = new Intent(MainActivity.this, EarthquakeMapsActivity.class);
startActivity(intent);
}
});
Button btnSensor = (Button) findViewById(R.id.btnSensor);
btnSensor.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this, SensorMapsActivity.class);
startActivity(intent);
}
});
}
public boolean isServiceOK(){
Log.d(TAG, "isServicesOK(): checking google services version");
int available = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(MapsActivity.this);
int available = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(MainActivity.this);
if (available== ConnectionResult.SUCCESS){
Log.d(TAG,"isServicesOK: Google Play Services is working");
@ -57,7 +67,7 @@ public class MapsActivity extends FragmentActivity {
}
else if (GoogleApiAvailability.getInstance().isUserResolvableError(available)){
Log.d(TAG, "isServicesOK(): an error occured but we can fix it");
Dialog dialog = GoogleApiAvailability.getInstance().getErrorDialog(MapsActivity.this, available, ERROR_DIALOG_REQUEST);
Dialog dialog = GoogleApiAvailability.getInstance().getErrorDialog(MainActivity.this, available, ERROR_DIALOG_REQUEST);
dialog.show();
}
else {
@ -65,5 +75,4 @@ public class MapsActivity extends FragmentActivity {
}
return false;
}
}

View File

@ -0,0 +1,68 @@
package de.edotzlaff.schockwelle;
import androidx.fragment.app.FragmentActivity;
import android.location.Location;
import android.os.Bundle;
import android.widget.TextView;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import org.w3c.dom.Text;
public class SensorMapsActivity extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sensor_maps);
TextView tv= (TextView) findViewById(R.id.txtSensor);
initMap();
}
void initMap(){
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
// Add a marker in Sydney and move the camera
LatLng sydney = new LatLng(-34, 151);
mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
}
//TODO Aron Daten von DB abfragen
//TODO Edward Distanz zwischen zwei Punkten berechnen
//TODO Edward Dauer für Timer berechnen bis Smartphone vibriert
/*
private float distance(double currentlatitude, double currentlongitude, double originLat, double originLon) {
float[] results = new float[1];
Location.distanceBetween(currentlatitude, currentlongitude, -34, 151, results);
float distanceInMeters = results[0];
return distanceInMeters;
}
*/
}

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".EarthquakeMapsActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Shake your Smartphone for a Earthquake"
android:layout_centerHorizontal="true"
android:id="@+id/txtEarthquake"/>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_below="@+id/txtEarthquake"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".EarthquakeMapsActivity" />
</RelativeLayout>

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btnEarthquake"
android:text="Generate Earthquake"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btnSensor"
android:text="Be a Sensor"
android:layout_centerHorizontal="true"
android:layout_below="@id/btnEarthquake"/>
</RelativeLayout>

View File

@ -1,15 +0,0 @@
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".map">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Map"
android:id="@+id/btnMap"/>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -1,16 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
tools:context=".EarthquakeMapsActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Timer till vibration"
android:layout_centerHorizontal="true"
android:id="@+id/txtSensor"/>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_below="@+id/txtSensor"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MapsActivity" />
tools:context=".SensorMapsActivity" />
</RelativeLayout>

View File

@ -1,6 +1,6 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.Maps0123" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<style name="Theme.Schockwelle" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_200</item>
<item name="colorPrimaryVariant">@color/purple_700</item>

View File

@ -1,4 +1,5 @@
<resources>
<string name="app_name">maps0123</string>
<string name="title_activity_maps">Map</string>
<string name="app_name">Schockwelle</string>
<string name="title_activity_earthquake_maps">Map</string>
<string name="title_activity_sensor_maps">Map</string>
</resources>

View File

@ -1,6 +1,6 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.Maps0123" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<style name="Theme.Schockwelle" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_500</item>
<item name="colorPrimaryVariant">@color/purple_700</item>

View File

@ -1,20 +1,4 @@
<resources>
<!--
TODO: Before you release your application, you need a Google Maps API key.
To do this, you can either add your release key credentials to your existing
key, or create a new key.
Note that this file specifies the API key for the release build target.
If you have previously set up a key for the debug target with the debug signing certificate,
you will also need to set up a key for your release certificate.
Follow the directions here:
https://developers.google.com/maps/documentation/android/signup
Once you have your key (it starts with "AIza"), replace the "google_maps_key"
string in this file.
-->
<string name="google_maps_key" templateMergeStrategy="preserve" translatable="false">YOUR_KEY_HERE</string>
</resources>

View File

@ -1,4 +1,4 @@
package de.edotzlaff.maps0123;
package de.edotzlaff.schockwelle;
import org.junit.Test;

View File

@ -1,4 +1,4 @@
#Thu Jun 10 16:33:45 CEST 2021
#Mon Jun 14 19:58:23 CEST 2021
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME

View File

@ -1,2 +1,2 @@
include ':app'
rootProject.name = "maps0123"
rootProject.name = "Schockwelle"