Add button to mark object as found.
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 6.2 KiB |
|
Before Width: | Height: | Size: 9.0 KiB After Width: | Height: | Size: 7.8 KiB |
|
|
@ -6,4 +6,5 @@
|
|||
<string name="trail_object">Dépose objet</string>
|
||||
<string name="dog_start">Départ chien</string>
|
||||
<string name="dog_stop">Stop</string>
|
||||
<string name="dog_object">Objet trouvé</string>
|
||||
</resources>
|
||||
|
|
|
|||