forked from upstream-mirrors/OpenTracks
do not pass complete track data to exporter factory method just to knwo if there is more then one track to export
This commit is contained in:
+5
-5
@@ -106,7 +106,7 @@ public class ExportImportTest {
|
||||
// given
|
||||
Track track = contentProviderUtils.getTrack(trackId);
|
||||
|
||||
TrackExporter trackExporter = TrackFileFormat.KML_WITH_TRACKDETAIL.newTrackExporter(context, new Track[]{track});
|
||||
TrackExporter trackExporter = TrackFileFormat.KML_WITH_TRACKDETAIL.newTrackExporter(context);
|
||||
|
||||
// when
|
||||
// 1. export
|
||||
@@ -142,7 +142,7 @@ public class ExportImportTest {
|
||||
// given
|
||||
Track track = contentProviderUtils.getTrack(trackId);
|
||||
|
||||
TrackExporter trackExporter = TrackFileFormat.KML_WITH_TRACKDETAIL_AND_SENSORDATA.newTrackExporter(context, new Track[]{track});
|
||||
TrackExporter trackExporter = TrackFileFormat.KML_WITH_TRACKDETAIL_AND_SENSORDATA.newTrackExporter(context);
|
||||
|
||||
// when
|
||||
// 1. export
|
||||
@@ -178,7 +178,7 @@ public class ExportImportTest {
|
||||
PreferencesUtils.setBoolean(context, R.string.import_prevent_reimport_key, true);
|
||||
Track track = contentProviderUtils.getTrack(trackId);
|
||||
|
||||
TrackExporter trackExporter = TrackFileFormat.KML_WITH_TRACKDETAIL_AND_SENSORDATA.newTrackExporter(context, new Track[]{track});
|
||||
TrackExporter trackExporter = TrackFileFormat.KML_WITH_TRACKDETAIL_AND_SENSORDATA.newTrackExporter(context);
|
||||
|
||||
// when
|
||||
// 1. export
|
||||
@@ -229,7 +229,7 @@ public class ExportImportTest {
|
||||
// given
|
||||
Track track = contentProviderUtils.getTrack(trackId);
|
||||
|
||||
TrackExporter trackExporter = TrackFileFormat.GPX.newTrackExporter(context, new Track[]{track});
|
||||
TrackExporter trackExporter = TrackFileFormat.GPX.newTrackExporter(context);
|
||||
|
||||
// when
|
||||
// 1. export
|
||||
@@ -267,7 +267,7 @@ public class ExportImportTest {
|
||||
PreferencesUtils.setBoolean(context, R.string.import_prevent_reimport_key, true);
|
||||
Track track = contentProviderUtils.getTrack(trackId);
|
||||
|
||||
TrackExporter trackExporter = TrackFileFormat.GPX.newTrackExporter(context, new Track[]{track});
|
||||
TrackExporter trackExporter = TrackFileFormat.GPX.newTrackExporter(context);
|
||||
|
||||
// when
|
||||
// 1. export
|
||||
|
||||
@@ -208,7 +208,8 @@ public class ShareContentProvider extends CustomContentProvider implements ICont
|
||||
tracks[i] = contentProviderUtils.getTrack(trackIds[i]);
|
||||
}
|
||||
|
||||
final TrackExporter trackExporter = getTrackFileFormat(uri).newTrackExporter(getContext(), tracks);
|
||||
boolean hasMultipleTracks = tracks.length > 1;
|
||||
final TrackExporter trackExporter = getTrackFileFormat(uri).newTrackExporter(getContext(), hasMultipleTracks);
|
||||
|
||||
PipeDataWriter<String> pipeDataWriter = (output, uri1, mimeType, opts, args) -> {
|
||||
try (FileOutputStream fileOutputStream = new FileOutputStream(output.getFileDescriptor())) {
|
||||
|
||||
@@ -206,7 +206,7 @@ public class ExportProgressDialogFragment extends DialogFragment {
|
||||
}
|
||||
|
||||
private Boolean exportTrack(Context context, Track track) {
|
||||
TrackExporter trackExporter = trackFileFormat.newTrackExporter(context, new Track[]{track});
|
||||
TrackExporter trackExporter = trackFileFormat.newTrackExporter(context);
|
||||
|
||||
//TODO Move to helper function
|
||||
String fileName = track.getId() + "." + trackFileFormat.getExtension();
|
||||
|
||||
@@ -21,7 +21,7 @@ public enum TrackFileFormat {
|
||||
|
||||
KML_ONLY_TRACK {
|
||||
@Override
|
||||
public TrackWriter newTrackWriter(Context context, boolean multiple) {
|
||||
public TrackWriter newTrackWriter(Context context, boolean hasMultipleTracks) {
|
||||
return new KmlTrackWriter(context,false, false, false);
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public enum TrackFileFormat {
|
||||
},
|
||||
KML_WITH_TRACKDETAIL {
|
||||
@Override
|
||||
public TrackWriter newTrackWriter(Context context, boolean multiple) {
|
||||
public TrackWriter newTrackWriter(Context context, boolean hasMultipleTracks) {
|
||||
return new KmlTrackWriter(context,true, false, false);
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public enum TrackFileFormat {
|
||||
},
|
||||
KML_WITH_TRACKDETAIL_AND_SENSORDATA {
|
||||
@Override
|
||||
public TrackWriter newTrackWriter(Context context, boolean multiple) {
|
||||
public TrackWriter newTrackWriter(Context context, boolean hasMultipleTracks) {
|
||||
return new KmlTrackWriter(context,true, true, false);
|
||||
}
|
||||
|
||||
@@ -69,12 +69,12 @@ public enum TrackFileFormat {
|
||||
private static final boolean exportPhotos = false;
|
||||
|
||||
@Override
|
||||
public TrackWriter newTrackWriter(Context context, boolean multiple) {
|
||||
public TrackWriter newTrackWriter(Context context, boolean hasMultipleTracks) {
|
||||
return new KmlTrackWriter(context,false, false, exportPhotos);
|
||||
}
|
||||
|
||||
public TrackExporter newTrackExporter(Context context, Track[] tracks) {
|
||||
return newKmzTrackExporter(context, this.newTrackWriter(context, tracks.length > 1), exportPhotos);
|
||||
public TrackExporter newTrackExporter(Context context, boolean hasMultipleTracks) {
|
||||
return newKmzTrackExporter(context, this.newTrackWriter(context, hasMultipleTracks), exportPhotos);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -96,12 +96,12 @@ public enum TrackFileFormat {
|
||||
private static final boolean exportPhotos = false;
|
||||
|
||||
@Override
|
||||
public TrackWriter newTrackWriter(Context context, boolean multiple) {
|
||||
public TrackWriter newTrackWriter(Context context, boolean hasMultipleTracks) {
|
||||
return new KmlTrackWriter(context,true, false, exportPhotos);
|
||||
}
|
||||
|
||||
public TrackExporter newTrackExporter(Context context, Track[] tracks) {
|
||||
return newKmzTrackExporter(context, this.newTrackWriter(context, tracks.length > 1), exportPhotos);
|
||||
public TrackExporter newTrackExporter(Context context, boolean hasMultipleTracks) {
|
||||
return newKmzTrackExporter(context, this.newTrackWriter(context, hasMultipleTracks), exportPhotos);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -124,7 +124,7 @@ public enum TrackFileFormat {
|
||||
private static final boolean exportPhotos = false;
|
||||
|
||||
@Override
|
||||
public TrackWriter newTrackWriter(Context context, boolean multiple) {
|
||||
public TrackWriter newTrackWriter(Context context, boolean hasMultipleTracks) {
|
||||
return new KmlTrackWriter(context,true, true, exportPhotos);
|
||||
}
|
||||
|
||||
@@ -133,8 +133,8 @@ public enum TrackFileFormat {
|
||||
return MIME_KMZ;
|
||||
}
|
||||
|
||||
public TrackExporter newTrackExporter(Context context, Track[] tracks) {
|
||||
return newKmzTrackExporter(context, this.newTrackWriter(context, tracks.length > 1), exportPhotos);
|
||||
public TrackExporter newTrackExporter(Context context, boolean hasMultipleTracks) {
|
||||
return newKmzTrackExporter(context, this.newTrackWriter(context, hasMultipleTracks), exportPhotos);
|
||||
}
|
||||
|
||||
public String getExtension() {
|
||||
@@ -153,7 +153,7 @@ public enum TrackFileFormat {
|
||||
private static final boolean exportPhotos = true;
|
||||
|
||||
@Override
|
||||
public TrackWriter newTrackWriter(Context context, boolean multiple) {
|
||||
public TrackWriter newTrackWriter(Context context, boolean hasMultipleTracks) {
|
||||
return new KmlTrackWriter(context,true, true, exportPhotos);
|
||||
}
|
||||
|
||||
@@ -162,8 +162,8 @@ public enum TrackFileFormat {
|
||||
return MIME_KMZ;
|
||||
}
|
||||
|
||||
public TrackExporter newTrackExporter(Context context, Track[] tracks) {
|
||||
return newKmzTrackExporter(context, newTrackWriter(context, tracks.length > 1), exportPhotos);
|
||||
public TrackExporter newTrackExporter(Context context, boolean hasMultipleTracks) {
|
||||
return newKmzTrackExporter(context, newTrackWriter(context, hasMultipleTracks), exportPhotos);
|
||||
}
|
||||
|
||||
public String getExtension() {
|
||||
@@ -178,7 +178,7 @@ public enum TrackFileFormat {
|
||||
},
|
||||
GPX {
|
||||
@Override
|
||||
public TrackWriter newTrackWriter(Context context, boolean multiple) {
|
||||
public TrackWriter newTrackWriter(Context context, boolean hasMultipleTracks) {
|
||||
return new GpxTrackWriter(context.getString(R.string.app_name));
|
||||
}
|
||||
|
||||
@@ -209,9 +209,13 @@ public enum TrackFileFormat {
|
||||
*/
|
||||
public abstract String getMimeType();
|
||||
|
||||
public TrackExporter newTrackExporter(Context context, Track[] tracks) {
|
||||
public TrackExporter newTrackExporter(Context context) {
|
||||
return newTrackExporter(context, false);
|
||||
}
|
||||
|
||||
public TrackExporter newTrackExporter(Context context, boolean hasMultipleTracks) {
|
||||
ContentProviderUtils contentProviderUtils = new ContentProviderUtils(context);
|
||||
TrackWriter trackWriter = newTrackWriter(context, tracks.length > 1);
|
||||
TrackWriter trackWriter = newTrackWriter(context, hasMultipleTracks);
|
||||
return new FileTrackExporter(contentProviderUtils, trackWriter);
|
||||
}
|
||||
|
||||
@@ -221,7 +225,7 @@ public enum TrackFileFormat {
|
||||
* @param context the context
|
||||
* @param multiple true for writing multiple tracks
|
||||
*/
|
||||
public abstract TrackWriter newTrackWriter(Context context, boolean multiple);
|
||||
public abstract TrackWriter newTrackWriter(Context context, boolean hasMultipleTracks);
|
||||
|
||||
/**
|
||||
* Returns the file extension for each format.
|
||||
|
||||
Reference in New Issue
Block a user