checkpoint
This commit is contained in:
parent
e96bfac4a9
commit
c434d3b840
31 changed files with 189 additions and 159 deletions
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.y20k.trackbook">
|
||||
package="net.voussoir.trkpt">
|
||||
|
||||
|
||||
|
||||
|
@ -19,11 +19,10 @@
|
|||
<!-- DANGEROUS PERMISSIONS, must request -->
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACTIVITY_RECOGNITION" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<application
|
||||
android:name="org.y20k.trackbook.Trackbook"
|
||||
android:name="net.voussoir.trkpt.Trackbook"
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
|
@ -33,7 +32,7 @@
|
|||
|
||||
<!-- MAIN ACTIVITY -->
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:name="net.voussoir.trkpt.MainActivity"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
@ -43,19 +42,19 @@
|
|||
|
||||
<!-- TRACKER SERVICE -->
|
||||
<service
|
||||
android:name=".TrackerService"
|
||||
android:name="net.voussoir.trkpt.TrackerService"
|
||||
android:foregroundServiceType="location"
|
||||
android:exported="false">
|
||||
<intent-filter>
|
||||
<action android:name="org.y20k.trackbook.action.START" />
|
||||
<action android:name="org.y20k.trackbook.action.STOP" />
|
||||
<action android:name="org.y20k.trackbook.action.DISMISS" />
|
||||
<action android:name="net.voussoir.trkpt.action.START" />
|
||||
<action android:name="net.voussoir.trkpt.action.STOP" />
|
||||
<action android:name="net.voussoir.trkpt.action.DISMISS" />
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
<!-- TRACKING TOGGLE SERVICE SYSTEM QUICK SETTINGS -->
|
||||
<service
|
||||
android:name=".TrackingToggleTileService"
|
||||
android:name="net.voussoir.trkpt.TrackingToggleTileService"
|
||||
android:label="@string/quick_settings_tile_title_default"
|
||||
android:icon="@drawable/ic_notification_icon_small_24dp"
|
||||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
package org.y20k.trackbook
|
||||
package net.voussoir.trkpt
|
||||
import android.content.ContentValues
|
||||
import android.database.Cursor
|
||||
import android.database.sqlite.SQLiteDatabase
|
||||
import android.database.sqlite.SQLiteDatabase.openOrCreateDatabase
|
||||
import android.util.Log
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
|
||||
class Database(val trackbook: Trackbook)
|
||||
class Database(val trackbook: net.voussoir.trkpt.Trackbook)
|
||||
{
|
||||
var ready: Boolean = false
|
||||
lateinit var file: File
|
||||
|
@ -61,7 +60,7 @@ class Database(val trackbook: Trackbook)
|
|||
commit()
|
||||
}
|
||||
|
||||
fun insert_trkpt(trkpt: Trkpt)
|
||||
fun insert_trkpt(trkpt: net.voussoir.trkpt.Trkpt)
|
||||
{
|
||||
Log.i("VOUSSOIR", "Database.insert_trkpt")
|
||||
val values = ContentValues().apply {
|
||||
|
@ -124,7 +123,7 @@ class Database(val trackbook: Trackbook)
|
|||
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 = this.connection.rawQuery("PRAGMA user_version = ${net.voussoir.trkpt.Keys.DATABASE_VERSION}", null)
|
||||
cursor.moveToNext()
|
||||
cursor.close()
|
||||
// Not using this.commit because this.ready is not true yet.
|
|
@ -1,4 +1,4 @@
|
|||
package org.y20k.trackbook
|
||||
package net.voussoir.trkpt
|
||||
import android.location.Location
|
||||
import java.util.*
|
||||
|
|
@ -14,9 +14,8 @@
|
|||
* https://github.com/osmdroid/osmdroid
|
||||
*/
|
||||
|
||||
package org.y20k.trackbook
|
||||
package net.voussoir.trkpt
|
||||
|
||||
import android.graphics.Color
|
||||
import java.util.*
|
||||
|
||||
/*
|
||||
|
@ -32,8 +31,8 @@ object Keys {
|
|||
const val DATABASE_VERSION: Int = 1
|
||||
|
||||
// intent actions
|
||||
const val ACTION_START: String = "org.y20k.trackbook.action.START"
|
||||
const val ACTION_STOP: String = "org.y20k.trackbook.action.STOP"
|
||||
const val ACTION_START: String = "net.voussoir.trkpt.action.START"
|
||||
const val ACTION_STOP: String = "net.voussoir.trkpt.action.STOP"
|
||||
|
||||
// args
|
||||
const val ARG_TRACK_TITLE: String = "ArgTrackTitle"
|
||||
|
@ -112,5 +111,4 @@ object Keys {
|
|||
const val NOTIFICATION_CHANNEL_RECORDING: String = "notificationChannelIdRecordingChannel"
|
||||
|
||||
const val POLYLINE_THICKNESS = 4F
|
||||
val POLYLINE_COLOR = Color.argb(255, 255, 0, 255)
|
||||
}
|
|
@ -14,20 +14,20 @@
|
|||
* https://github.com/osmdroid/osmdroid
|
||||
*/
|
||||
|
||||
package org.y20k.trackbook
|
||||
/*
|
||||
* Modified by voussoir for trkpt, forked from Trackbook.
|
||||
*/
|
||||
|
||||
package net.voussoir.trkpt
|
||||
|
||||
import android.Manifest
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
import android.content.pm.PackageManager
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.PowerManager
|
||||
import android.os.StrictMode
|
||||
import android.os.StrictMode.VmPolicy
|
||||
import android.provider.Settings
|
||||
import android.util.Log
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.ContextCompat
|
||||
|
@ -35,8 +35,8 @@ import androidx.navigation.fragment.NavHostFragment
|
|||
import androidx.navigation.ui.setupWithNavController
|
||||
import com.google.android.material.bottomnavigation.BottomNavigationView
|
||||
import org.osmdroid.config.Configuration
|
||||
import org.y20k.trackbook.helpers.AppThemeHelper
|
||||
import org.y20k.trackbook.helpers.PreferencesHelper
|
||||
import net.voussoir.trkpt.helpers.AppThemeHelper
|
||||
import net.voussoir.trkpt.helpers.PreferencesHelper
|
||||
|
||||
class MainActivity: AppCompatActivity()
|
||||
{
|
||||
|
@ -51,7 +51,7 @@ class MainActivity: AppCompatActivity()
|
|||
super.onCreate(savedInstanceState)
|
||||
request_permissions(this)
|
||||
// todo: remove after testing finished
|
||||
if (BuildConfig.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.R)
|
||||
if (net.voussoir.trkpt.BuildConfig.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.R)
|
||||
{
|
||||
StrictMode.setVmPolicy(
|
||||
VmPolicy.Builder()
|
||||
|
@ -62,7 +62,7 @@ class MainActivity: AppCompatActivity()
|
|||
}
|
||||
|
||||
// set user agent to prevent getting banned from the osm servers
|
||||
Configuration.getInstance().userAgentValue = BuildConfig.APPLICATION_ID
|
||||
Configuration.getInstance().userAgentValue = net.voussoir.trkpt.BuildConfig.APPLICATION_ID
|
||||
// set the path for osmdroid's files (e.g. tile cache)
|
||||
Configuration.getInstance().osmdroidBasePath = this.getExternalFilesDir(null)
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* https://github.com/osmdroid/osmdroid
|
||||
*/
|
||||
|
||||
package org.y20k.trackbook
|
||||
package net.voussoir.trkpt
|
||||
|
||||
import android.Manifest
|
||||
import android.app.Dialog
|
||||
|
@ -53,7 +53,8 @@ import org.osmdroid.views.overlay.Polyline
|
|||
import org.osmdroid.views.overlay.TilesOverlay
|
||||
import org.osmdroid.views.overlay.compass.CompassOverlay
|
||||
import org.osmdroid.views.overlay.compass.InternalCompassOrientationProvider
|
||||
import org.y20k.trackbook.helpers.*
|
||||
import net.voussoir.trkpt.helpers.*
|
||||
import net.voussoir.trkpt.R
|
||||
|
||||
class MapFragment : Fragment()
|
||||
{
|
||||
|
@ -219,7 +220,7 @@ class MapFragment : Fragment()
|
|||
{
|
||||
startTracking()
|
||||
}
|
||||
handler.post(location_update_redraw)
|
||||
handler.postDelayed(location_update_redraw, 0)
|
||||
}
|
||||
currentLocationButton.setOnClickListener {
|
||||
centerMap(currentBestLocation, animated=true)
|
||||
|
@ -452,7 +453,7 @@ class MapFragment : Fragment()
|
|||
clear_track_overlay()
|
||||
val pl = Polyline(mapView)
|
||||
pl.outlinePaint.strokeWidth = Keys.POLYLINE_THICKNESS
|
||||
pl.outlinePaint.color = Keys.POLYLINE_COLOR
|
||||
pl.outlinePaint.color = requireContext().getColor(R.color.fuchsia)
|
||||
mapView.overlays.add(pl)
|
||||
current_track_overlay = pl
|
||||
}
|
||||
|
@ -601,6 +602,7 @@ class MapFragment : Fragment()
|
|||
// get state of tracking and update button if necessary
|
||||
trackingState = trackerService.trackingState
|
||||
update_main_button()
|
||||
handler.postDelayed(location_update_redraw, 0)
|
||||
// register listener for changes in shared preferences
|
||||
PreferencesHelper.registerPreferenceChangeListener(sharedPreferenceChangeListener)
|
||||
// start listening for location updates
|
|
@ -14,7 +14,11 @@
|
|||
* https://github.com/osmdroid/osmdroid
|
||||
*/
|
||||
|
||||
package org.y20k.trackbook
|
||||
/*
|
||||
* Modified by voussoir for trkpt, forked from Trackbook.
|
||||
*/
|
||||
|
||||
package net.voussoir.trkpt
|
||||
|
||||
import YesNoDialog
|
||||
import android.app.Activity
|
||||
|
@ -40,10 +44,10 @@ import androidx.preference.PreferenceFragmentCompat
|
|||
import androidx.preference.SwitchPreferenceCompat
|
||||
import androidx.preference.contains
|
||||
import get_path_from_uri
|
||||
import org.y20k.trackbook.helpers.AppThemeHelper
|
||||
import org.y20k.trackbook.helpers.LengthUnitHelper
|
||||
import org.y20k.trackbook.helpers.PreferencesHelper
|
||||
import org.y20k.trackbook.helpers.random_device_id
|
||||
import net.voussoir.trkpt.helpers.AppThemeHelper
|
||||
import net.voussoir.trkpt.helpers.LengthUnitHelper
|
||||
import net.voussoir.trkpt.helpers.PreferencesHelper
|
||||
import net.voussoir.trkpt.helpers.random_device_id
|
||||
|
||||
class SettingsFragment : PreferenceFragmentCompat(), YesNoDialog.YesNoDialogListener
|
||||
{
|
|
@ -14,22 +14,25 @@
|
|||
* https://github.com/osmdroid/osmdroid
|
||||
*/
|
||||
|
||||
package org.y20k.trackbook
|
||||
/*
|
||||
* Modified by voussoir for trkpt, forked from Trackbook.
|
||||
*/
|
||||
|
||||
package net.voussoir.trkpt
|
||||
|
||||
import android.content.Context
|
||||
import android.database.Cursor
|
||||
import android.database.DatabaseUtils.dumpCursorToString
|
||||
import android.net.Uri
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.util.Log
|
||||
import android.widget.Toast
|
||||
import org.y20k.trackbook.helpers.iso8601
|
||||
import net.voussoir.trkpt.helpers.iso8601
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
||||
data class Track (
|
||||
val database: Database,
|
||||
val database: net.voussoir.trkpt.Database,
|
||||
val device_id: String,
|
||||
var start_time: Date,
|
||||
var end_time: Date,
|
|
@ -14,7 +14,11 @@
|
|||
* https://github.com/osmdroid/osmdroid
|
||||
*/
|
||||
|
||||
package org.y20k.trackbook
|
||||
/*
|
||||
* Modified by voussoir for trkpt, forked from Trackbook.
|
||||
*/
|
||||
|
||||
package net.voussoir.trkpt
|
||||
|
||||
import YesNoDialog
|
||||
import android.app.Activity
|
||||
|
@ -54,14 +58,14 @@ import org.osmdroid.views.overlay.TilesOverlay
|
|||
import org.osmdroid.views.overlay.simplefastpoint.SimpleFastPointOverlay
|
||||
import org.osmdroid.views.overlay.simplefastpoint.SimpleFastPointOverlayOptions
|
||||
import org.osmdroid.views.overlay.simplefastpoint.SimplePointTheme
|
||||
import org.y20k.trackbook.helpers.AppThemeHelper
|
||||
import org.y20k.trackbook.helpers.DateTimeHelper
|
||||
import org.y20k.trackbook.helpers.LengthUnitHelper
|
||||
import org.y20k.trackbook.helpers.PreferencesHelper
|
||||
import org.y20k.trackbook.helpers.UiHelper
|
||||
import org.y20k.trackbook.helpers.create_start_end_markers
|
||||
import org.y20k.trackbook.helpers.iso8601
|
||||
import org.y20k.trackbook.helpers.iso8601_parse
|
||||
import net.voussoir.trkpt.helpers.AppThemeHelper
|
||||
import net.voussoir.trkpt.helpers.DateTimeHelper
|
||||
import net.voussoir.trkpt.helpers.LengthUnitHelper
|
||||
import net.voussoir.trkpt.helpers.PreferencesHelper
|
||||
import net.voussoir.trkpt.helpers.UiHelper
|
||||
import net.voussoir.trkpt.helpers.create_start_end_markers
|
||||
import net.voussoir.trkpt.helpers.iso8601
|
||||
import net.voussoir.trkpt.helpers.iso8601_parse
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
||||
|
@ -114,7 +118,7 @@ class TrackFragment : Fragment(), MapListener, YesNoDialog.YesNoDialogListener
|
|||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View
|
||||
{
|
||||
this.trackbook = (requireContext().applicationContext as Trackbook)
|
||||
val database: Database = (requireActivity().applicationContext as Trackbook).database
|
||||
val database: net.voussoir.trkpt.Database = (requireActivity().applicationContext as Trackbook).database
|
||||
track = Track(
|
||||
database=database,
|
||||
name=this.requireArguments().getString(Keys.ARG_TRACK_TITLE, ""),
|
||||
|
@ -337,7 +341,7 @@ class TrackFragment : Fragment(), MapListener, YesNoDialog.YesNoDialogListener
|
|||
val pointTheme = SimplePointTheme(track_geopoints, false)
|
||||
val style = Paint()
|
||||
style.style = Paint.Style.FILL
|
||||
style.color = Keys.POLYLINE_COLOR
|
||||
style.color = requireContext().getColor(R.color.fuchsia)
|
||||
style.flags = Paint.ANTI_ALIAS_FLAG
|
||||
val overlayOptions: SimpleFastPointOverlayOptions = SimpleFastPointOverlayOptions.getDefaultStyle()
|
||||
.setAlgorithm(SimpleFastPointOverlayOptions.RenderingAlgorithm.MEDIUM_OPTIMIZATION)
|
||||
|
@ -369,7 +373,7 @@ class TrackFragment : Fragment(), MapListener, YesNoDialog.YesNoDialogListener
|
|||
{
|
||||
var pl = Polyline(mapView)
|
||||
pl.outlinePaint.strokeWidth = Keys.POLYLINE_THICKNESS
|
||||
pl.outlinePaint.color = Keys.POLYLINE_COLOR
|
||||
pl.outlinePaint.color = requireContext().getColor(R.color.fuchsia)
|
||||
pl.infoWindow = null
|
||||
track_segment_overlays.add(pl)
|
||||
mapView.overlays.add(pl)
|
|
@ -14,7 +14,11 @@
|
|||
* https://github.com/osmdroid/osmdroid
|
||||
*/
|
||||
|
||||
package org.y20k.trackbook
|
||||
/*
|
||||
* Modified by voussoir for trkpt, forked from Trackbook.
|
||||
*/
|
||||
|
||||
package net.voussoir.trkpt
|
||||
|
||||
import android.Manifest
|
||||
import android.app.Application
|
||||
|
@ -22,9 +26,9 @@ import android.content.pm.PackageManager
|
|||
import android.database.Cursor
|
||||
import android.util.Log
|
||||
import com.google.android.material.color.DynamicColors
|
||||
import org.y20k.trackbook.helpers.AppThemeHelper
|
||||
import org.y20k.trackbook.helpers.PreferencesHelper
|
||||
import org.y20k.trackbook.helpers.PreferencesHelper.initPreferences
|
||||
import net.voussoir.trkpt.helpers.AppThemeHelper
|
||||
import net.voussoir.trkpt.helpers.PreferencesHelper
|
||||
import net.voussoir.trkpt.helpers.PreferencesHelper.initPreferences
|
||||
import java.io.File
|
||||
|
||||
|
||||
|
@ -35,7 +39,7 @@ interface DatabaseChangedListener
|
|||
|
||||
class Trackbook : Application()
|
||||
{
|
||||
val database: Database = Database(this)
|
||||
val database: net.voussoir.trkpt.Database = net.voussoir.trkpt.Database(this)
|
||||
val homepoints: ArrayList<Homepoint> = ArrayList()
|
||||
val database_changed_listeners = ArrayList<DatabaseChangedListener>()
|
||||
|
|
@ -14,7 +14,11 @@
|
|||
* https://github.com/osmdroid/osmdroid
|
||||
*/
|
||||
|
||||
package org.y20k.trackbook
|
||||
/*
|
||||
* Modified by voussoir for trkpt, forked from Trackbook.
|
||||
*/
|
||||
|
||||
package net.voussoir.trkpt
|
||||
|
||||
import android.app.Notification
|
||||
import android.app.NotificationManager
|
||||
|
@ -32,52 +36,56 @@ import android.util.Log
|
|||
import androidx.core.content.ContextCompat
|
||||
import org.osmdroid.util.GeoPoint
|
||||
import java.util.*
|
||||
import org.y20k.trackbook.helpers.*
|
||||
import net.voussoir.trkpt.helpers.*
|
||||
|
||||
/*
|
||||
* TrackerService class
|
||||
*/
|
||||
class TrackerService: Service()
|
||||
{
|
||||
/* Main class variables */
|
||||
lateinit var trackbook: Trackbook
|
||||
|
||||
var trackingState: Int = Keys.STATE_TRACKING_STOPPED
|
||||
var gpsProviderActive: Boolean = false
|
||||
var networkProviderActive: Boolean = false
|
||||
var useImperial: Boolean = false
|
||||
var use_gps_location: Boolean = false
|
||||
var use_network_location: Boolean = false
|
||||
var omitRests: Boolean = true
|
||||
var device_id: String = random_device_id()
|
||||
var currentBestLocation: Location = getDefaultLocation()
|
||||
var last_location_time: Long = 0
|
||||
var lastCommit: Long = 0
|
||||
var location_min_time_ms: Long = 0
|
||||
private val RECENT_TRKPT_COUNT = 7200
|
||||
lateinit var recent_trkpts: Deque<Trkpt>
|
||||
lateinit var recent_displacement_locations: Deque<Location>
|
||||
var recent_trackpoints_for_mapview: MutableList<GeoPoint> = mutableListOf()
|
||||
var gpsLocationListenerRegistered: Boolean = false
|
||||
var networkLocationListenerRegistered: Boolean = false
|
||||
lateinit var recent_trackpoints_for_mapview: MutableList<GeoPoint>
|
||||
var bound: Boolean = false
|
||||
private val binder = LocalBinder()
|
||||
lateinit var trackbook: Trackbook
|
||||
private lateinit var locationManager: LocationManager
|
||||
|
||||
private lateinit var notificationManager: NotificationManager
|
||||
private lateinit var notificationHelper: NotificationHelper
|
||||
|
||||
private lateinit var locationManager: LocationManager
|
||||
private lateinit var gpsLocationListener: LocationListener
|
||||
private lateinit var networkLocationListener: LocationListener
|
||||
var use_gps_location: Boolean = false
|
||||
var use_network_location: Boolean = false
|
||||
var gpsProviderActive: Boolean = false
|
||||
var networkProviderActive: Boolean = false
|
||||
var gpsLocationListenerRegistered: Boolean = false
|
||||
var networkLocationListenerRegistered: Boolean = false
|
||||
|
||||
var mapfragment: MapFragment? = null
|
||||
|
||||
private fun addGpsLocationListener()
|
||||
{
|
||||
if (! use_gps_location)
|
||||
{
|
||||
Log.v("VOUSSOIR", "Skipping GPS listener.")
|
||||
Log.i("VOUSSOIR", "Skipping GPS listener.")
|
||||
return
|
||||
}
|
||||
|
||||
if (gpsLocationListenerRegistered)
|
||||
{
|
||||
Log.v("VOUSSOIR", "GPS location listener has already been added.")
|
||||
Log.i("VOUSSOIR", "GPS location listener has already been added.")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -102,20 +110,20 @@ class TrackerService: Service()
|
|||
gpsLocationListener,
|
||||
)
|
||||
gpsLocationListenerRegistered = true
|
||||
Log.v("VOUSSOIR", "Added GPS location listener.")
|
||||
Log.i("VOUSSOIR", "Added GPS location listener.")
|
||||
}
|
||||
|
||||
private fun addNetworkLocationListener()
|
||||
{
|
||||
if (! use_network_location)
|
||||
{
|
||||
Log.v("VOUSSOIR", "Skipping Network listener.")
|
||||
Log.i("VOUSSOIR", "Skipping Network listener.")
|
||||
return
|
||||
}
|
||||
|
||||
if (networkLocationListenerRegistered)
|
||||
{
|
||||
Log.v("VOUSSOIR", "Network location listener has already been added.")
|
||||
Log.i("VOUSSOIR", "Network location listener has already been added.")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -140,7 +148,7 @@ class TrackerService: Service()
|
|||
networkLocationListener,
|
||||
)
|
||||
networkLocationListenerRegistered = true
|
||||
Log.v("VOUSSOIR", "Added Network location listener.")
|
||||
Log.i("VOUSSOIR", "Added Network location listener.")
|
||||
}
|
||||
|
||||
private fun createLocationListener(): LocationListener
|
||||
|
@ -149,20 +157,23 @@ class TrackerService: Service()
|
|||
{
|
||||
override fun onLocationChanged(location: Location)
|
||||
{
|
||||
Log.i("VOUSSOIR", "Processing point ${location.latitude}, ${location.longitude} ${location.time}.")
|
||||
Log.i("VOUSSOIR", "Processing point ${location.time} ${location.latitude}, ${location.longitude}.")
|
||||
|
||||
if (! isBetterLocation(location, currentBestLocation))
|
||||
if (location.time == currentBestLocation.time)
|
||||
{
|
||||
Log.i("VOUSSOIR", "Not better than previous.")
|
||||
return
|
||||
}
|
||||
|
||||
// if (! isBetterLocation(location, currentBestLocation))
|
||||
// {
|
||||
// Log.i("VOUSSOIR", "Not better than previous.")
|
||||
// return
|
||||
// }
|
||||
|
||||
currentBestLocation = location
|
||||
|
||||
if (mapfragment != null)
|
||||
{
|
||||
mapfragment!!.handler.postDelayed(mapfragment!!.location_update_redraw, 0)
|
||||
}
|
||||
val mf = mapfragment
|
||||
mf?.handler?.postDelayed(mf.location_update_redraw, 0)
|
||||
|
||||
if (trackingState != Keys.STATE_TRACKING_ACTIVE)
|
||||
{
|
||||
|
@ -199,7 +210,11 @@ class TrackerService: Service()
|
|||
return
|
||||
}
|
||||
}
|
||||
if (! (recent_displacement_locations.isEmpty() || isDifferentEnough(recent_displacement_locations.first(), location, omitRests)))
|
||||
if (recent_displacement_locations.isEmpty())
|
||||
{
|
||||
// pass
|
||||
}
|
||||
else if (! isDifferentEnough(recent_displacement_locations.first(), location, omitRests))
|
||||
{
|
||||
Log.i("VOUSSOIR", "Omitting due to too close to previous.")
|
||||
return
|
||||
|
@ -207,6 +222,7 @@ class TrackerService: Service()
|
|||
|
||||
val trkpt = Trkpt(device_id=device_id, location=location)
|
||||
trackbook.database.insert_trkpt(trkpt)
|
||||
|
||||
recent_trkpts.add(trkpt)
|
||||
while (recent_trkpts.size > RECENT_TRKPT_COUNT)
|
||||
{
|
||||
|
@ -264,6 +280,7 @@ class TrackerService: Service()
|
|||
/* Overrides onBind from Service */
|
||||
override fun onBind(p0: Intent?): IBinder
|
||||
{
|
||||
Log.i("VOUSSOIR", "TrackerService.onBind")
|
||||
bound = true
|
||||
// start receiving location updates
|
||||
addGpsLocationListener()
|
||||
|
@ -276,6 +293,7 @@ class TrackerService: Service()
|
|||
override fun onCreate()
|
||||
{
|
||||
super.onCreate()
|
||||
Log.i("VOUSSOIR", "TrackerService.onCreate")
|
||||
trackbook = (applicationContext as Trackbook)
|
||||
trackbook.load_homepoints()
|
||||
recent_trkpts = ArrayDeque<Trkpt>(RECENT_TRKPT_COUNT)
|
||||
|
@ -317,6 +335,7 @@ class TrackerService: Service()
|
|||
/* Overrides onRebind from Service */
|
||||
override fun onRebind(intent: Intent?)
|
||||
{
|
||||
Log.i("VOUSSOIR", "TrackerService.onRebind")
|
||||
bound = true
|
||||
addGpsLocationListener()
|
||||
addNetworkLocationListener()
|
||||
|
@ -325,6 +344,7 @@ class TrackerService: Service()
|
|||
/* Overrides onStartCommand from Service */
|
||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int
|
||||
{
|
||||
Log.i("VOUSSOIR", "TrackerService.onStartCommand")
|
||||
// SERVICE RESTART (via START_STICKY)
|
||||
if (intent == null)
|
||||
{
|
||||
|
@ -350,6 +370,8 @@ class TrackerService: Service()
|
|||
/* Overrides onUnbind from Service */
|
||||
override fun onUnbind(intent: Intent?): Boolean
|
||||
{
|
||||
super.onUnbind(intent)
|
||||
Log.i("VOUSSOIR", "TrackerService.onUnbind")
|
||||
bound = false
|
||||
// stop receiving location updates - if not tracking
|
||||
if (trackingState != Keys.STATE_TRACKING_ACTIVE)
|
||||
|
@ -368,7 +390,7 @@ class TrackerService: Service()
|
|||
{
|
||||
locationManager.removeUpdates(gpsLocationListener)
|
||||
gpsLocationListenerRegistered = false
|
||||
Log.v("VOUSSOIR", "Removed GPS location listener.")
|
||||
Log.i("VOUSSOIR", "Removed GPS location listener.")
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -382,7 +404,7 @@ class TrackerService: Service()
|
|||
{
|
||||
locationManager.removeUpdates(networkLocationListener)
|
||||
networkLocationListenerRegistered = false
|
||||
Log.v("VOUSSOIR", "Removed Network location listener.")
|
||||
Log.i("VOUSSOIR", "Removed Network location listener.")
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -392,6 +414,7 @@ class TrackerService: Service()
|
|||
|
||||
fun startTracking()
|
||||
{
|
||||
Log.i("VOUSSOIR", "TrackerService.startTracking")
|
||||
addGpsLocationListener()
|
||||
addNetworkLocationListener()
|
||||
trackingState = Keys.STATE_TRACKING_ACTIVE
|
||||
|
@ -402,6 +425,7 @@ class TrackerService: Service()
|
|||
|
||||
fun stopTracking()
|
||||
{
|
||||
Log.i("VOUSSOIR", "TrackerService.stopTracking")
|
||||
trackbook.database.commit()
|
||||
|
||||
trackingState = Keys.STATE_TRACKING_STOPPED
|
|
@ -14,7 +14,11 @@
|
|||
* https://github.com/osmdroid/osmdroid
|
||||
*/
|
||||
|
||||
package org.y20k.trackbook
|
||||
/*
|
||||
* Modified by voussoir for trkpt, forked from Trackbook.
|
||||
*/
|
||||
|
||||
package net.voussoir.trkpt
|
||||
|
||||
import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
|
@ -22,7 +26,7 @@ import android.graphics.drawable.Icon
|
|||
import android.os.Build
|
||||
import android.service.quicksettings.Tile
|
||||
import android.service.quicksettings.TileService
|
||||
import org.y20k.trackbook.helpers.PreferencesHelper
|
||||
import net.voussoir.trkpt.helpers.PreferencesHelper
|
||||
|
||||
/*
|
||||
* TrackingToggleTileService class
|
|
@ -14,7 +14,11 @@
|
|||
* https://github.com/osmdroid/osmdroid
|
||||
*/
|
||||
|
||||
package org.y20k.trackbook
|
||||
/*
|
||||
* Modified by voussoir for trkpt, forked from Trackbook.
|
||||
*/
|
||||
|
||||
package net.voussoir.trkpt
|
||||
|
||||
import YesNoDialog
|
||||
import android.content.Context
|
||||
|
@ -27,14 +31,12 @@ import androidx.core.os.bundleOf
|
|||
import androidx.fragment.app.Fragment
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.recyclerview.widget.DefaultItemAnimator
|
||||
import androidx.recyclerview.widget.ItemTouchHelper
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.Dispatchers.Main
|
||||
import org.y20k.trackbook.helpers.UiHelper
|
||||
import org.y20k.trackbook.helpers.iso8601
|
||||
import org.y20k.trackbook.tracklist.TracklistAdapter
|
||||
import net.voussoir.trkpt.helpers.iso8601
|
||||
import net.voussoir.trkpt.tracklist.TracklistAdapter
|
||||
|
||||
/*
|
||||
* TracklistFragment class
|
|
@ -14,13 +14,12 @@
|
|||
* https://github.com/osmdroid/osmdroid
|
||||
*/
|
||||
|
||||
package org.y20k.trackbook
|
||||
package net.voussoir.trkpt
|
||||
|
||||
import android.location.Location
|
||||
import org.osmdroid.api.IGeoPoint
|
||||
import org.osmdroid.util.GeoPoint
|
||||
import org.osmdroid.views.overlay.Polyline
|
||||
import org.y20k.trackbook.helpers.getNumberOfSatellites
|
||||
import net.voussoir.trkpt.helpers.getNumberOfSatellites
|
||||
|
||||
class Trkpt(
|
||||
val device_id: String,
|
||||
|
@ -54,4 +53,4 @@ class Trkpt(
|
|||
location.time = this.time
|
||||
return location
|
||||
}
|
||||
}
|
||||
}
|
|
@ -14,7 +14,7 @@
|
|||
* https://github.com/osmdroid/osmdroid
|
||||
*/
|
||||
|
||||
package org.y20k.trackbook.dialogs
|
||||
package net.voussoir.trkpt.dialogs
|
||||
|
||||
import android.content.Context
|
||||
import android.content.DialogInterface
|
||||
|
@ -25,7 +25,7 @@ import android.widget.TextView
|
|||
import androidx.core.view.isGone
|
||||
import androidx.core.view.isVisible
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import org.y20k.trackbook.R
|
||||
import net.voussoir.trkpt.R
|
||||
|
||||
/*
|
||||
* ErrorDialog object
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* YesNoDialog
|
||||
* Implements the YesNoDialog class
|
||||
* A YesNoDialog asks the user if he/she wants to do something or notpackage org.y20k.trackbook.dialogs
|
||||
* A YesNoDialog asks the user if he/she wants to do something or not
|
||||
*
|
||||
* This file is part of
|
||||
* TRACKBOOK - Movement Recorder for Android
|
||||
|
@ -16,8 +16,8 @@
|
|||
|
||||
import android.content.Context
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import org.y20k.trackbook.Keys
|
||||
import org.y20k.trackbook.R
|
||||
import net.voussoir.trkpt.Keys
|
||||
import net.voussoir.trkpt.R
|
||||
|
||||
/*
|
||||
* YesNoDialog class
|
|
@ -14,7 +14,7 @@
|
|||
* https://github.com/osmdroid/osmdroid
|
||||
*/
|
||||
|
||||
package org.y20k.trackbook.extensions
|
||||
package net.voussoir.trkpt.extensions
|
||||
|
||||
import android.content.SharedPreferences
|
||||
|
|
@ -1,19 +1,9 @@
|
|||
package org.y20k.trackbook.helpers
|
||||
package net.voussoir.trkpt.helpers
|
||||
|
||||
import android.annotation.TargetApi
|
||||
import android.content.ContentUris
|
||||
import android.content.Context
|
||||
import android.database.Cursor
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Environment
|
||||
import android.provider.DocumentsContract
|
||||
import android.provider.MediaStore
|
||||
import java.lang.Math.abs
|
||||
import java.security.SecureRandom
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
import kotlin.random.Random.Default.nextBits
|
||||
|
||||
private val RNG = SecureRandom()
|
||||
|
|
@ -14,14 +14,14 @@
|
|||
* https://github.com/osmdroid/osmdroid
|
||||
*/
|
||||
|
||||
package org.y20k.trackbook.helpers
|
||||
package net.voussoir.trkpt.helpers
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.Configuration
|
||||
import android.util.Log
|
||||
import androidx.appcompat.app.AppCompatDelegate
|
||||
import org.y20k.trackbook.Keys
|
||||
import org.y20k.trackbook.R
|
||||
import net.voussoir.trkpt.Keys
|
||||
import net.voussoir.trkpt.R
|
||||
|
||||
/*
|
||||
* AppThemeHelper object
|
|
@ -14,14 +14,12 @@
|
|||
* https://github.com/osmdroid/osmdroid
|
||||
*/
|
||||
|
||||
package org.y20k.trackbook.helpers
|
||||
package net.voussoir.trkpt.helpers
|
||||
|
||||
import android.content.Context
|
||||
import android.location.Location
|
||||
import org.y20k.trackbook.Keys
|
||||
import org.y20k.trackbook.R
|
||||
import net.voussoir.trkpt.Keys
|
||||
import net.voussoir.trkpt.R
|
||||
import java.text.DateFormat
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* https://github.com/osmdroid/osmdroid
|
||||
*/
|
||||
|
||||
package org.y20k.trackbook.helpers
|
||||
package net.voussoir.trkpt.helpers
|
||||
|
||||
import java.math.BigDecimal
|
||||
import java.math.RoundingMode
|
|
@ -14,7 +14,7 @@
|
|||
* https://github.com/osmdroid/osmdroid
|
||||
*/
|
||||
|
||||
package org.y20k.trackbook.helpers
|
||||
package net.voussoir.trkpt.helpers
|
||||
|
||||
import android.Manifest
|
||||
import android.content.Context
|
||||
|
@ -24,7 +24,7 @@ import android.location.LocationManager
|
|||
import android.os.Bundle
|
||||
import android.os.SystemClock
|
||||
import androidx.core.content.ContextCompat
|
||||
import org.y20k.trackbook.Keys
|
||||
import net.voussoir.trkpt.Keys
|
||||
import kotlin.math.pow
|
||||
|
||||
/* Get default location */
|
|
@ -14,7 +14,7 @@
|
|||
* https://github.com/osmdroid/osmdroid
|
||||
*/
|
||||
|
||||
package org.y20k.trackbook.helpers
|
||||
package net.voussoir.trkpt.helpers
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
|
@ -24,8 +24,8 @@ import org.osmdroid.util.GeoPoint
|
|||
import org.osmdroid.views.MapView
|
||||
import org.osmdroid.views.overlay.ItemizedIconOverlay
|
||||
import org.osmdroid.views.overlay.OverlayItem
|
||||
import org.y20k.trackbook.R
|
||||
import org.y20k.trackbook.Trkpt
|
||||
import net.voussoir.trkpt.R
|
||||
import net.voussoir.trkpt.Trkpt
|
||||
import java.text.DecimalFormat
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
|
@ -14,7 +14,7 @@
|
|||
* https://github.com/osmdroid/osmdroid
|
||||
*/
|
||||
|
||||
package org.y20k.trackbook.helpers
|
||||
package net.voussoir.trkpt.helpers
|
||||
|
||||
import android.app.*
|
||||
import android.content.Context
|
||||
|
@ -24,10 +24,10 @@ import androidx.annotation.RequiresApi
|
|||
import androidx.appcompat.content.res.AppCompatResources
|
||||
import androidx.core.app.NotificationCompat
|
||||
import androidx.core.graphics.drawable.toBitmap
|
||||
import org.y20k.trackbook.Keys
|
||||
import org.y20k.trackbook.MainActivity
|
||||
import org.y20k.trackbook.R
|
||||
import org.y20k.trackbook.TrackerService
|
||||
import net.voussoir.trkpt.Keys
|
||||
import net.voussoir.trkpt.MainActivity
|
||||
import net.voussoir.trkpt.R
|
||||
import net.voussoir.trkpt.TrackerService
|
||||
|
||||
/*
|
||||
* NotificationHelper class
|
||||
|
@ -40,8 +40,8 @@ class NotificationHelper(private val trackerService: TrackerService)
|
|||
/* Creates notification */
|
||||
fun createNotification(trackingState: Int, timestamp: String): Notification {
|
||||
|
||||
// create notification channel if necessary
|
||||
if (shouldCreateNotificationChannel()) {
|
||||
if (shouldCreateNotificationChannel())
|
||||
{
|
||||
createNotificationChannel()
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,6 @@ class NotificationHelper(private val trackerService: TrackerService)
|
|||
}
|
||||
|
||||
return builder.build()
|
||||
|
||||
}
|
||||
|
||||
/* Checks if notification channel should be created */
|
|
@ -14,7 +14,7 @@
|
|||
* https://github.com/osmdroid/osmdroid
|
||||
*/
|
||||
|
||||
package org.y20k.trackbook.helpers
|
||||
package net.voussoir.trkpt.helpers
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
|
@ -23,9 +23,9 @@ import android.location.LocationManager
|
|||
import android.util.Log
|
||||
import androidx.core.content.edit
|
||||
import androidx.preference.PreferenceManager
|
||||
import org.y20k.trackbook.Keys
|
||||
import org.y20k.trackbook.extensions.getDouble
|
||||
import org.y20k.trackbook.extensions.putDouble
|
||||
import net.voussoir.trkpt.Keys
|
||||
import net.voussoir.trkpt.extensions.getDouble
|
||||
import net.voussoir.trkpt.extensions.putDouble
|
||||
|
||||
/*
|
||||
* PreferencesHelper object
|
||||
|
@ -75,10 +75,13 @@ object PreferencesHelper
|
|||
}
|
||||
|
||||
fun loadTrackingState(): Int {
|
||||
return sharedPreferences.getInt(Keys.PREF_TRACKING_STATE, Keys.STATE_TRACKING_STOPPED)
|
||||
val state = sharedPreferences.getInt(Keys.PREF_TRACKING_STATE, Keys.STATE_TRACKING_STOPPED)
|
||||
Log.i("VOUSSOIR", "PreferencesHelper.loadTrackingState ${state}")
|
||||
return state
|
||||
}
|
||||
|
||||
fun saveTrackingState(trackingState: Int) {
|
||||
Log.i("VOUSSOIR", "PreferencesHelper.saveTrackingState ${trackingState}")
|
||||
sharedPreferences.edit { putInt(Keys.PREF_TRACKING_STATE, trackingState) }
|
||||
}
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* https://github.com/osmdroid/osmdroid
|
||||
*/
|
||||
|
||||
package org.y20k.trackbook.helpers
|
||||
package net.voussoir.trkpt.helpers
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Canvas
|
||||
|
@ -22,13 +22,10 @@ import android.graphics.Paint
|
|||
import android.graphics.PorterDuff
|
||||
import android.graphics.PorterDuffXfermode
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.recyclerview.widget.ItemTouchHelper
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import org.y20k.trackbook.R
|
||||
import org.y20k.trackbook.tracklist.TracklistAdapter
|
||||
import net.voussoir.trkpt.R
|
||||
|
||||
/*
|
||||
* UiHelper object
|
|
@ -14,7 +14,7 @@
|
|||
* https://github.com/osmdroid/osmdroid
|
||||
*/
|
||||
|
||||
package org.y20k.trackbook.tracklist
|
||||
package net.voussoir.trkpt.tracklist
|
||||
|
||||
import android.content.Context
|
||||
import android.database.Cursor
|
||||
|
@ -26,15 +26,15 @@ import android.widget.TextView
|
|||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import org.y20k.trackbook.Keys
|
||||
import org.y20k.trackbook.R
|
||||
import org.y20k.trackbook.Database
|
||||
import org.y20k.trackbook.Track
|
||||
import net.voussoir.trkpt.Keys
|
||||
import net.voussoir.trkpt.R
|
||||
import net.voussoir.trkpt.Database
|
||||
import net.voussoir.trkpt.Track
|
||||
import java.text.DateFormat
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
||||
class TracklistAdapter(val fragment: Fragment, val database: Database) : RecyclerView.Adapter<RecyclerView.ViewHolder>()
|
||||
class TracklistAdapter(val fragment: Fragment, val database: net.voussoir.trkpt.Database) : RecyclerView.Adapter<RecyclerView.ViewHolder>()
|
||||
{
|
||||
private lateinit var tracklistListener: TracklistAdapterListener
|
||||
val tracks: ArrayList<Track> = ArrayList<Track>()
|
|
@ -8,7 +8,7 @@
|
|||
<!-- MAP -->
|
||||
<fragment
|
||||
android:id="@+id/map_fragment"
|
||||
android:name="org.y20k.trackbook.MapFragment"
|
||||
android:name="net.voussoir.trkpt.MapFragment"
|
||||
android:label="Map"
|
||||
tools:layout="@layout/fragment_map">
|
||||
<action
|
||||
|
@ -22,13 +22,13 @@
|
|||
<!-- SETTINGS -->
|
||||
<fragment
|
||||
android:id="@+id/settings_fragment"
|
||||
android:name="org.y20k.trackbook.SettingsFragment"
|
||||
android:name="net.voussoir.trkpt.SettingsFragment"
|
||||
android:label="Settings"/>
|
||||
|
||||
<!-- TRACKS (LIST OF TRACKS) -->
|
||||
<fragment
|
||||
android:id="@+id/tracklist_fragment"
|
||||
android:name="org.y20k.trackbook.TracklistFragment"
|
||||
android:name="net.voussoir.trkpt.TracklistFragment"
|
||||
android:label="Tracks"
|
||||
tools:layout="@layout/fragment_tracklist">
|
||||
<action
|
||||
|
@ -40,7 +40,7 @@
|
|||
<!-- TRACK -->
|
||||
<fragment
|
||||
android:id="@+id/fragment_track"
|
||||
android:name="org.y20k.trackbook.TrackFragment"
|
||||
android:name="net.voussoir.trkpt.TrackFragment"
|
||||
android:label="Track"
|
||||
tools:layout="@layout/fragment_track" >
|
||||
<argument
|
||||
|
|
|
@ -49,5 +49,6 @@
|
|||
<color name="default_blue">#FF3C98DB</color>
|
||||
<color name="homepoint">#FFFFC107</color>
|
||||
<color name="default_green">#FF4CAF50</color>
|
||||
<color name="fuchsia">#FFFF00FF</color>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
<string name="tab_tracks">History</string>
|
||||
<string name="tab_settings">Settings</string>
|
||||
<!-- Notification -->
|
||||
<string name="notification_title_trackbook_running">Trackbook running</string>
|
||||
<string name="notification_title_trackbook_not_running">Trackbook stopped</string>
|
||||
<string name="notification_title_trackbook_running">Recording</string>
|
||||
<string name="notification_title_trackbook_not_running">Stopped</string>
|
||||
<string name="notification_pause">Stop</string>
|
||||
<string name="notification_resume">Record</string>
|
||||
<string name="notification_show">Show</string>
|
||||
|
|
Loading…
Reference in a new issue