Cleanup: Marker stores URI to photo (instead of String).

This commit is contained in:
Dennis Guse
2025-02-21 22:50:24 +01:00
parent b9ed5e28e0
commit 1b33184835
17 changed files with 45 additions and 78 deletions
@@ -418,7 +418,7 @@ public class ContentProviderUtils {
marker.setIcon(cursor.getString(iconIndex));
}
if (!cursor.isNull(photoUrlIndex)) {
marker.setPhotoUrl(cursor.getString(photoUrlIndex));
marker.setPhotoUrl(Uri.parse(cursor.getString(photoUrlIndex)));
}
return marker;
}
@@ -496,7 +496,7 @@ public class ContentProviderUtils {
private void deleteMarkerPhoto(Context context, Marker marker) {
if (marker != null && marker.hasPhoto()) {
Uri uri = marker.getPhotoURI();
Uri uri = marker.getPhotoUrl();
File file = MarkerUtils.buildInternalPhotoFile(context, marker.getTrackId(), uri);
if (file.exists()) {
File parent = file.getParentFile();
@@ -545,7 +545,9 @@ public class ContentProviderUtils {
values.put(MarkerColumns.BEARING, marker.getBearing());
}
values.put(MarkerColumns.PHOTOURL, marker.getPhotoUrl());
if (marker.hasPhoto()) {
values.put(MarkerColumns.PHOTOURL, marker.getPhotoUrl().toString());
}
return values;
}
@@ -24,7 +24,6 @@ import android.os.Parcelable;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.time.Duration;
import java.time.Instant;
/**
@@ -51,8 +50,7 @@ public final class Marker {
private Altitude altitude;
private Float bearing;
@Deprecated //TODO Make an URI instead of String
private String photoUrl = "";
private Uri photoUrl = null;
public Marker(@Nullable Track.Id trackId, Instant time) {
this.trackId = trackId;
@@ -71,7 +69,7 @@ public final class Marker {
}
@Deprecated
public Marker(String name, String description, String category, String icon, @NonNull Track.Id trackId, @NonNull TrackPoint trackPoint, String photoUrl) {
public Marker(String name, String description, String category, String icon, @NonNull Track.Id trackId, @NonNull TrackPoint trackPoint, Uri photoUrl) {
this(trackId, trackPoint);
this.name = name;
this.description = description;
@@ -222,20 +220,16 @@ public final class Marker {
this.bearing = bearing;
}
public String getPhotoUrl() {
public Uri getPhotoUrl() {
return photoUrl;
}
public void setPhotoUrl(String photoUrl) {
public void setPhotoUrl(Uri photoUrl) {
this.photoUrl = photoUrl;
}
public Uri getPhotoURI() {
return Uri.parse(photoUrl);
}
public boolean hasPhoto() {
return photoUrl != null && !photoUrl.isEmpty();
return photoUrl != null;
}
public record Id(long id) implements Parcelable {