From 17afc10fde23e6205e4ae9c26b0695bcc243ebeb Mon Sep 17 00:00:00 2001 From: Ville Haapavaara Date: Tue, 25 Apr 2017 09:43:43 +0300 Subject: [PATCH 01/19] Set the map move to a location when a location is changed --- .../ville/fi/hikemate/Activities/MapActivity.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/ville/fi/hikemate/Activities/MapActivity.java b/app/src/main/java/ville/fi/hikemate/Activities/MapActivity.java index b171e15..8c9208c 100644 --- a/app/src/main/java/ville/fi/hikemate/Activities/MapActivity.java +++ b/app/src/main/java/ville/fi/hikemate/Activities/MapActivity.java @@ -51,7 +51,7 @@ protected void onCreate(Bundle savedInstanceState) { if (ContextCompat.checkSelfPermission(host, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { - + System.out.println("Asking permissions, no permissions"); Debug.print(host, "Asking permissions", "Requesting permission", "No permissions, dialog", 1); // Should we show an explanation? @@ -75,11 +75,13 @@ protected void onCreate(Bundle savedInstanceState) { // result of the request. } } else { - + System.out.println("Asking permissions, we have a permission"); ActivityCompat.requestPermissions(thisActivity, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, MY_PERMISSIONS_REQUEST_LOCATION); + + /* Debug.print(host, "Asking permissions", "Requesting permission", "We have a permission", 1); @@ -98,7 +100,6 @@ protected void onCreate(Bundle savedInstanceState) { @Override public void onMapReady(GoogleMap googleMap) { mMap = googleMap; - mMap.moveCamera(CameraUpdateFactory.newLatLng(new LatLng(location.getLatitude(), location.getLongitude()))); } @Override @@ -109,10 +110,6 @@ public void onRequestPermissionsResult(int requestCode, case MY_PERMISSIONS_REQUEST_LOCATION: { if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { - - // permission was granted, yay! Do the - // contacts-related task you need to do. - try { locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener); Debug.print(host, "onRequestPermissionResult", "LocationGranted", "LocationManager requesting", 1); @@ -124,12 +121,10 @@ public void onRequestPermissionsResult(int requestCode, // permission denied, boo! Disable the // functionality that depends on this permission. + // TODO: Go back to MainActivity. } return; } - - // other 'case' lines to check for other - // permissions this app might request } } From 160cc6278ac4180f37cb290239ba8018d6e07a2b Mon Sep 17 00:00:00 2001 From: Ville Haapavaara Date: Tue, 25 Apr 2017 12:44:14 +0300 Subject: [PATCH 02/19] Add buttons for canceling and saving a hike --- app/src/main/res/layout/activity_map.xml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/layout/activity_map.xml b/app/src/main/res/layout/activity_map.xml index 60a2825..3720104 100644 --- a/app/src/main/res/layout/activity_map.xml +++ b/app/src/main/res/layout/activity_map.xml @@ -15,7 +15,16 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/map" - android:text="Nappi" - android:id="@+id/button2" /> + android:text="Cancel" + android:id="@+id/button_cancel" + android:onClick=""/> + +