Skip to content

Commit

Permalink
La boussole pointe vers la bonne direction
Browse files Browse the repository at this point in the history
  • Loading branch information
TheLortex committed Jun 30, 2014
1 parent 3139844 commit 256ab68
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
bin/*
gen/*
*.class
3 changes: 3 additions & 0 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyB1emAI5NSdyv4MUHyoF2w619RCyw-mygI"/>
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
Expand Down
3 changes: 3 additions & 0 deletions lint.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<lint>
</lint>
6 changes: 3 additions & 3 deletions project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

# Project target.
target=android-17
android.library.reference.1=../../android-sdk-linux/extras/android/support/v7/appcompat
android.library.reference.2=../../android-sdk-linux/extras/google/google_play_services/libproject/google-play-services_lib
target=android-19
android.library.reference.1=../../adt-bundle-windows-x86_64-20140321/sdk/extras/android/support/v7/appcompat
android.library.reference.2=../../adt-bundle-windows-x86_64-20140321/sdk/extras/google/google_play_services/libproject/google-play-services_lib
14 changes: 11 additions & 3 deletions src/fr/projetcookie/boussole/DataManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import android.content.Context;
import android.content.SharedPreferences;
import android.hardware.GeomagneticField;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
Expand Down Expand Up @@ -135,10 +136,17 @@ public void onLocationChanged(Location location) {
}

private void updateDirection() {
float azimuth = direction;
Location currentLoc = mLastLocation;
GeomagneticField geoField = new GeomagneticField(
(float) currentLoc.getLatitude(),
(float) currentLoc.getLongitude(),
(float) currentLoc.getAltitude(),
System.currentTimeMillis());
azimuth += geoField.getDeclination();
float bearing = currentLoc.bearingTo(mProvider.getLocation());

mLastLocation.setBearing(0);
float bearing = mProvider.getLocation().bearingTo(mLastLocation);

mListener.onDirectionUpdate(bearing + direction + 90); //TODO: Check if same offset everywhere
mListener.onDirectionUpdate(azimuth - bearing);
}
}
6 changes: 3 additions & 3 deletions src/fr/projetcookie/boussole/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ private void selectItem(int position) {

private void buildAlertMessageNoGps() {
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Votre GPS n'est pas activé. Améliorer la précision en l'activant?")
builder.setMessage("Votre GPS n'est pas activé. Améliorer la précision en l'activant?")
.setCancelable(false)
.setPositiveButton("Oui", new DialogInterface.OnClickListener() {
public void onClick(@SuppressWarnings("unused") final DialogInterface dialog, @SuppressWarnings("unused") final int id) {
Expand Down Expand Up @@ -504,8 +504,8 @@ public void onDirectionUpdate(float dir) {
else
mDistanceText = mDataTitles[1] + " " + Math.round(distance) + " m";

mLatitudeText = mDataTitles[2] + " " + Math.round(lat*1000)/1000f + "°";
mLongitudeText = mDataTitles[3] + " " + Math.round(lon*1000)/1000f + "°";
mLatitudeText = mDataTitles[2] + " " + Math.round(lat*1000)/1000f + "°";
mLongitudeText = mDataTitles[3] + " " + Math.round(lon*1000)/1000f + "°";

dataAdapter.clear();
dataAdapter.add(mAltitudeText);
Expand Down

0 comments on commit 256ab68

Please sign in to comment.