forked from upstream-mirrors/OpenTracks
Cleanup: Marker stores URI to photo (instead of String).
This commit is contained in:
@@ -270,7 +270,7 @@ public class KMLTrackExporter implements TrackExporter {
|
||||
}
|
||||
|
||||
private void writeMarker(Marker marker, ZoneOffset zoneOffset) {
|
||||
boolean existsPhoto = MarkerUtils.buildInternalPhotoFile(context, marker.getTrackId(), marker.getPhotoURI()) != null;
|
||||
boolean existsPhoto = MarkerUtils.buildInternalPhotoFile(context, marker.getTrackId(), marker.getPhotoUrl()) != null;
|
||||
if (marker.hasPhoto() && exportPhotos && existsPhoto) {
|
||||
float heading = getHeading(marker.getTrackId(), marker.getLocation());
|
||||
writePhotoOverlay(marker, heading, zoneOffset);
|
||||
|
||||
@@ -97,7 +97,7 @@ public class KmzTrackExporter implements TrackExporter {
|
||||
}
|
||||
Marker marker = contentProviderUtils.createMarker(cursor);
|
||||
if (marker.hasPhoto()) {
|
||||
Uri uriPhoto = marker.getPhotoURI();
|
||||
Uri uriPhoto = marker.getPhotoUrl();
|
||||
boolean existsPhoto = MarkerUtils.buildInternalPhotoFile(context, track.getId(), uriPhoto) != null;
|
||||
if (existsPhoto) {
|
||||
addImage(context, zipOutputStream, uriPhoto, marker);
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package de.dennisguse.opentracks.io.file.importer;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.util.Log;
|
||||
|
||||
import org.xml.sax.Attributes;
|
||||
@@ -109,7 +110,7 @@ public class GpxTrackImporter extends DefaultHandler implements XMLImporter.Trac
|
||||
private String cadence;
|
||||
private String power;
|
||||
private String markerType;
|
||||
private String photoUrl;
|
||||
private Uri photoUrl;
|
||||
private String uuid;
|
||||
private String gain;
|
||||
private String loss;
|
||||
|
||||
@@ -18,6 +18,7 @@ package de.dennisguse.opentracks.io.file.importer;
|
||||
|
||||
import android.content.Context;
|
||||
import android.location.Location;
|
||||
import android.net.Uri;
|
||||
import android.util.Log;
|
||||
|
||||
import org.xml.sax.Attributes;
|
||||
@@ -121,7 +122,7 @@ public class KmlTrackImporter extends DefaultHandler implements XMLImporter.Trac
|
||||
private String longitude;
|
||||
private String altitude;
|
||||
private String markerType;
|
||||
private String photoUrl;
|
||||
private Uri photoUrl;
|
||||
private String uuid;
|
||||
|
||||
private final TrackImporter trackImporter;
|
||||
@@ -223,7 +224,7 @@ public class KmlTrackImporter extends DefaultHandler implements XMLImporter.Trac
|
||||
}
|
||||
case TAG_HREF -> {
|
||||
if (content != null) {
|
||||
photoUrl = content.trim();
|
||||
photoUrl = Uri.parse(content.trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ public class KmzTrackImporter {
|
||||
List<String> photosName = new ArrayList<>();
|
||||
for (Marker marker : markers) {
|
||||
if (marker.hasPhoto()) {
|
||||
String photoUrl = Uri.decode(marker.getPhotoUrl());
|
||||
String photoUrl = Uri.decode(marker.getPhotoUrl().toString()); //TODO Why Uri.decode()?
|
||||
photosName.add(photoUrl.substring(photoUrl.lastIndexOf(File.separatorChar) + 1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -233,12 +233,11 @@ public class TrackImporter {
|
||||
*
|
||||
* @param externalPhotoUrl the file name
|
||||
*/
|
||||
private String getInternalPhotoUrl(@NonNull Track.Id trackId, @NonNull String externalPhotoUrl) {
|
||||
String importFileName = KmzTrackImporter.importNameForFilename(externalPhotoUrl);
|
||||
private Uri getInternalPhotoUrl(@NonNull Track.Id trackId, @NonNull Uri externalPhotoUrl) {
|
||||
String importFileName = KmzTrackImporter.importNameForFilename(externalPhotoUrl.toString());
|
||||
File file = MarkerUtils.buildInternalPhotoFile(context, trackId, Uri.parse(importFileName));
|
||||
if (file != null) {
|
||||
Uri photoUri = FileUtils.getUriForFile(context, file);
|
||||
return "" + photoUri;
|
||||
return FileUtils.getUriForFile(context, file);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user