diff --git a/.idea/gradle.xml b/.idea/gradle.xml index fe72da5070ca010e95601473aa0196fedfeae55a..0e23f8edad758c196e8d59c0d4b7a17807c6780f 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -5,7 +5,7 @@ <GradleProjectSettings> <option name="distributionType" value="LOCAL" /> <option name="externalProjectPath" value="$PROJECT_DIR$" /> - <option name="gradleHome" value="C:\Program Files\Android\Android Studio\gradle\gradle-2.14.1" /> + <option name="gradleHome" value="$APPLICATION_HOME_DIR$/gradle/gradle-2.14.1" /> <option name="modules"> <set> <option value="$PROJECT_DIR$" /> diff --git a/.idea/misc.xml b/.idea/misc.xml index fbb68289f4352bf149aa31a2c9940faa99174224..5d19981032aa01b060f5a568641d7a8840cc90dc 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -37,7 +37,7 @@ <ConfirmationsSetting value="0" id="Add" /> <ConfirmationsSetting value="0" id="Remove" /> </component> - <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK"> + <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK"> <output url="file://$PROJECT_DIR$/build/classes" /> </component> <component name="ProjectType"> diff --git a/.idea/modules.xml b/.idea/modules.xml index 2b7958ab84b721004a5c381e67de6e267b87bb8b..280fecef02a1dfb103fd81e385e70115f834f9d1 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -2,7 +2,7 @@ <project version="4"> <component name="ProjectModuleManager"> <modules> - <module fileurl="file://$PROJECT_DIR$/Smart Planner.iml" filepath="$PROJECT_DIR$/Smart Planner.iml" /> + <module fileurl="file://$PROJECT_DIR$/SmartPlanner.iml" filepath="$PROJECT_DIR$/SmartPlanner.iml" /> <module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" /> </modules> </component> diff --git a/app/build.gradle b/app/build.gradle index c43db8ffc19e2a4de8bc8729e8eba844a0ca168f..74d6bb5955bac3ce10ab2a1c92b621de31a09a73 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -25,6 +25,7 @@ dependencies { exclude group: 'com.android.support', module: 'support-annotations' }) compile 'com.android.support:appcompat-v7:25.1.0' - testCompile 'junit:junit:4.12' compile 'com.android.volley:volley:1.0.0' + compile 'com.google.android.gms:play-services:10.0.1' + testCompile 'junit:junit:4.12' } diff --git a/app/src/debug/res/values/google_maps_api.xml b/app/src/debug/res/values/google_maps_api.xml new file mode 100644 index 0000000000000000000000000000000000000000..a4e410238c0b9ca0b7036e34ef92cdb176f0c7ff --- /dev/null +++ b/app/src/debug/res/values/google_maps_api.xml @@ -0,0 +1,21 @@ +<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=0A:28:96:D7:DC:0E:9A:A4:08:7E:EB:25:FC:89:B6:7F:E3:33:0B:E8%3Bcom.example.chan24.smartplanner + + You can also add your credentials to an existing key, using this line: + 0A:28:96:D7:DC:0E:9A:A4:08:7E:EB:25:FC:89:B6:7F:E3:33:0B:E8;com.example.chan24.smartplanner + + 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"> + AIzaSyCiYMdcQTAJIqgGOcbY88Oq5EYpwfJUyk0 + </string> +</resources> diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d7a91d48f7499c595742acf7ef7a7330e8d46b42..1feaaa1ca691dc2c906f9f8dd04feabb014dcb45 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,6 +2,13 @@ <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.chan24.smartplanner"> + <!-- + 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" /> + <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" @@ -16,7 +23,22 @@ </intent-filter> </activity> <activity android:name=".RegisterActivity" /> - <activity android:name=".UserArea"></activity> + <activity android:name=".UserArea" /> + <!-- + The API key for Google Maps-based APIs is defined as a string resource. + (See the file "res/values/google_maps_api.xml"). + Note that the API key is linked to the encryption key used to sign the APK. + You need a different API key for each encryption key, including the release key that is used to + sign the APK for publishing. + You can define the keys for the debug and release targets in src/debug/ and src/release/. + --> + <meta-data + android:name="com.google.android.geo.API_KEY" + android:value="@string/google_maps_key" /> + + <activity + android:name=".MapsActivity" + android:label="@string/title_activity_maps"></activity> </application> </manifest> \ No newline at end of file diff --git a/app/src/main/java/com/example/chan24/smartplanner/LoginActivity.java b/app/src/main/java/com/example/chan24/smartplanner/LoginActivity.java index b1dcad6d94f2c675414e003d17e45c76353f5f43..4671f651cb1733ecde088f5f799e55f5226e8e87 100644 --- a/app/src/main/java/com/example/chan24/smartplanner/LoginActivity.java +++ b/app/src/main/java/com/example/chan24/smartplanner/LoginActivity.java @@ -1,8 +1,11 @@ package com.example.chan24.smartplanner; +import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; +import android.view.View; +import android.widget.Button; public class LoginActivity extends AppCompatActivity { @@ -10,5 +13,6 @@ public class LoginActivity extends AppCompatActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); + } } diff --git a/app/src/main/java/com/example/chan24/smartplanner/MapsActivity.java b/app/src/main/java/com/example/chan24/smartplanner/MapsActivity.java new file mode 100644 index 0000000000000000000000000000000000000000..78c1778f08231531b9a3ab1abe27a4484aa90c72 --- /dev/null +++ b/app/src/main/java/com/example/chan24/smartplanner/MapsActivity.java @@ -0,0 +1,46 @@ +package com.example.chan24.smartplanner; + +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 MapsActivity extends FragmentActivity implements OnMapReadyCallback { + + private GoogleMap mMap; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_maps); + // 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)); + } +} diff --git a/app/src/main/res/layout/activity_maps.xml b/app/src/main/res/layout/activity_maps.xml new file mode 100644 index 0000000000000000000000000000000000000000..47d7f50efd0c510ddbe1758b52ce06f2a2d30316 --- /dev/null +++ b/app/src/main/res/layout/activity_maps.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.MapsActivity" /> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 996b2bcad33e86b7f08b7b2c9548b2950c85b60d..6669eb82b999dc6184be6354594269a46af63244 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,3 +1,4 @@ <resources> <string name="app_name">SmartPlanner</string> + <string name="title_activity_maps">Map</string> </resources> diff --git a/app/src/release/res/values/google_maps_api.xml b/app/src/release/res/values/google_maps_api.xml new file mode 100644 index 0000000000000000000000000000000000000000..fa88c612644439299cf42e81f9ea12e0f6e09598 --- /dev/null +++ b/app/src/release/res/values/google_maps_api.xml @@ -0,0 +1,22 @@ +<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>