Skip to content
This repository has been archived by the owner on Apr 21, 2021. It is now read-only.

Commit

Permalink
Correctif geolocalisation
Browse files Browse the repository at this point in the history
  • Loading branch information
LauriFernandez committed Oct 19, 2017
1 parent f6064a8 commit 724308b
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 55 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,20 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/builds" />
Expand All @@ -101,7 +101,7 @@
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="jdk" jdkName="Android API 25 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="support-core-ui-26.0.0-alpha1" level="project" />
<orderEntry type="library" exported="" name="gridlayout-v7-26.0.0-alpha1" level="project" />
Expand Down
3 changes: 1 addition & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 26
compileSdkVersion 25
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "squiddle.sheshire.apomalyn.qc.ca.nearumix"
Expand All @@ -24,7 +24,6 @@ dependencies {
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})

compile 'com.google.android.gms:play-services-maps:11.0.4'
compile 'com.google.android.gms:play-services-auth:11.0.4'
compile 'com.android.support:appcompat-v7:26.+'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package squiddle.sheshire.apomalyn.qc.ca.nearumix;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.location.LocationManager;

/**
* Created by sheshire on 17-10-19.
*/

public class AlertReceiver extends BroadcastReceiver {

@Override

public void onReceive(Context context, Intent intent) {

// Vaudra true par défaut si on ne trouve pas l'extra booléen dont la clé est LocationManager.KEY_PROXIMITY_ENTERING

boolean entrer = (boolean)(intent.getBooleanExtra(LocationManager.KEY_PROXIMITY_ENTERING, true));

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,4 @@ public boolean onMarkerClick(Marker marker) {
return true;
}

@Override
public void onPointerCaptureChanged(boolean hasCapture) {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,18 @@
import com.google.android.gms.auth.api.signin.GoogleSignInResult;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.SignInButton;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.OptionalPendingResult;
import com.google.android.gms.common.api.ResultCallback;
import com.google.android.gms.common.api.Status;

import org.json.JSONObject;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import squiddle.sheshire.apomalyn.qc.ca.nearumix.DAO.BaseDeDonnees;
import squiddle.sheshire.apomalyn.qc.ca.nearumix.DAO.UtilisateurDAO;

import static android.Manifest.permission.READ_CONTACTS;
import static squiddle.sheshire.apomalyn.qc.ca.nearumix.R.styleable.CustomTextView;
Expand All @@ -43,14 +48,11 @@ public class VueConnexion extends AppCompatActivity implements
private GoogleApiClient mGoogleApiClient;
private ProgressDialog mProgressDialog;

private UtilisateurDAO utilisateurDAO = null;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.vue_connexion);

this.utilisateurDAO = UtilisateurDAO.getInstance();
// Button listeners
findViewById(R.id.sign_in_button).setOnClickListener(this);

Expand Down Expand Up @@ -162,16 +164,23 @@ private void handleSignInResult(GoogleSignInResult result) {
if (result.isSuccess()) {
// Signed in successfully, show authenticated UI.
GoogleSignInAccount acct = result.getSignInAccount();
findViewById(R.id.sign_in_button).setVisibility(View.GONE);

Intent changementVersCarte;
if(utilisateurDAO.setUtilisateurCourant(acct.getEmail()) == null){
changementVersCarte = new Intent(VueConnexion.this, VueConnexion.class);
}else{
changementVersCarte = new Intent(VueConnexion.this, VueMenu.class);
}
startActivity(changementVersCarte);
updateUI(true);
} else {
updateUI(false);
}
BaseDeDonnees bd = new BaseDeDonnees();
HashMap<String, String> map = new HashMap<>();
map.put("email", "[email protected]");
Log.d(TAG, new JSONObject(bd.envoyerRequete(BaseDeDonnees.GET_UTILISATEUR, map)).toString());
//Intent changementVersCarte = new Intent(VueConnexion.this, VueCarte.class);
//startActivity(changementVersCarte);
Intent changementVersCarte = new Intent(VueConnexion.this, VueMenu.class);
startActivity(changementVersCarte);
}

private void updateUI(boolean signedIn) {
if (signedIn) {
findViewById(R.id.sign_in_button).setVisibility(View.GONE);
} else {
findViewById(R.id.sign_in_button).setVisibility(View.VISIBLE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.*;
import android.Manifest;
import android.app.Fragment;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
Expand Down Expand Up @@ -64,7 +65,7 @@ protected void onCreate(Bundle savedInstanceState) {
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
point_influence_dao = PointInfluenceDAO.getInstance(); //TODO nous devons chanchez l'instanciation
point_influence_dao = PointInfluenceDAO.getInstance();

DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
Expand All @@ -86,19 +87,19 @@ protected void onCreate(Bundle savedInstanceState) {
// for ActivityCompat#requestPermissions for more details.
return;
}
if(locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)){
if (locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, new LocationListener() {
@Override
@Override
public void onLocationChanged(Location location) {
double latitude = location.getLatitude();
double longitude = location.getLongitude();
LatLng latLng = new LatLng(latitude,longitude);
Geocoder geocoder = new Geocoder(getApplicationContext());
try {
List<Address> addressList = geocoder.getFromLocation(latitude,longitude,1);
String string = addressList.get(0).getLocality();
mMap.addMarker(new MarkerOptions().position(latLng).title("NOUS sommes ici"));
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng,10.2f));
double latitude = location.getLatitude();
double longitude = location.getLongitude();
LatLng latLng = new LatLng(latitude, longitude);
Geocoder geocoder = new Geocoder(getApplicationContext());
try {
List<Address> addressList = geocoder.getFromLocation(latitude, longitude, 1);
String string = "Vous etes ici";
mMap.addMarker(new MarkerOptions().position(latLng).title(string));
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 15.2f));
} catch (IOException e) {
e.printStackTrace();
}
Expand Down Expand Up @@ -131,8 +132,9 @@ public void onLocationChanged(Location location) {
Geocoder geocoder = new Geocoder(getApplicationContext());
try {
List<Address> addressList = geocoder.getFromLocation(latitude,longitude,1);
String string = addressList.get(0).getLocality();
mMap.addMarker(new MarkerOptions().position(latLng).title("NOUS sommes ici"));
String string = addressList.get(0).getLocality() + " , ";
string += addressList.get(0).getCountryName();
mMap.addMarker(new MarkerOptions().position(latLng).title(string));
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng,10.2f));
} catch (IOException e) {
e.printStackTrace();
Expand All @@ -157,6 +159,25 @@ public void onProviderDisabled(String s) {
});

}
// Intent intent = new Intent(this, AlertReceiver.class);
//
//
// PendingIntent pending = PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
//
//
//// On ajoute une alerte de proximité si on s'approche ou s'éloigne du bâtiment de Simple IT
//
// if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
// // TODO: Consider calling
// // ActivityCompat#requestPermissions
// // here to request the missing permissions, and then overriding
// // public void onRequestPermissionsResult(int requestCode, String[] permissions,
// // int[] grantResults)
// // to handle the case where the user grants the permission. See the documentation
// // for ActivityCompat#requestPermissions for more details.
// return;
// }
// locationManager.addProximityAlert(48.872808, 2.33517, 150, -1, pending);
}


Expand Down Expand Up @@ -232,17 +253,20 @@ public void onMapReady(GoogleMap googleMap) {

for(PointInfluence pi : liste_pi) {
mMap.addMarker(new MarkerOptions().position(pi.getCoordonnees()).title(pi.getNom()));
mMap.moveCamera(CameraUpdateFactory.newLatLng(pi.getCoordonnees()));
mMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
@Override
public boolean onMarkerClick(Marker marker) {
Intent intent_aller_vers_vue_PI = new Intent (VueMenu.this, VuePointInfluence.class);
intent_aller_vers_vue_PI.putExtra("id_PI", point_influence_dao.getPointInfluenceParNom(marker.getTitle()).getId());
startActivityForResult(intent_aller_vers_vue_PI, -1);
//mMap.moveCamera(CameraUpdateFactory.newLatLng(pi.getCoordonnees()));
}
mMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
@Override
public boolean onMarkerClick(Marker marker) {
if(marker.getTitle().equals("Vous etes ici")){
return true;
}
});
}
Intent intent_aller_vers_vue_PI = new Intent (VueMenu.this, VuePointInfluence.class);
intent_aller_vers_vue_PI.putExtra("id_PI", point_influence_dao.getPointInfluenceParNom(marker.getTitle()).getId());
startActivityForResult(intent_aller_vers_vue_PI, -1);
return true;
}
});

/*PointInfluence pi = point_influence_dao.getPointInfluence(0);
LatLng matane = pi.getCoordonnees();
Expand All @@ -265,8 +289,8 @@ public boolean onMarkerClick(Marker marker) {
return true;
}

@Override
public void onPointerCaptureChanged(boolean hasCapture) {

}
//@Override
//public void onPointerCaptureChanged(boolean hasCapture) {
//
// }
}

0 comments on commit 724308b

Please sign in to comment.