mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-02 09:33:06 +02:00
Cleanup: Marker.icon was not used anymore.
This commit is contained in:
@@ -91,9 +91,9 @@ public class TestDataUtil {
|
||||
);
|
||||
|
||||
List<Marker> markers = List.of(
|
||||
new Marker(null, trackId, "Marker 1", "Marker description 1", "Marker category 3", "", trackPoints.get(1).getPosition(),null),
|
||||
new Marker(null, trackId, "Marker 2", "Marker description 2", "Marker category 3", "", trackPoints.get(4).getPosition(), null),
|
||||
new Marker(null, trackId, "Marker 3", "Marker description 3", "Marker category 3", "", trackPoints.get(5).getPosition(), null)
|
||||
new Marker(null, trackId, "Marker 1", "Marker description 1", "Marker category 3", trackPoints.get(1).getPosition(),null),
|
||||
new Marker(null, trackId, "Marker 2", "Marker description 2", "Marker category 3", trackPoints.get(4).getPosition(), null),
|
||||
new Marker(null, trackId, "Marker 3", "Marker description 3", "Marker category 3", trackPoints.get(5).getPosition(), null)
|
||||
);
|
||||
|
||||
return new TrackData(track, trackPoints, markers);
|
||||
@@ -163,7 +163,6 @@ public class TestDataUtil {
|
||||
"Marker name",
|
||||
description,
|
||||
"Marker category",
|
||||
"",
|
||||
trackPoint.getPosition(),
|
||||
photoUri);
|
||||
}
|
||||
|
||||
@@ -239,7 +239,6 @@ public class CustomContentProviderUtilsTest {
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
getLastValidTrackPoint(trackId).getPosition(),
|
||||
null
|
||||
));
|
||||
@@ -303,7 +302,6 @@ public class CustomContentProviderUtilsTest {
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
getLastValidTrackPoint(trackId1).getPosition(),
|
||||
null
|
||||
));
|
||||
@@ -477,7 +475,6 @@ public class CustomContentProviderUtilsTest {
|
||||
"",
|
||||
TEST_DESC,
|
||||
"",
|
||||
"",
|
||||
getLastValidTrackPoint(trackId).getPosition(),
|
||||
null
|
||||
));
|
||||
@@ -558,7 +555,6 @@ public class CustomContentProviderUtilsTest {
|
||||
"",
|
||||
MOCK_DESC,
|
||||
"",
|
||||
"",
|
||||
getLastValidTrackPoint(trackId).getPosition(),
|
||||
null
|
||||
));
|
||||
@@ -568,7 +564,6 @@ public class CustomContentProviderUtilsTest {
|
||||
"",
|
||||
MOCK_DESC,
|
||||
"",
|
||||
"",
|
||||
getLastValidTrackPoint(trackId).getPosition(),
|
||||
null
|
||||
));
|
||||
@@ -596,7 +591,6 @@ public class CustomContentProviderUtilsTest {
|
||||
"",
|
||||
MOCK_DESC,
|
||||
"",
|
||||
"",
|
||||
getLastValidTrackPoint(trackId).getPosition(),
|
||||
null
|
||||
));
|
||||
@@ -621,7 +615,6 @@ public class CustomContentProviderUtilsTest {
|
||||
"",
|
||||
TEST_DESC,
|
||||
"",
|
||||
"",
|
||||
getLastValidTrackPoint(trackId).getPosition(),
|
||||
null
|
||||
));
|
||||
@@ -645,7 +638,6 @@ public class CustomContentProviderUtilsTest {
|
||||
"",
|
||||
TEST_DESC,
|
||||
"",
|
||||
"",
|
||||
getLastValidTrackPoint(trackId).getPosition(),
|
||||
null
|
||||
));
|
||||
@@ -657,7 +649,6 @@ public class CustomContentProviderUtilsTest {
|
||||
"",
|
||||
TEST_DESC_NEW,
|
||||
"",
|
||||
"",
|
||||
getLastValidTrackPoint(trackId).getPosition(),
|
||||
null
|
||||
));
|
||||
|
||||
@@ -58,7 +58,6 @@ import de.dennisguse.opentracks.data.models.Cadence;
|
||||
import de.dennisguse.opentracks.data.models.Distance;
|
||||
import de.dennisguse.opentracks.data.models.HeartRate;
|
||||
import de.dennisguse.opentracks.data.models.Marker;
|
||||
import de.dennisguse.opentracks.data.models.MarkerBuilder;
|
||||
import de.dennisguse.opentracks.data.models.Position;
|
||||
import de.dennisguse.opentracks.data.models.Power;
|
||||
import de.dennisguse.opentracks.data.models.Speed;
|
||||
@@ -160,7 +159,6 @@ public class ExportImportTest {
|
||||
"Marker 1",
|
||||
"Marker 1 desc",
|
||||
"Marker 1 category",
|
||||
null,
|
||||
service.getLastStoredTrackPointWithLocation().getPosition(),
|
||||
null
|
||||
));
|
||||
@@ -184,7 +182,6 @@ public class ExportImportTest {
|
||||
"Marker 2",
|
||||
"Marker 2 desc",
|
||||
"Marker 2 category",
|
||||
null,
|
||||
service.getLastStoredTrackPointWithLocation().getPosition(),
|
||||
null
|
||||
));
|
||||
@@ -561,7 +558,6 @@ public class ExportImportTest {
|
||||
Marker importMarker = importedMarkers.get(i);
|
||||
assertEquals(marker.category(), importMarker.category());
|
||||
assertEquals(marker.description(), importMarker.description());
|
||||
// assertEquals(marker.getIcon(), importMarker.getIcon()); // TODO for KML
|
||||
assertEquals(marker.name(), importMarker.name());
|
||||
assertNull(importMarker.photoUrl());
|
||||
|
||||
|
||||
@@ -312,7 +312,6 @@ public class ContentProviderUtils {
|
||||
int nameIndex = cursor.getColumnIndexOrThrow(MarkerColumns.NAME);
|
||||
int descriptionIndex = cursor.getColumnIndexOrThrow(MarkerColumns.DESCRIPTION);
|
||||
int categoryIndex = cursor.getColumnIndexOrThrow(MarkerColumns.CATEGORY);
|
||||
int iconIndex = cursor.getColumnIndexOrThrow(MarkerColumns.ICON);
|
||||
int trackIdIndex = cursor.getColumnIndexOrThrow(MarkerColumns.TRACKID);
|
||||
int longitudeIndex = cursor.getColumnIndexOrThrow(MarkerColumns.LONGITUDE);
|
||||
int latitudeIndex = cursor.getColumnIndexOrThrow(MarkerColumns.LATITUDE);
|
||||
@@ -369,7 +368,6 @@ public class ContentProviderUtils {
|
||||
!cursor.isNull(nameIndex) ? cursor.getString(nameIndex) : "",
|
||||
!cursor.isNull(descriptionIndex) ? cursor.getString(descriptionIndex) : "",
|
||||
!cursor.isNull(categoryIndex) ? cursor.getString(categoryIndex) : "",
|
||||
!cursor.isNull(iconIndex) ? cursor.getString(iconIndex) : "",
|
||||
position,
|
||||
photoUrl
|
||||
);
|
||||
@@ -475,7 +473,6 @@ public class ContentProviderUtils {
|
||||
values.put(MarkerColumns.NAME, marker.name());
|
||||
values.put(MarkerColumns.DESCRIPTION, marker.description());
|
||||
values.put(MarkerColumns.CATEGORY, marker.category());
|
||||
values.put(MarkerColumns.ICON, marker.icon());
|
||||
|
||||
values.put(MarkerColumns.LONGITUDE, (int) (marker.position().longitude() * 1E6));
|
||||
values.put(MarkerColumns.LATITUDE, (int) (marker.position().latitude() * 1E6));
|
||||
|
||||
@@ -29,7 +29,7 @@ class CustomSQLiteOpenHelper extends SQLiteOpenHelper {
|
||||
|
||||
private static final String TAG = CustomSQLiteOpenHelper.class.getSimpleName();
|
||||
|
||||
private static final int DATABASE_VERSION = 39;
|
||||
private static final int DATABASE_VERSION = 40;
|
||||
|
||||
private final Context context;
|
||||
|
||||
@@ -83,6 +83,7 @@ class CustomSQLiteOpenHelper extends SQLiteOpenHelper {
|
||||
case 37 -> upgradeFrom36to37(db);
|
||||
case 38 -> upgradeFrom37to38(db);
|
||||
case 39 -> upgradeFrom38to39(db);
|
||||
case 40 -> upgradeFrom39to40(db);
|
||||
default -> throw new RuntimeException("Not implemented: upgrade to " + toVersion);
|
||||
}
|
||||
}
|
||||
@@ -109,6 +110,7 @@ class CustomSQLiteOpenHelper extends SQLiteOpenHelper {
|
||||
case 36 -> downgradeFrom37to36(db);
|
||||
case 37 -> downgradeFrom38to37(db);
|
||||
case 38 -> downgradeFrom39to38(db);
|
||||
case 39 -> downgradeFrom40to39(db);
|
||||
default -> throw new RuntimeException("Not implemented: downgrade to " + toVersion);
|
||||
}
|
||||
}
|
||||
@@ -704,4 +706,32 @@ class CustomSQLiteOpenHelper extends SQLiteOpenHelper {
|
||||
db.setTransactionSuccessful();
|
||||
db.endTransaction();
|
||||
}
|
||||
|
||||
private void upgradeFrom39to40(SQLiteDatabase db) {
|
||||
db.beginTransaction();
|
||||
|
||||
db.execSQL("ALTER TABLE markers RENAME TO markers_old");
|
||||
db.execSQL("CREATE TABLE markers (_id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, description TEXT, category TEXT, trackid INTEGER NOT NULL, longitude INTEGER, latitude INTEGER, time INTEGER, elevation FLOAT, accuracy FLOAT, bearing FLOAT, photoUrl TEXT, FOREIGN KEY (trackid) REFERENCES tracks(_id) ON UPDATE CASCADE ON DELETE CASCADE)");
|
||||
db.execSQL("INSERT INTO markers SELECT _id, name, description, category, trackid, longitude, latitude, time, elevation, accuracy, bearing, photoUrl FROM markers_old");
|
||||
db.execSQL("DROP TABLE markers_old");
|
||||
|
||||
db.execSQL("CREATE INDEX markers_trackid_index ON markers(trackid)");
|
||||
|
||||
db.setTransactionSuccessful();
|
||||
db.endTransaction();
|
||||
}
|
||||
|
||||
private void downgradeFrom40to39(SQLiteDatabase db) {
|
||||
db.beginTransaction();
|
||||
|
||||
db.execSQL("ALTER TABLE markers RENAME TO markers_old");
|
||||
db.execSQL("CREATE TABLE markers (_id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, description TEXT, category TEXT, icon TEXT, trackid INTEGER NOT NULL, longitude INTEGER, latitude INTEGER, time INTEGER, elevation FLOAT, accuracy FLOAT, bearing FLOAT, photoUrl TEXT, FOREIGN KEY (trackid) REFERENCES tracks(_id) ON UPDATE CASCADE ON DELETE CASCADE)");
|
||||
db.execSQL("INSERT INTO markers SELECT _id, name, description, category, 'http://maps.google.com/mapfiles/ms/micons/blue-pushpin.png', trackid, longitude, latitude, time, elevation, accuracy, bearing, photoUrl FROM markers_old");
|
||||
db.execSQL("DROP TABLE markers_old");
|
||||
|
||||
db.execSQL("CREATE INDEX markers_trackid_index ON markers(trackid)");
|
||||
|
||||
db.setTransactionSuccessful();
|
||||
db.endTransaction();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,8 +24,6 @@ public record Marker(
|
||||
String description,
|
||||
@NonNull
|
||||
String category,
|
||||
@NonNull
|
||||
String icon,
|
||||
|
||||
//Some data might not be used.
|
||||
Position position,
|
||||
|
||||
@@ -22,9 +22,6 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* NOTE: A marker is indirectly (via it's {@link Position}) assigned to one {@link TrackPoint} via position.time.
|
||||
*
|
||||
@@ -38,13 +35,12 @@ public final class MarkerBuilder {
|
||||
private String name;
|
||||
private String description;
|
||||
private String category;
|
||||
private String icon;
|
||||
private final Track.Id trackId;
|
||||
|
||||
//Some data might not be used.
|
||||
private final Position position;
|
||||
|
||||
private Uri photoUrl = null;
|
||||
private Uri photoUrl;
|
||||
|
||||
@VisibleForTesting
|
||||
public MarkerBuilder(@Nullable Track.Id trackId, @NonNull TrackPoint trackPoint) {
|
||||
@@ -53,7 +49,6 @@ public final class MarkerBuilder {
|
||||
this.name = "";
|
||||
this.description = "";
|
||||
this.category = "";
|
||||
this.icon = "";
|
||||
this.photoUrl = null;
|
||||
|
||||
if (!trackPoint.hasLocation())
|
||||
@@ -62,12 +57,11 @@ public final class MarkerBuilder {
|
||||
this.position = trackPoint.getPosition();
|
||||
}
|
||||
|
||||
public MarkerBuilder(@Nullable Track.Id trackId, @NonNull TrackPoint trackPoint, String name, String description, String category, String icon, Uri photoUrl) {
|
||||
public MarkerBuilder(@Nullable Track.Id trackId, @NonNull TrackPoint trackPoint, String name, String description, String category, Uri photoUrl) {
|
||||
this(trackId, trackPoint);
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.category = category;
|
||||
this.icon = icon;
|
||||
this.photoUrl = photoUrl;
|
||||
}
|
||||
|
||||
@@ -77,7 +71,6 @@ public final class MarkerBuilder {
|
||||
this.name = marker.name();
|
||||
this.description = marker.description();
|
||||
this.category = marker.category();
|
||||
this.icon = marker.icon();
|
||||
this.position = marker.position();
|
||||
this.photoUrl = marker.photoUrl();
|
||||
}
|
||||
@@ -113,10 +106,6 @@ public final class MarkerBuilder {
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
public void setIcon(String icon) {
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
public Track.Id getTrackId() {
|
||||
return trackId;
|
||||
}
|
||||
@@ -140,7 +129,6 @@ public final class MarkerBuilder {
|
||||
name,
|
||||
description,
|
||||
category,
|
||||
icon,
|
||||
position,
|
||||
photoUrl
|
||||
);
|
||||
|
||||
@@ -39,8 +39,6 @@ public interface MarkerColumns extends BaseColumns {
|
||||
String NAME = "name"; // marker name
|
||||
String DESCRIPTION = "description"; // marker description
|
||||
String CATEGORY = "category"; // marker category
|
||||
@Deprecated //TODO Remove: it is always: position
|
||||
String ICON = "icon"; // marker icon
|
||||
String TRACKID = "trackid"; // track id
|
||||
String LONGITUDE = "longitude"; // longitude
|
||||
String LATITUDE = "latitude"; // latitude
|
||||
@@ -56,7 +54,6 @@ public interface MarkerColumns extends BaseColumns {
|
||||
+ NAME + " TEXT, "
|
||||
+ DESCRIPTION + " TEXT, "
|
||||
+ CATEGORY + " TEXT, "
|
||||
+ ICON + " TEXT, "
|
||||
+ TRACKID + " INTEGER NOT NULL, "
|
||||
+ LONGITUDE + " INTEGER, "
|
||||
+ LATITUDE + " INTEGER, "
|
||||
|
||||
@@ -34,7 +34,6 @@ import java.util.Locale;
|
||||
import de.dennisguse.opentracks.data.models.Altitude;
|
||||
import de.dennisguse.opentracks.data.models.Distance;
|
||||
import de.dennisguse.opentracks.data.models.Marker;
|
||||
import de.dennisguse.opentracks.data.models.MarkerBuilder;
|
||||
import de.dennisguse.opentracks.data.models.Position;
|
||||
import de.dennisguse.opentracks.data.models.Speed;
|
||||
import de.dennisguse.opentracks.data.models.Track;
|
||||
@@ -436,7 +435,6 @@ public class GPXTrackImporter extends DefaultHandler implements XMLImporter.Trac
|
||||
name != null ? name : "",
|
||||
description != null ? description : "",
|
||||
markerType != null ? markerType : "",
|
||||
null,
|
||||
trackPoint.getPosition(),
|
||||
photoUrl
|
||||
));
|
||||
|
||||
@@ -35,7 +35,6 @@ import java.util.Locale;
|
||||
|
||||
import de.dennisguse.opentracks.data.models.Distance;
|
||||
import de.dennisguse.opentracks.data.models.Marker;
|
||||
import de.dennisguse.opentracks.data.models.MarkerBuilder;
|
||||
import de.dennisguse.opentracks.data.models.Position;
|
||||
import de.dennisguse.opentracks.data.models.Speed;
|
||||
import de.dennisguse.opentracks.data.models.Track;
|
||||
@@ -270,7 +269,6 @@ public class KMLTrackImporter extends DefaultHandler implements XMLImporter.Trac
|
||||
name != null ? name : "",
|
||||
description != null ? description : "",
|
||||
activityTypeLocalized != null ? activityTypeLocalized : "",
|
||||
null,
|
||||
position,
|
||||
photoUrl
|
||||
));
|
||||
|
||||
@@ -227,11 +227,8 @@ public class TrackImporter {
|
||||
*/
|
||||
private void updateMarkers(Track.Id trackId) {
|
||||
markers.forEach(marker -> {
|
||||
if (marker.hasPhoto()) {
|
||||
if (marker.hasPhoto())
|
||||
marker.setPhotoUrl(getInternalPhotoUrl(trackId, marker.getPhotoUrl()));
|
||||
}
|
||||
|
||||
marker.setIcon(context.getString(R.string.marker_icon_url)); //TODO Why?
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,6 @@ import java.time.Duration;
|
||||
import de.dennisguse.opentracks.data.ContentProviderUtils;
|
||||
import de.dennisguse.opentracks.data.models.Distance;
|
||||
import de.dennisguse.opentracks.data.models.Marker;
|
||||
import de.dennisguse.opentracks.data.models.MarkerBuilder;
|
||||
import de.dennisguse.opentracks.data.models.Track;
|
||||
import de.dennisguse.opentracks.data.models.TrackPoint;
|
||||
import de.dennisguse.opentracks.sensors.GpsStatusValue;
|
||||
@@ -256,7 +255,6 @@ public class TrackRecordingService extends Service implements TrackPointCreator.
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
trackPoint.getPosition(),
|
||||
null
|
||||
);
|
||||
|
||||
@@ -143,14 +143,12 @@ public class MarkerEditViewModel extends AndroidViewModel {
|
||||
nextMarkerNumber = 1;
|
||||
}
|
||||
String name = getApplication().getString(R.string.marker_name_format, nextMarkerNumber + 1);
|
||||
String icon = getApplication().getString(R.string.marker_icon_url);
|
||||
|
||||
Marker marker = new Marker(
|
||||
null,
|
||||
trackId,
|
||||
name,
|
||||
"",
|
||||
icon,
|
||||
"",
|
||||
trackPoint.getPosition(),
|
||||
null);
|
||||
|
||||
@@ -37,8 +37,6 @@ limitations under the License.
|
||||
<a href="https://github.com/material-components/material-components-android">Material Components for Android</a> (Apache License, Version 2.0)
|
||||
</string>
|
||||
|
||||
<string name="marker_icon_url" translatable="false">http://maps.google.com/mapfiles/ms/micons/blue-pushpin.png</string>
|
||||
|
||||
<string name="sensor_unit_beats_per_minute" translatable="false">bpm</string>
|
||||
<string name="sensor_unit_rounds_per_minute" translatable="false">rpm</string>
|
||||
<string name="sensor_unit_power" translatable="false">w</string>
|
||||
|
||||
Reference in New Issue
Block a user