Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# These are supported funding model platforms
# github: [labexp]
liberapay: OSMTracker
24 changes: 23 additions & 1 deletion .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,34 @@ jobs:
distribution: 'temurin'
java-version: '17'

- name: Setup Signing Keystore
run: |
# 1. Decode nightly keystore secret
echo "${{ secrets.NIGHTLY_KEYSTORE }}" | base64 -d > /tmp/nightly-keystore.jks
echo "Keystore created in /tmp/nightly-keystore.jks"

# Verify
echo "✅ Keystore created in: /tmp/nightly-keystore.jks"
ls -la /tmp/nightly-keystore.jks
echo "ks_path=/tmp/nightly-keystore.jks" >> $GITHUB_OUTPUT


- name: Setup Android SDK
uses: android-actions/setup-android@v2

- name: Build with Gradle
run: ./gradlew assembleDebug --stacktrace
run: |
./gradlew assembleDebug --stacktrace \
-Pandroid.injected.signing.store.file="/tmp/nightly-keystore.jks" \
-Pandroid.injected.signing.store.password="${{ secrets.KEYSTORE_PASSWORD }}" \
-Pandroid.injected.signing.key.alias="${{ secrets.KEY_ALIAS }}" \
-Pandroid.injected.signing.key.password="${{ secrets.KEY_PASSWORD }}"

- name: Cleanup Keystore
run: |
echo "Cleaning keystore..."
rm -f app/nightly-keystore.jks
echo "✅ Keystore removed"

- name: Rename output APK
run: |
Expand Down
31 changes: 20 additions & 11 deletions app/src/main/java/net/osmtracker/activity/DisplayTrackMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import net.osmtracker.R;
import net.osmtracker.db.TrackContentProvider;
import net.osmtracker.overlay.WayPointsOverlay;
import net.osmtracker.overlay.Polylines;

import org.osmdroid.api.IMapController;
import org.osmdroid.config.Configuration;
Expand All @@ -33,7 +34,6 @@
import org.osmdroid.util.GeoPoint;
import org.osmdroid.views.CustomZoomButtonsController;
import org.osmdroid.views.MapView;
import org.osmdroid.views.overlay.Polyline;
import org.osmdroid.views.overlay.ScaleBarOverlay;
import org.osmdroid.views.overlay.mylocation.SimpleLocationOverlay;

