diff --git a/app/src/main/java/fr/chteufleur/mytrackingdog/MainActivity.java b/app/src/main/java/fr/chteufleur/mytrackingdog/MainActivity.java index f4da1ff..f4f11f2 100644 --- a/app/src/main/java/fr/chteufleur/mytrackingdog/MainActivity.java +++ b/app/src/main/java/fr/chteufleur/mytrackingdog/MainActivity.java @@ -31,6 +31,7 @@ import org.osmdroid.tileprovider.tilesource.TileSourceFactory; import org.osmdroid.util.GeoPoint; import org.osmdroid.views.MapView; import org.osmdroid.views.overlay.Marker; +import org.osmdroid.views.overlay.Overlay; import org.osmdroid.views.overlay.Polyline; import org.osmdroid.views.overlay.compass.IOrientationConsumer; import org.osmdroid.views.overlay.compass.IOrientationProvider; @@ -147,7 +148,11 @@ public class MainActivity extends AppCompatActivity implements IOrientationConsu add_object.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - addMarker(); + if (serviceGps.isTraceurActivated()) { + addMarker(); + } else if (serviceGps.isDogActivated()) { + markAsFound(); + } } }); @@ -165,6 +170,7 @@ public class MainActivity extends AppCompatActivity implements IOrientationConsu if (serviceGps.isTraceurActivated()) { this.start_stop_trace.setText(R.string.trail_stop); this.add_object.setVisibility(View.VISIBLE); + this.add_object.setText(R.string.trail_object); this.start_stop_dog_trace.setVisibility(View.GONE); this.textViewCurrentLocation.setVisibility(View.VISIBLE); updateDistance(); @@ -179,7 +185,8 @@ public class MainActivity extends AppCompatActivity implements IOrientationConsu serviceGps.toggleDogActivation(); if (serviceGps.isDogActivated()) { this.start_stop_dog_trace.setText(R.string.dog_stop); - this.add_object.setVisibility(View.GONE); + this.add_object.setVisibility(View.VISIBLE); + this.add_object.setText(R.string.dog_object); this.start_stop_trace.setVisibility(View.GONE); this.textViewCurrentLocation.setVisibility(View.GONE); } else { @@ -222,6 +229,24 @@ public class MainActivity extends AppCompatActivity implements IOrientationConsu map.getOverlays().add(marker); } + private void markAsFound() { + WayPointLocation wpl = serviceGps.foundNearObject(); + if (wpl != null) { + wpl.setFound(); + for (Overlay o : map.getOverlays()) { + if (o instanceof Marker) { + Marker marker = (Marker) o; + GeoPoint gp = marker.getPosition(); + if (wpl.isEquals(gp.getLatitude(), gp.getLongitude())) { + marker.setIcon(getResources().getDrawable(R.drawable.ic_marker_blue)); + marker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM); + break; + } + } + } + } + } + @Override public void onResume(){ super.onResume(); diff --git a/app/src/main/java/fr/chteufleur/mytrackingdog/services/ServiceGps.java b/app/src/main/java/fr/chteufleur/mytrackingdog/services/ServiceGps.java index 6869d04..3af31f5 100644 --- a/app/src/main/java/fr/chteufleur/mytrackingdog/services/ServiceGps.java +++ b/app/src/main/java/fr/chteufleur/mytrackingdog/services/ServiceGps.java @@ -168,6 +168,17 @@ public class ServiceGps extends Observable implements IServiceGps, LocationListe return traces.getPoint(lat, lon); } + public WayPointLocation foundNearObject() { + WayPointLocation ret = null; + MyLocation curLoc = currentLocation; + for (MyLocation ml: getListGeoPointObjects()) { + if (curLoc.distanceTo(ml) < 10 && ml instanceof WayPointLocation) { + ret = (WayPointLocation) ml; + } + } + return ret; + } + public String getFileName(String prefix) { SimpleDateFormat formater = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss"); String date = formater.format(new Date()); diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png index a2f5908..793aea1 100644 Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher.png and b/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png index ff10afd..64529b6 100644 Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher.png and b/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png index dcd3cd8..5a2571f 100644 Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png index 8ca12fe..059d239 100644 Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png index b824ebd..0370969 100644 Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e7833b6..ed26564 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -6,4 +6,5 @@ Dépose objet Départ chien Stop + Objet trouvé