Merge pull request #10689 from osmandapp/fix_waypoints_currently_recording
Fix saving waypoints currently recording
This commit is contained in:
commit
6f32c8cf0d
1 changed files with 78 additions and 62 deletions
|
@ -40,7 +40,7 @@ import java.util.Map;
|
|||
public class SavingTrackHelper extends SQLiteOpenHelper {
|
||||
|
||||
public final static String DATABASE_NAME = "tracks"; //$NON-NLS-1$
|
||||
public final static int DATABASE_VERSION = 6;
|
||||
public final static int DATABASE_VERSION = 7;
|
||||
|
||||
public final static String TRACK_NAME = "track"; //$NON-NLS-1$
|
||||
public final static String TRACK_COL_DATE = "date"; //$NON-NLS-1$
|
||||
|
@ -59,6 +59,8 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
public final static String POINT_COL_CATEGORY = "category"; //$NON-NLS-1$
|
||||
public final static String POINT_COL_DESCRIPTION = "description"; //$NON-NLS-1$
|
||||
public final static String POINT_COL_COLOR = "color"; //$NON-NLS-1$
|
||||
public final static String POINT_COL_ICON = "icon"; //$NON-NLS-1$
|
||||
public final static String POINT_COL_BACKGROUND = "background"; //$NON-NLS-1$
|
||||
|
||||
public final static float NO_HEADING = -1.0f;
|
||||
|
||||
|
@ -92,7 +94,10 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
+ TRACK_COL_DATE + ", " + TRACK_COL_HEADING + ")"
|
||||
+ " VALUES (?, ?, ?, ?, ?, ?, ?)"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
insertPointsScript = "INSERT INTO " + POINT_NAME + " VALUES (?, ?, ?, ?, ?, ?, ?)"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
insertPointsScript = "INSERT INTO " + POINT_NAME + " (" + POINT_COL_LAT + ", " + POINT_COL_LON + ", "
|
||||
+ POINT_COL_DATE + ", " + POINT_COL_DESCRIPTION + ", " + POINT_COL_NAME + ", "
|
||||
+ POINT_COL_CATEGORY + ", " + POINT_COL_COLOR + ", " + POINT_COL_ICON + ", "
|
||||
+ POINT_COL_BACKGROUND + ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -112,7 +117,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
try {
|
||||
db.execSQL("CREATE TABLE " + POINT_NAME + " (" + POINT_COL_LAT + " double, " + POINT_COL_LON + " double, " //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||
+ POINT_COL_DATE + " long, " + POINT_COL_DESCRIPTION + " text, " + POINT_COL_NAME + " text, "
|
||||
+ POINT_COL_CATEGORY + " text, " + POINT_COL_COLOR + " long" + ")"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ POINT_COL_CATEGORY + " text, " + POINT_COL_COLOR + " long, " + POINT_COL_ICON + " text, " + POINT_COL_BACKGROUND + " text )"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
} catch (RuntimeException e) {
|
||||
// ignore if already exists
|
||||
}
|
||||
|
@ -136,6 +141,10 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
if (oldVersion < 6) {
|
||||
db.execSQL("ALTER TABLE " + TRACK_NAME + " ADD " + TRACK_COL_HEADING + " float");
|
||||
}
|
||||
if (oldVersion < 7) {
|
||||
db.execSQL("ALTER TABLE " + POINT_NAME + " ADD " + POINT_COL_ICON + " text");
|
||||
db.execSQL("ALTER TABLE " + POINT_NAME + " ADD " + POINT_COL_BACKGROUND + " text");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -294,7 +303,8 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
|
||||
private void collectDBPoints(SQLiteDatabase db, Map<String, GPXFile> dataTracks) {
|
||||
Cursor query = db.rawQuery("SELECT " + POINT_COL_LAT + "," + POINT_COL_LON + "," + POINT_COL_DATE + "," //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||
+ POINT_COL_DESCRIPTION + "," + POINT_COL_NAME + "," + POINT_COL_CATEGORY + "," + POINT_COL_COLOR + " FROM " + POINT_NAME+" ORDER BY " + POINT_COL_DATE +" ASC", null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
+ POINT_COL_DESCRIPTION + "," + POINT_COL_NAME + "," + POINT_COL_CATEGORY + "," + POINT_COL_COLOR + ","
|
||||
+ POINT_COL_ICON + "," + POINT_COL_BACKGROUND + " FROM " + POINT_NAME + " ORDER BY " + POINT_COL_DATE + " ASC", null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
if (query.moveToFirst()) {
|
||||
do {
|
||||
WptPt pt = new WptPt();
|
||||
|
@ -309,6 +319,8 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
if (color != 0) {
|
||||
pt.setColor(color);
|
||||
}
|
||||
pt.setIconName(query.getString(7));
|
||||
pt.setBackgroundType(query.getString(8));
|
||||
|
||||
// check if name is extension (needed for audio/video plugin & josm integration)
|
||||
if (pt.name != null && pt.name.length() > 4 && pt.name.charAt(pt.name.length() - 4) == '.') {
|
||||
|
@ -370,7 +382,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
if (!newInterval) {
|
||||
segment.points.add(pt);
|
||||
}
|
||||
String date = new SimpleDateFormat("yyyy-MM-dd", Locale.US).format(new Date(time));; //$NON-NLS-1$
|
||||
String date = new SimpleDateFormat("yyyy-MM-dd", Locale.US).format(new Date(time)); //$NON-NLS-1$
|
||||
if (dataTracks.containsKey(date)) {
|
||||
GPXFile gpx = dataTracks.get(date);
|
||||
gpx.tracks.add(track);
|
||||
|
@ -529,7 +541,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
ctx.getSelectedGpxHelper().addPoint(pt, currentTrack.getModifiableGpxFile());
|
||||
currentTrack.getModifiableGpxFile().modifiedTime = time;
|
||||
points++;
|
||||
execWithClose(insertPointsScript, new Object[] { lat, lon, time, description, name, category, color });
|
||||
execWithClose(insertPointsScript, new Object[]{lat, lon, time, description, name, category, color, iconName, backgroundName});
|
||||
return pt;
|
||||
}
|
||||
|
||||
|
@ -549,6 +561,8 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
params.add(name);
|
||||
params.add(category);
|
||||
params.add(color);
|
||||
params.add(iconName);
|
||||
params.add(iconBackground);
|
||||
|
||||
params.add(pt.getLatitude());
|
||||
params.add(pt.getLongitude());
|
||||
|
@ -563,7 +577,9 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
+ POINT_COL_DESCRIPTION + "=?, "
|
||||
+ POINT_COL_NAME + "=?, "
|
||||
+ POINT_COL_CATEGORY + "=?, "
|
||||
+ POINT_COL_COLOR + "=? "
|
||||
+ POINT_COL_COLOR + "=?, "
|
||||
+ POINT_COL_ICON + "=?, "
|
||||
+ POINT_COL_BACKGROUND + "=? "
|
||||
+ "WHERE "
|
||||
+ POINT_COL_LAT + "=? AND "
|
||||
+ POINT_COL_LON + "=? AND "
|
||||
|
|
Loading…
Reference in a new issue