Expand Down Expand Up @@ -118,7 +118,7 @@ public class DisplayTrackMap extends Activity {
/**
* OSM view overlay that displays current path
*/
private Polyline polyline;
private Polylines polylines;

/**
* OSM view overlay that displays waypoints
Expand Down Expand Up @@ -158,6 +158,11 @@ public class DisplayTrackMap extends Activity {
*/
private Integer lastTrackPointIdProcessed = null;

/**
* The id of the last segment
*/
private int prevSegmentId=-1;

/**
* Observes changes on track points
*/
Expand Down Expand Up @@ -303,6 +308,7 @@ private void resumeActivity() {
// This ensures that all waypoints for the track will be reloaded
// from the database to populate the path layout
lastTrackPointIdProcessed = null;
prevSegmentId = -1;

// Reload path
pathChanged();
Expand All @@ -321,7 +327,7 @@ protected void onPause() {
getContentResolver().unregisterContentObserver(trackpointContentObserver);

// Clear the points list.
polyline.setPoints(new ArrayList<>());
polylines.clear();

super.onPause();
}
Expand Down Expand Up @@ -387,12 +393,8 @@ private void createOverlays() {
this.getWindowManager().getDefaultDisplay().getMetrics(metrics);

// set with to hopefully DPI independent 0.5mm
polyline = new Polyline();
Paint paint = polyline.getOutlinePaint();
paint.setColor(Color.BLUE);
paint.setStrokeWidth((float) (metrics.densityDpi / 25.4 / 2));
osmView.getOverlayManager().add(polyline);

polylines = new Polylines(Color.BLUE, (float)(metrics.densityDpi / 25.4 / 2), osmView);

myLocationOverlay = new SimpleLocationOverlay(this);
osmView.getOverlays().add(myLocationOverlay);

Expand Down Expand Up @@ -439,7 +441,7 @@ private void pathChanged() {

// Projection: The columns to retrieve. Here, we want the latitude,
// longitude and primary key only
String[] projection = {TrackContentProvider.Schema.COL_LATITUDE, TrackContentProvider.Schema.COL_LONGITUDE, TrackContentProvider.Schema.COL_ID};
String[] projection = {TrackContentProvider.Schema.COL_LATITUDE, TrackContentProvider.Schema.COL_LONGITUDE, TrackContentProvider.Schema.COL_ID, TrackContentProvider.Schema.COL_SEG_ID };
// Selection: The where clause to use
String selection = null;
// SelectionArgs: The parameter replacements to use for the '?' in the selection
Expand Down Expand Up @@ -470,13 +472,20 @@ private void pathChanged() {
int primaryKeyColumnIndex = c.getColumnIndex(TrackContentProvider.Schema.COL_ID);
int latitudeColumnIndex = c.getColumnIndex(TrackContentProvider.Schema.COL_LATITUDE);
int longitudeColumnIndex = c.getColumnIndex(TrackContentProvider.Schema.COL_LONGITUDE);
int segmentIdColumnIndex = c.getColumnIndex(TrackContentProvider.Schema.COL_SEG_ID);

// Add each new point to the track
while (!c.isAfterLast()) {
lastLat = c.getDouble(latitudeColumnIndex);
lastLon = c.getDouble(longitudeColumnIndex);
lastTrackPointIdProcessed = c.getInt(primaryKeyColumnIndex);
polyline.addPoint(new GeoPoint(lastLat, lastLon));
int segmentId = c.getInt(segmentIdColumnIndex);
if(segmentId != prevSegmentId) {
polylines.nextSegment();
}
prevSegmentId = segmentId;

polylines.addPoint(new GeoPoint(lastLat, lastLon));
if (doInitialBoundsCalc) {
if (lastLat < minLat) minLat = lastLat;
if (lastLon < minLon) minLon = lastLon;
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/net/osmtracker/db/DataHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public DataHelper(Context c) {
* @param pressure
* atmospheric pressure
*/
public void track(long trackId, Location location, float azimuth, int accuracy, float pressure) {
public void track(long trackId, Location location, float azimuth, int accuracy, float pressure, long segId) {
Log.v(TAG, "Tracking (trackId=" + trackId + ") location: " + location + " azimuth: " + azimuth + ", accuracy: " + accuracy);
ContentValues values = new ContentValues();
values.put(TrackContentProvider.Schema.COL_TRACK_ID, trackId);
Expand Down Expand Up @@ -180,6 +180,8 @@ public void track(long trackId, Location location, float azimuth, int accuracy,
values.put(TrackContentProvider.Schema.COL_ATMOSPHERIC_PRESSURE, pressure);
}

values.put(TrackContentProvider.Schema.COL_SEG_ID, segId);

Uri trackUri = ContentUris.withAppendedId(TrackContentProvider.CONTENT_URI_TRACK, trackId);
contentResolver.insert(Uri.withAppendedPath(trackUri, TrackContentProvider.Schema.TBL_TRACKPOINT + "s"), values);
}
Expand Down
5 changes: 4 additions & 1 deletion app/src/main/java/net/osmtracker/db/DatabaseHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ public class DatabaseHelper extends SQLiteOpenHelper {
+ TrackContentProvider.Schema.COL_TIMESTAMP + " long not null,"
+ TrackContentProvider.Schema.COL_COMPASS + " double null,"
+ TrackContentProvider.Schema.COL_COMPASS_ACCURACY + " integer null,"
+ TrackContentProvider.Schema.COL_ATMOSPHERIC_PRESSURE + " double null" + ")";
+ TrackContentProvider.Schema.COL_ATMOSPHERIC_PRESSURE + " double null,"
+ TrackContentProvider.Schema.COL_SEG_ID + " integer not null default 0"
+ ")";

/**
* SQL for creating index TRACKPOINT_idx (track id)
Expand Down Expand Up @@ -201,6 +203,7 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("alter table " + TrackContentProvider.Schema.TBL_TRACKPOINT + " add column " + TrackContentProvider.Schema.COL_ATMOSPHERIC_PRESSURE + " double null");
db.execSQL("alter table " + TrackContentProvider.Schema.TBL_WAYPOINT + " add column " + TrackContentProvider.Schema.COL_ATMOSPHERIC_PRESSURE + " double null");
case 17:
db.execSQL("alter table "+TrackContentProvider.Schema.TBL_TRACKPOINT + " add column " + TrackContentProvider.Schema.COL_SEG_ID + " integer default 0");
db.execSQL(SQL_CREATE_TABLE_NOTE);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public class TrackContentProvider extends ContentProvider {
Schema.COL_OSM_VISIBILITY,
Schema.COL_START_DATE,
"count(" + Schema.TBL_TRACKPOINT + "." + Schema.COL_ID + ") as " + Schema.COL_TRACKPOINT_COUNT,
"(SELECT max("+Schema.TBL_TRACKPOINT+"."+Schema.COL_SEG_ID+") FROM "+Schema.TBL_TRACKPOINT+" WHERE "+Schema.TBL_TRACKPOINT+"."+Schema.COL_TRACK_ID+" = " + Schema.TBL_TRACK + "." + Schema.COL_ID + ") as " + Schema.COL_MAX_SEG_ID,
"(SELECT count(" + Schema.TBL_WAYPOINT + "." + Schema.COL_TRACK_ID +") " +
"FROM " + Schema.TBL_WAYPOINT + " " +
"WHERE " + Schema.TBL_WAYPOINT + "." + Schema.COL_TRACK_ID +" " +
Expand Down Expand Up @@ -593,10 +594,14 @@ public static final class Schema {
public static final String COL_COMPASS = "compass_heading";
public static final String COL_COMPASS_ACCURACY = "compass_accuracy";
public static final String COL_ATMOSPHERIC_PRESSURE = "atmospheric_pressure";


public static final String COL_SEG_ID = "segment_id";

// virtual colums that are used in some sqls but dont exist in database
public static final String COL_TRACKPOINT_COUNT = "tp_count";
public static final String COL_WAYPOINT_COUNT = "wp_count";
public static final String COL_MAX_SEG_ID = "max_segment_id";

public static final String COL_NOTE_COUNT = "note_count";

// Codes for UriMatcher
Expand Down
14 changes: 12 additions & 2 deletions app/src/main/java/net/osmtracker/db/model/Track.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static OSMVisibility fromPosition(int position) {
private String description;
private OSMVisibility visibility;
private List<String> tags = new ArrayList<String>();
private int tpCount, wpCount, noteCount;
private int tpCount, wpCount, noteCount, maxSegId;
private long trackDate;
private long trackId;

Expand Down Expand Up @@ -92,6 +92,9 @@ public static Track build(final long trackId, Cursor tc, ContentResolver cr, boo
out.tpCount = tc.getInt(tc.getColumnIndex(TrackContentProvider.Schema.COL_TRACKPOINT_COUNT));

out.wpCount = tc.getInt(tc.getColumnIndex(TrackContentProvider.Schema.COL_WAYPOINT_COUNT));

int maxSegIdIdx = tc.getColumnIndex(TrackContentProvider.Schema.COL_MAX_SEG_ID);
out.maxSegId = tc.isNull(maxSegIdIdx) ? 0 :tc.getInt(maxSegIdIdx);

out.noteCount = tc.getInt(tc.getColumnIndex(TrackContentProvider.Schema.COL_NOTE_COUNT));

Expand Down Expand Up @@ -147,9 +150,12 @@ public void setWpCount(int wpCount) {
this.wpCount = wpCount;
}

public void setMaxSegId(int maxSegId) {
this.maxSegId = maxSegId;
}
public void setNoteCount(int noteCount) {
this.noteCount = noteCount;
}
}

public void setTracktDate(long tracktDate) {
this.trackDate = tracktDate;
Expand Down Expand Up @@ -193,6 +199,10 @@ public Integer getWpCount() {
return wpCount;
}

public Integer getMaxSegId() {
return maxSegId;
}

public Integer getTpCount() {
return tpCount;
}
Expand Down
10 changes: 9 additions & 1 deletion app/src/main/java/net/osmtracker/gpx/ExportTrackTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,16 @@ private void writeTrackPoints(String trackName, Writer fw, Cursor c, boolean fil
fw.write("\t\t" + "<trkseg>" + "\n");

int i=0;
int prevSegId=-1;
for(c.moveToFirst(); !c.isAfterLast(); c.moveToNext(),i++) {
StringBuffer out = new StringBuffer();
int segId = c.getInt(c.getColumnIndex(TrackContentProvider.Schema.COL_SEG_ID));
if(prevSegId != -1 && segId != prevSegId) {
fw.write("\t\t" + "</trkseg>" + "\n");
fw.write("\t\t" + "<trkseg>" + "\n");
}
prevSegId = segId;

out.append("\t\t\t" + "<trkpt lat=\""
+ c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_LATITUDE)) + "\" "
+ "lon=\"" + c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_LONGITUDE)) + "\">" + "\n");
Expand Down Expand Up @@ -626,4 +634,4 @@ public String sanitizeTrackName(String trackName){
public String getErrorMsg() {
return errorMsg;
}
}
}
61 changes: 61 additions & 0 deletions app/src/main/java/net/osmtracker/overlay/Polylines.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package net.osmtracker.overlay;

import java.util.ArrayList;
import java.util.List;

import org.osmdroid.util.GeoPoint;
import org.osmdroid.views.MapView;
import org.osmdroid.views.overlay.Polyline;

import android.graphics.Paint;

/**
* Collection of Polylines, useful to draw interrupted paths
*/
public class Polylines {
private int color;
private float width;
private MapView osmView;
private boolean havePoint;

private int curIdx=0;

private List<Polyline> polylines = new ArrayList<Polyline>();

private void addPolyline() {
Polyline polyline = new Polyline();
Paint paint = polyline.getOutlinePaint();
paint.setColor(color);
paint.setStrokeWidth(width);

polylines.add(polyline);
osmView.getOverlayManager().add(polyline);
}

public void clear() {
for(Polyline polyline : polylines)
polyline.setPoints(new ArrayList<>());
curIdx=0;
}

public Polylines(int color, float width, MapView osmView) {
this.color=color;
this.width=width;
this.osmView = osmView;
addPolyline();
havePoint=false;
}

public void addPoint(GeoPoint gp) {
if(curIdx >= polylines.size())
addPolyline();
polylines.get(curIdx).addPoint(gp);
havePoint=true;
}

public void nextSegment() {
if(havePoint)
curIdx++;
havePoint=false;
}
}
Loading