Share GPX traces.
This commit is contained in:
parent
fe8eb244d5
commit
928cd65dba
|
|
@ -8,6 +8,7 @@ import android.content.pm.PackageManager;
|
|||
import android.graphics.Color;
|
||||
import android.hardware.GeomagneticField;
|
||||
import android.location.LocationManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
|
|
@ -380,9 +381,23 @@ public class MainActivity extends AppCompatActivity implements IOrientationConsu
|
|||
//noinspection SimplifiableIfStatement
|
||||
if (id == R.id.action_import_gpx) {
|
||||
Intent intent = new Intent(this, FilePicker.class);
|
||||
intent.putExtra(FilePicker.EXTRA_FILE_PATH, Environment.getExternalStorageDirectory().getAbsolutePath()+"/"+appName);
|
||||
intent.putExtra(FilePicker.EXTRA_FILE_PATH, Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + appName);
|
||||
startActivityForResult(intent, REQUEST_PICK_FILE);
|
||||
return true;
|
||||
|
||||
} else if (id == R.id.action_send_gpx_trail) {
|
||||
File trailFile = serviceGps.getLastExportedTrailFile();
|
||||
if (trailFile != null) {
|
||||
Intent shareIntent = new Intent();
|
||||
shareIntent.setAction(Intent.ACTION_SEND);
|
||||
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(trailFile));
|
||||
shareIntent.setType("*/*");
|
||||
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
startActivity(Intent.createChooser(shareIntent, getResources().getText(R.string.action_send_to)));
|
||||
} else {
|
||||
Toast.makeText(ctx, "Aucune trace enregistré.", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@ public class ServiceGps extends Observable implements IServiceGps, LocationListe
|
|||
private static final String TAG = ServiceGps.class.getName();
|
||||
public static final String NOTIF_NEW_LOCATION = "fr.chteufleur.mytrackingdog.services.servicegps.newlocation";
|
||||
|
||||
private File lastExportedTrailFile = null;
|
||||
|
||||
private LocationManager locationManager;
|
||||
private MyLocation currentLocation = null;
|
||||
private String appName = "";
|
||||
|
|
@ -217,14 +219,22 @@ public class ServiceGps extends Observable implements IServiceGps, LocationListe
|
|||
ExportGpx exportGpx = new ExportGpx(file, Gpx.TRAIL_TRACE_NAME);
|
||||
exportGpx.setObjects(traces.getListPointObjectsTrail());
|
||||
exportGpx.setTrace(traces.getListPointTraceur());
|
||||
lastExportedTrailFile = file;
|
||||
return exportGpx.export();
|
||||
}
|
||||
|
||||
public File getLastExportedTrailFile() {
|
||||
return lastExportedTrailFile;
|
||||
}
|
||||
|
||||
public void importGpxTrace(File file) {
|
||||
ImportGpx importGpx = new ImportGpx(file);
|
||||
try {
|
||||
List list = importGpx.parse();
|
||||
String traceName = importGpx.getTraceName();
|
||||
if (traceName.equals(Gpx.TRAIL_TRACE_NAME)) {
|
||||
lastExportedTrailFile = file;
|
||||
}
|
||||
for (int i=0; i<list.size(); i++) {
|
||||
Object o = list.get(i);
|
||||
if (o instanceof WayPointLocation) {
|
||||
|
|
|
|||
|
|
@ -7,4 +7,9 @@
|
|||
android:orderInCategory="100"
|
||||
android:title="@string/action_import_gpx"
|
||||
app:showAsAction="never" />
|
||||
<item
|
||||
android:id="@+id/action_send_gpx_trail"
|
||||
android:orderInCategory="100"
|
||||
android:title="@string/action_send_gpx_trail"
|
||||
app:showAsAction="never" />
|
||||
</menu>
|
||||
|
|
|
|||
|
|
@ -1,10 +1,13 @@
|
|||
<resources>
|
||||
<string name="app_name">MyTrackingDog</string>
|
||||
<string name="action_import_gpx">Import GPX</string>
|
||||
<string name="trail_start">Départ traceur</string>
|
||||
<string name="trail_stop">Stop</string>
|
||||
<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>
|
||||
|
||||
<string name="action_import_gpx">Import GPX</string>
|
||||
<string name="action_send_gpx_trail">Envoyer trace du traceur</string>
|
||||
<string name="action_send_to">Envoyer par</string>
|
||||
</resources>
|
||||
|
|
|
|||
Loading…
Reference in New Issue