checkpoint

This commit is contained in:
voussoir 2023-03-13 16:58:39 -07:00
parent aca4cf20c0
commit c3d2223524
3 changed files with 21 additions and 12 deletions

View file

@ -1,5 +1,6 @@
package org.y20k.trackbook
import android.content.ContentValues
import android.database.Cursor
import android.database.sqlite.SQLiteDatabase
import android.database.sqlite.SQLiteDatabase.openOrCreateDatabase
import android.util.Log
@ -68,6 +69,14 @@ class Database(val trackbook: Trackbook)
connection.insert("trkpt", null, values)
}
fun delete_homepoint(id: Long)
{
Log.i("VOUSSOIR", "Database.delete_homepoint")
begin_transaction()
connection.delete("homepoints", "id = ?", arrayOf(id.toString()))
commit()
}
fun insert_homepoint(id: Long, name: String, latitude: Double, longitude: Double, radius: Double)
{
Log.i("VOUSSOIR", "Database.insert_homepoint")
@ -81,15 +90,6 @@ class Database(val trackbook: Trackbook)
begin_transaction()
connection.insert("homepoints", null, values)
commit()
trackbook.load_homepoints()
}
fun delete_homepoint(id: Long)
{
Log.i("VOUSSOIR", "Database.delete_homepoint")
begin_transaction()
connection.delete("homepoints", "id = ?", arrayOf(id.toString()))
commit()
}
fun update_homepoint(id: Long, name: String, radius: Double)
@ -106,11 +106,19 @@ class Database(val trackbook: Trackbook)
private fun initialize_tables()
{
this.connection.beginTransaction()
begin_transaction()
this.connection.execSQL("CREATE TABLE IF NOT EXISTS meta(name TEXT PRIMARY KEY, value TEXT)")
this.connection.execSQL("CREATE TABLE IF NOT EXISTS trkpt(lat REAL NOT NULL, lon REAL NOT NULL, time INTEGER NOT NULL, accuracy REAL, device_id INTEGER NOT NULL, ele INTEGER, sat INTEGER, PRIMARY KEY(lat, lon, time, device_id))")
this.connection.execSQL("CREATE TABLE IF NOT EXISTS homepoints(id INTEGER PRIMARY KEY, lat REAL NOT NULL, lon REAL NOT NULL, radius REAL NOT NULL, name TEXT)")
this.connection.execSQL("PRAGMA user_version = ${Keys.CURRENT_TRACKLIST_FORMAT_VERSION}")
// The pragmas don't seem to execute unless you call moveToNext.
var cursor: Cursor
cursor = this.connection.rawQuery("PRAGMA journal_mode = DELETE", null)
cursor.moveToNext()
cursor.close()
cursor = this.connection.rawQuery("PRAGMA user_version = ${Keys.DATABASE_VERSION}", null)
cursor.moveToNext()
cursor.close()
// Not using this.commit because this.ready is not true yet.
this.connection.setTransactionSuccessful()
this.connection.endTransaction()
}

View file

@ -28,7 +28,7 @@ object Keys {
// version numbers
const val CURRENT_TRACK_FORMAT_VERSION: Int = 4
const val CURRENT_TRACKLIST_FORMAT_VERSION: Int = 0
const val DATABASE_VERSION: Int = 1
// intent actions
const val ACTION_START: String = "org.y20k.trackbook.action.START"

View file

@ -98,6 +98,7 @@ data class TrackFragmentLayoutHolder(
mapView.addMapListener(this)
mapView.isTilesScaledToDpi = true
mapView.setTileSource(TileSourceFactory.MAPNIK)
mapView.isVerticalMapRepetitionEnabled = false
mapView.setMultiTouchControls(true)
mapView.zoomController.setVisibility(org.osmdroid.views.CustomZoomButtonsController.Visibility.NEVER)
controller.setCenter(GeoPoint(track.view_latitude, track.view_longitude))