Skip to content
This repository has been archived by the owner on Oct 25, 2019. It is now read-only.

Commit

Permalink
#2 added map view
Browse files Browse the repository at this point in the history
  • Loading branch information
Malah committed Feb 4, 2019
1 parent 817b9d0 commit 2d4c062
Show file tree
Hide file tree
Showing 9 changed files with 105 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
/build
/captures
.externalNativeBuild
local.properties
local.properties
app/src/debug/
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# Projet MMM

## Binômes
* Gwénolé LE HENAF
* Charles LARZILLIERE
* Gwénolé LE HENAFF
* Hugo BANNIER

## Technologies
* Android
* Java 8
* Gradle
* Lombok

## Build
Ajouter la clé API de google map
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ android {

dependencies {
implementation "android.arch.persistence.room:runtime:1.1.1"
implementation 'com.google.android.gms:play-services-maps:16.0.0'
annotationProcessor 'android.arch.persistence.room:compiler:1.1.1'
compileOnly 'org.projectlombok:lombok:1.18.4'
annotationProcessor 'org.projectlombok:lombok:1.18.4'
Expand Down
21 changes: 20 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="fr.istic.hbmlh.photoloc">

<uses-feature android:name="android.hardware.camera" android:required="true" />
<uses-feature
android:name="android.hardware.camera"
android:required="true" />

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<application
Expand All @@ -12,6 +15,22 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">

<!--
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>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ protected void onCreate(Bundle savedInstanceState) {
photoLocRepository = new RepositoriesImpl(this).getPhotoLocRepository();
photoService = new PhotoServiceImpl(photoLocRepository);
btnPhoto.setOnClickListener((view) -> photoService.takePicture(this));
btnMap.setOnClickListener(v -> startActivity(new Intent(this, MapsActivity.class)));
}

@Override
Expand Down
46 changes: 46 additions & 0 deletions app/src/main/java/fr/istic/hbmlh/photoloc/MapsActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package fr.istic.hbmlh.photoloc;

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));
}
}
9 changes: 9 additions & 0 deletions app/src/main/res/layout/activity_maps.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-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=".MapsActivity" />
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
<string name="app_name">PhotoLoc</string>
<string name="btn_photo">Take a picture</string>
<string name="btn_map">Show map</string>
<string name="title_activity_maps">Map</string>
</resources>
20 changes: 20 additions & 0 deletions app/src/release/res/values/google_maps_api.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<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>

0 comments on commit 2d4c062

Please sign in to comment.