From 0cca2e86c5921580b5aaee64bf33f858e58801af Mon Sep 17 00:00:00 2001
From: chan24 <aakaschan24@gmail.com>
Date: Fri, 21 Apr 2017 12:33:14 +0530
Subject: [PATCH] nav my location added

---
 app/build.gradle                              |  1 +
 app/src/main/AndroidManifest.xml              |  5 +-
 .../smartplanner/MapsActivityLocation.java    | 60 +++++++++++++++++++
 .../example/chan24/smartplanner/UserArea.java |  2 +-
 app/src/main/res/layout/activity_maps.xml     |  4 +-
 .../res/layout/activity_maps_location.xml     |  8 +++
 app/src/main/res/values/strings.xml           |  1 +
 7 files changed, 77 insertions(+), 4 deletions(-)
 create mode 100644 app/src/main/java/com/example/chan24/smartplanner/MapsActivityLocation.java
 create mode 100644 app/src/main/res/layout/activity_maps_location.xml

diff --git a/app/build.gradle b/app/build.gradle
index 8fa90c5..dc1567d 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -39,4 +39,5 @@ dependencies {
 
 
 
+
 apply plugin: 'com.google.gms.google-services'
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 05c3ac9..a04f7b4 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -52,7 +52,10 @@
         <activity android:name=".ProfileActivity" />
         <activity
             android:name=".MapsActivity"
-            android:label="@string/title_activity_maps"></activity>
+            android:label="@string/title_activity_maps" />
+        <activity
+            android:name=".MapsActivityLocation"
+            android:label="@string/title_activity_maps_location"></activity>
     </application>
 
 </manifest>
\ No newline at end of file
diff --git a/app/src/main/java/com/example/chan24/smartplanner/MapsActivityLocation.java b/app/src/main/java/com/example/chan24/smartplanner/MapsActivityLocation.java
new file mode 100644
index 0000000..8d65977
--- /dev/null
+++ b/app/src/main/java/com/example/chan24/smartplanner/MapsActivityLocation.java
@@ -0,0 +1,60 @@
+package com.example.chan24.smartplanner;
+
+import android.content.pm.PackageManager;
+import android.support.v4.app.ActivityCompat;
+import android.support.v4.app.FragmentActivity;
+import android.os.Bundle;
+
+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 MapsActivityLocation extends FragmentActivity implements OnMapReadyCallback {
+
+    private GoogleMap mMap;
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_maps_location);
+        // 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);
+    }
+
+
+    /**
+     * Manipulates the map once available.
+     * This callback is triggered when the map is ready to be used.
+     * This is where we can add markers or lines, add listeners or move the camera. In this case,
+     * we just add a marker near Sydney, Australia.
+     * If Google Play services is not installed on the device, the user will be prompted to install
+     * it inside the SupportMapFragment. This method will only be triggered once the user has
+     * installed Google Play services and returned to the app.
+     */
+    @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));*/
+
+        mMap = googleMap;
+
+        if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION)
+                != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this,
+                android.Manifest.permission.ACCESS_COARSE_LOCATION)
+                != PackageManager.PERMISSION_GRANTED) {
+            return;
+        }
+        mMap.setMyLocationEnabled(true);
+        mMap.getUiSettings().setCompassEnabled(true);
+        mMap.getUiSettings().setZoomControlsEnabled(true);
+    }
+}
diff --git a/app/src/main/java/com/example/chan24/smartplanner/UserArea.java b/app/src/main/java/com/example/chan24/smartplanner/UserArea.java
index cde04ca..dd57527 100644
--- a/app/src/main/java/com/example/chan24/smartplanner/UserArea.java
+++ b/app/src/main/java/com/example/chan24/smartplanner/UserArea.java
@@ -85,7 +85,7 @@ public class UserArea extends AppCompatActivity {
                         break;
 
                     case R.id.my_location :
-                        Intent i1 =new Intent(getApplicationContext(),MapsActivity.class);
+                        Intent i1 =new Intent(getApplicationContext(),MapsActivityLocation.class);
                         startActivity(i1);
                         mDrawerLayout.closeDrawers();
                         break;
diff --git a/app/src/main/res/layout/activity_maps.xml b/app/src/main/res/layout/activity_maps.xml
index 15c21b4..44134d9 100644
--- a/app/src/main/res/layout/activity_maps.xml
+++ b/app/src/main/res/layout/activity_maps.xml
@@ -6,7 +6,7 @@
         xmlns:tools="http://schemas.android.com/tools"
         android:id="@+id/mainCoordinatorLayout"
         android:layout_width="match_parent"
-        android:layout_height="500dp"
+        android:layout_height="550dp"
         android:fitsSystemWindows="true"
         tools:context=".MapsActivity">
 
@@ -15,7 +15,7 @@
             android:id="@+id/map"
             android:name="com.google.android.gms.maps.SupportMapFragment"
             android:layout_width="match_parent"
-            android:layout_height="500dp"
+            android:layout_height="550dp"
             tools:context="com.example.chan24.smartplanner.MapsActivity" />
 
 
diff --git a/app/src/main/res/layout/activity_maps_location.xml b/app/src/main/res/layout/activity_maps_location.xml
new file mode 100644
index 0000000..3ad2e4d
--- /dev/null
+++ b/app/src/main/res/layout/activity_maps_location.xml
@@ -0,0 +1,8 @@
+<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:id="@+id/map"
+    android:name="com.google.android.gms.maps.SupportMapFragment"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    tools:context="com.example.chan24.smartplanner.MapsActivityLocation" />
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 16bcde1..dd3e0ce 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -3,4 +3,5 @@
     <string name="title_activity_maps">Map</string>
     <string name="open">Open</string>
     <string name="close">Close</string>
+    <string name="title_activity_maps_location">Map</string>
 </resources>
-- 
GitLab