Cleanup: renaming Importer classes.

This commit is contained in:
Dennis Guse
2021-05-27 17:55:42 +02:00
parent 288fe27a57
commit eada954299
6 changed files with 18 additions and 18 deletions
@@ -169,7 +169,7 @@ public class ExportImportTest {
// 2. import // 2. import
InputStream inputStream = context.getContentResolver().openInputStream(tmpFileUri); InputStream inputStream = context.getContentResolver().openInputStream(tmpFileUri);
XMLImporter trackImporter = new XMLImporter(new KmlFileTrackImporter(context)); XMLImporter trackImporter = new XMLImporter(new KmlTrackImporter(context));
importTrackId = trackImporter.importFile(inputStream).get(0); importTrackId = trackImporter.importFile(inputStream).get(0);
// then // then
@@ -209,7 +209,7 @@ public class ExportImportTest {
// 2. import // 2. import
InputStream inputStream = context.getContentResolver().openInputStream(tmpFileUri); InputStream inputStream = context.getContentResolver().openInputStream(tmpFileUri);
XMLImporter trackImporter = new XMLImporter(new KmlFileTrackImporter(context)); XMLImporter trackImporter = new XMLImporter(new KmlTrackImporter(context));
importTrackId = trackImporter.importFile(inputStream).get(0); importTrackId = trackImporter.importFile(inputStream).get(0);
// then // then
@@ -288,7 +288,7 @@ public class ExportImportTest {
// 2. import // 2. import
InputStream inputStream = context.getContentResolver().openInputStream(tmpFileUri); InputStream inputStream = context.getContentResolver().openInputStream(tmpFileUri);
XMLImporter trackImporter = new XMLImporter(new KmlFileTrackImporter(context)); XMLImporter trackImporter = new XMLImporter(new KmlTrackImporter(context));
importTrackId = trackImporter.importFile(inputStream).get(0); importTrackId = trackImporter.importFile(inputStream).get(0);
// then // then
@@ -313,7 +313,7 @@ public class ExportImportTest {
// 2. import // 2. import
InputStream inputStream = context.getContentResolver().openInputStream(tmpFileUri); InputStream inputStream = context.getContentResolver().openInputStream(tmpFileUri);
XMLImporter trackImporter = new XMLImporter(new GpxFileTrackImporter(context, contentProviderUtils)); XMLImporter trackImporter = new XMLImporter(new GpxTrackImporter(context, contentProviderUtils));
importTrackId = trackImporter.importFile(inputStream).get(0); importTrackId = trackImporter.importFile(inputStream).get(0);
// then // then
@@ -362,7 +362,7 @@ public class ExportImportTest {
// 2. import // 2. import
InputStream inputStream = context.getContentResolver().openInputStream(tmpFileUri); InputStream inputStream = context.getContentResolver().openInputStream(tmpFileUri);
XMLImporter trackImporter = new XMLImporter(new GpxFileTrackImporter(context, contentProviderUtils)); XMLImporter trackImporter = new XMLImporter(new GpxTrackImporter(context, contentProviderUtils));
importTrackId = trackImporter.importFile(inputStream).get(0); importTrackId = trackImporter.importFile(inputStream).get(0);
// then // then
@@ -51,7 +51,7 @@ public class LegacyImportTest {
@Test @Test
public void kml_with_statistics_marker() throws IOException { public void kml_with_statistics_marker() throws IOException {
// given // given
XMLImporter trackImporter = new XMLImporter(new KmlFileTrackImporter(context)); XMLImporter trackImporter = new XMLImporter(new KmlTrackImporter(context));
InputStream inputStream = InstrumentationRegistry.getInstrumentation().getContext().getResources().openRawResource(de.dennisguse.opentracks.debug.test.R.raw.legacy_kml_statistics_marker); InputStream inputStream = InstrumentationRegistry.getInstrumentation().getContext().getResources().openRawResource(de.dennisguse.opentracks.debug.test.R.raw.legacy_kml_statistics_marker);
// when // when
@@ -93,7 +93,7 @@ public class LegacyImportTest {
@Test(expected = ImportParserException.class) @Test(expected = ImportParserException.class)
public void kml_without_locations() throws IOException { public void kml_without_locations() throws IOException {
// given // given
XMLImporter trackImporter = new XMLImporter(new KmlFileTrackImporter(context)); XMLImporter trackImporter = new XMLImporter(new KmlTrackImporter(context));
InputStream inputStream = InstrumentationRegistry.getInstrumentation().getContext().getResources().openRawResource(de.dennisguse.opentracks.debug.test.R.raw.legacy_kml_empty); InputStream inputStream = InstrumentationRegistry.getInstrumentation().getContext().getResources().openRawResource(de.dennisguse.opentracks.debug.test.R.raw.legacy_kml_empty);
// when // when
@@ -107,7 +107,7 @@ public class LegacyImportTest {
@Test @Test
public void gpx_with_pause_resume() throws IOException { public void gpx_with_pause_resume() throws IOException {
// given // given
XMLImporter trackImporter = new XMLImporter(new GpxFileTrackImporter(context)); XMLImporter trackImporter = new XMLImporter(new GpxTrackImporter(context));
InputStream inputStream = InstrumentationRegistry.getInstrumentation().getContext().getResources().openRawResource(de.dennisguse.opentracks.debug.test.R.raw.legacy_gpx_pause_resume); InputStream inputStream = InstrumentationRegistry.getInstrumentation().getContext().getResources().openRawResource(de.dennisguse.opentracks.debug.test.R.raw.legacy_gpx_pause_resume);
// when // when
@@ -54,9 +54,9 @@ import de.dennisguse.opentracks.util.StringUtils;
* *
* @author Jimmy Shih * @author Jimmy Shih
*/ */
public class GpxFileTrackImporter extends DefaultHandler implements XMLImporter.TrackParser { public class GpxTrackImporter extends DefaultHandler implements XMLImporter.TrackParser {
private static final String TAG = GpxFileTrackImporter.class.getSimpleName(); private static final String TAG = GpxTrackImporter.class.getSimpleName();
private static final String TAG_DESCRIPTION = "desc"; private static final String TAG_DESCRIPTION = "desc";
private static final String TAG_COMMENT = "cmt"; private static final String TAG_COMMENT = "cmt";
@@ -115,12 +115,12 @@ public class GpxFileTrackImporter extends DefaultHandler implements XMLImporter.
private final TrackImporter trackImporter; private final TrackImporter trackImporter;
public GpxFileTrackImporter(Context context) { public GpxTrackImporter(Context context) {
this(context, new ContentProviderUtils(context)); this(context, new ContentProviderUtils(context));
} }
@VisibleForTesting @VisibleForTesting
GpxFileTrackImporter(Context context, ContentProviderUtils contentProviderUtils) { GpxTrackImporter(Context context, ContentProviderUtils contentProviderUtils) {
this.context = context; this.context = context;
//TODO move this to instantiation of this class //TODO move this to instantiation of this class
@@ -52,9 +52,9 @@ public class ImportService extends JobIntentService {
try { try {
if (TrackFileFormat.GPX.getExtension().equals(fileExtension)) { if (TrackFileFormat.GPX.getExtension().equals(fileExtension)) {
trackIds.addAll(new XMLImporter(new GpxFileTrackImporter(this)).importFile(this, file.getUri())); trackIds.addAll(new XMLImporter(new GpxTrackImporter(this)).importFile(this, file.getUri()));
} else if (TrackFileFormat.KML_WITH_TRACKDETAIL_AND_SENSORDATA.getExtension().equals(fileExtension)) { } else if (TrackFileFormat.KML_WITH_TRACKDETAIL_AND_SENSORDATA.getExtension().equals(fileExtension)) {
trackIds.addAll(new XMLImporter(new KmlFileTrackImporter(this)).importFile(this, file.getUri())); trackIds.addAll(new XMLImporter(new KmlTrackImporter(this)).importFile(this, file.getUri()));
} else if (TrackFileFormat.KMZ_WITH_TRACKDETAIL_AND_SENSORDATA_AND_PICTURES.getExtension().equals(fileExtension)) { } else if (TrackFileFormat.KMZ_WITH_TRACKDETAIL_AND_SENSORDATA_AND_PICTURES.getExtension().equals(fileExtension)) {
trackIds.addAll(new KmzTrackImporter().importFile(this, file.getUri())); trackIds.addAll(new KmzTrackImporter().importFile(this, file.getUri()));
} else { } else {
@@ -46,9 +46,9 @@ import de.dennisguse.opentracks.util.StringUtils;
* *
* @author Jimmy Shih * @author Jimmy Shih
*/ */
public class KmlFileTrackImporter extends DefaultHandler implements XMLImporter.TrackParser { public class KmlTrackImporter extends DefaultHandler implements XMLImporter.TrackParser {
private static final String TAG = KmlFileTrackImporter.class.getSimpleName(); private static final String TAG = KmlTrackImporter.class.getSimpleName();
private static final String MARKER_STYLE = "#" + KMLTrackExporter.MARKER_STYLE; private static final String MARKER_STYLE = "#" + KMLTrackExporter.MARKER_STYLE;
@@ -107,7 +107,7 @@ public class KmlFileTrackImporter extends DefaultHandler implements XMLImporter.
private final TrackImporter trackImporter; private final TrackImporter trackImporter;
public KmlFileTrackImporter(Context context) { public KmlTrackImporter(Context context) {
this.context = context; this.context = context;
//TODO move this to instantiation of this class //TODO move this to instantiation of this class
@@ -205,7 +205,7 @@ public class KmzTrackImporter {
} }
private List<Track.Id> parseKml(ZipInputStream zipInputStream) throws IOException { private List<Track.Id> parseKml(ZipInputStream zipInputStream) throws IOException {
XMLImporter kmlFileTrackImporter = new XMLImporter(new KmlFileTrackImporter(context)); XMLImporter kmlFileTrackImporter = new XMLImporter(new KmlTrackImporter(context));
InputStream nonClosableInputStream = new FilterInputStream(zipInputStream) { InputStream nonClosableInputStream = new FilterInputStream(zipInputStream) {
@Override @Override