checkpoint

This commit is contained in:
voussoir 2023-03-14 16:45:15 -07:00
parent 71d94c8fcc
commit 8f5852d157
31 changed files with 140 additions and 252 deletions

View file

@ -14,6 +14,7 @@
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
<!-- DANGEROUS PERMISSIONS, must request -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

View file

@ -53,9 +53,9 @@ object Keys {
const val PREF_MAP_ZOOM_LEVEL: String = "prefMapZoomLevel"
const val PREF_TRACKING_STATE: String = "prefTrackingState"
const val PREF_USE_IMPERIAL_UNITS: String = "prefUseImperialUnits"
const val PREF_GPS_ONLY: String = "prefGpsOnly"
const val PREF_LOCATION_NETWORK: String = "prefLocationNetwork"
const val PREF_LOCATION_GPS: String = "prefLocationGPS"
const val PREF_OMIT_RESTS: String = "prefOmitRests"
const val PREF_COMMIT_INTERVAL: String = "prefCommitInterval"
const val PREF_DEVICE_ID: String = "prefDeviceID"
const val PREF_DATABASE_DIRECTORY: String = "prefDatabaseDirectory"

View file

@ -18,12 +18,16 @@ package org.y20k.trackbook
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
@ -152,7 +156,7 @@ class MainActivity: AppCompatActivity()
override fun onRequestPermissionsResult(
requestCode: Int,
permissions: Array<out String>,
grantResults: IntArray
grantResults: IntArray,
)
{
super.onRequestPermissionsResult(requestCode, permissions, grantResults)

View file

@ -309,51 +309,24 @@ class MapFragment : Fragment()
}
private val requestLocationPermissionLauncher = registerForActivityResult(RequestPermission()) { isGranted: Boolean ->
if (isGranted) {
if (isGranted)
{
// permission was granted - re-bind service
activity?.unbindService(connection)
activity?.bindService(Intent(activity, TrackerService::class.java), connection, Context.BIND_AUTO_CREATE)
LogHelper.i(TAG, "Request result: Location permission has been granted.")
} else {
}
else
{
// permission denied - unbind service
activity?.unbindService(connection)
}
toggleLocationErrorBar(gpsProviderActive, networkProviderActive)
}
/* Register the permission launcher for starting the tracking service */
private val startTrackingPermissionLauncher = registerForActivityResult(RequestPermission()) { isGranted: Boolean ->
if (isGranted)
{
LogHelper.i(TAG, "Request result: Activity Recognition permission has been granted.")
}
else
{
LogHelper.i(TAG, "Request result: Activity Recognition permission has NOT been granted.")
}
// start service via intent so that it keeps running after unbind
startTrackerService()
trackerService.startTracking()
}
/* Start recording waypoints */
private fun startTracking() {
// request activity recognition permission on Android Q+ if denied
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && ContextCompat.checkSelfPermission(activity as Context, Manifest.permission.ACTIVITY_RECOGNITION) == PackageManager.PERMISSION_DENIED)
{
startTrackingPermissionLauncher.launch(Manifest.permission.ACTIVITY_RECOGNITION)
}
else
{
// start service via intent so that it keeps running after unbind
startTrackerService()
trackerService.startTracking()
}
}
/* Start tracker service */
private fun startTrackerService()
{
val intent = Intent(activity, TrackerService::class.java)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// ... start service in foreground to prevent it being killed on Oreo
@ -361,8 +334,10 @@ class MapFragment : Fragment()
} else {
activity?.startService(intent)
}
trackerService.startTracking()
}
/* Handles state when service is being unbound */
private fun handleServiceUnbind()
{
@ -377,7 +352,7 @@ class MapFragment : Fragment()
private fun handleTrackingManagementMenu()
{
when (trackingState) {
Keys.STATE_TRACKING_ACTIVE -> trackerService.pauseTracking()
Keys.STATE_TRACKING_ACTIVE -> trackerService.stopTracking()
Keys.STATE_TRACKING_STOPPED -> startTracking()
}
}
@ -390,11 +365,11 @@ class MapFragment : Fragment()
if (activity != null)
{
trackingState = PreferencesHelper.loadTrackingState()
}
}
}
update_main_button()
}
}
}
}
fun centerMap(location: Location, animated: Boolean = false) {
val position = GeoPoint(location.latitude, location.longitude)
@ -598,16 +573,22 @@ class MapFragment : Fragment()
}
}
fun toggleLocationErrorBar(gpsProviderActive: Boolean, networkProviderActive: Boolean) {
if (ContextCompat.checkSelfPermission(requireContext(), Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_DENIED) {
fun toggleLocationErrorBar(gpsProviderActive: Boolean, networkProviderActive: Boolean)
{
if (ContextCompat.checkSelfPermission(requireContext(), Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_DENIED)
{
// CASE: Location permission not granted
locationErrorBar.setText(R.string.snackbar_message_location_permission_denied)
if (!locationErrorBar.isShown) locationErrorBar.show()
} else if (!gpsProviderActive && !networkProviderActive) {
}
else if (!gpsProviderActive && !networkProviderActive)
{
// CASE: Location setting is off
locationErrorBar.setText(R.string.snackbar_message_location_offline)
if (!locationErrorBar.isShown) locationErrorBar.show()
} else {
}
else
{
if (locationErrorBar.isShown) locationErrorBar.dismiss()
}
}

View file

@ -25,9 +25,12 @@ import android.content.Intent
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.os.PowerManager
import android.provider.DocumentsContract
import android.provider.Settings
import android.util.Log
import android.view.View
import android.widget.Button
import android.widget.Toast
import androidx.activity.result.contract.ActivityResultContracts
import androidx.preference.EditTextPreference
@ -71,17 +74,27 @@ class SettingsFragment : PreferenceFragmentCompat(), YesNoDialog.YesNoDialogList
preferenceCategoryGeneral.title = getString(R.string.pref_general_title)
screen.addPreference(preferenceCategoryGeneral)
// set up "Restrict to GPS" preference
val preferenceGpsOnly = SwitchPreferenceCompat(activity as Context)
preferenceGpsOnly.isSingleLineTitle = false
preferenceGpsOnly.title = getString(R.string.pref_gps_only_title)
preferenceGpsOnly.setIcon(R.drawable.ic_gps_24dp)
preferenceGpsOnly.key = Keys.PREF_GPS_ONLY
preferenceGpsOnly.summaryOn = getString(R.string.pref_gps_only_summary_gps_only)
preferenceGpsOnly.summaryOff = getString(R.string.pref_gps_only_summary_gps_and_network)
preferenceGpsOnly.setDefaultValue(false)
preferenceCategoryGeneral.contains(preferenceGpsOnly)
screen.addPreference(preferenceGpsOnly)
val prefLocationGPS = SwitchPreferenceCompat(activity as Context)
prefLocationGPS.isSingleLineTitle = false
prefLocationGPS.title = getString(R.string.pref_location_gps_title)
prefLocationGPS.setIcon(R.drawable.ic_gps_24dp)
prefLocationGPS.key = Keys.PREF_LOCATION_GPS
prefLocationGPS.summaryOn = getString(R.string.pref_location_gps_summary_on)
prefLocationGPS.summaryOff = getString(R.string.pref_location_gps_summary_off)
prefLocationGPS.setDefaultValue(true)
preferenceCategoryGeneral.contains(prefLocationGPS)
screen.addPreference(prefLocationGPS)
val prefLocationNetwork = SwitchPreferenceCompat(activity as Context)
prefLocationNetwork.isSingleLineTitle = false
prefLocationNetwork.title = getString(R.string.pref_location_network_title)
prefLocationNetwork.setIcon(R.drawable.ic_gps_24dp)
prefLocationNetwork.key = Keys.PREF_LOCATION_NETWORK
prefLocationNetwork.summaryOn = getString(R.string.pref_location_network_summary_on)
prefLocationNetwork.summaryOff = getString(R.string.pref_location_network_summary_off)
prefLocationNetwork.setDefaultValue(false)
preferenceCategoryGeneral.contains(prefLocationNetwork)
screen.addPreference(prefLocationNetwork)
// set up "Use Imperial Measurements" preference
val preferenceImperialMeasurementUnits = SwitchPreferenceCompat(activity as Context)
@ -114,7 +127,6 @@ class SettingsFragment : PreferenceFragmentCompat(), YesNoDialog.YesNoDialogList
}
screen.addPreference(preferenceThemeSelection)
// set up "Recording Accuracy" preference
val preferenceOmitRests = SwitchPreferenceCompat(activity as Context)
preferenceOmitRests.isSingleLineTitle = false
preferenceOmitRests.title = getString(R.string.pref_omit_rests_title)
@ -178,10 +190,26 @@ class SettingsFragment : PreferenceFragmentCompat(), YesNoDialog.YesNoDialogList
preferenceDatabaseFolder.summary = getString(R.string.pref_database_folder_summary) + "\n" + newValue
return@setOnPreferenceChangeListener true
}
preferenceCategoryGeneral.contains(preferenceDatabaseFolder)
screen.addPreference(preferenceDatabaseFolder)
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1)
{
if (!context.getSystemService(PowerManager::class.java).isIgnoringBatteryOptimizations(context.packageName))
{
val battery_optimization_button = Preference(context)
battery_optimization_button.title = "Disable battery optimization"
battery_optimization_button.summary = "If your device kills the app, you can give this a try"
battery_optimization_button.setOnPreferenceClickListener {
val i: Intent = Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS).setData(Uri.parse("package:${context.packageName}"))
context.startActivity(i)
return@setOnPreferenceClickListener true
}
preferenceCategoryGeneral.contains(battery_optimization_button)
screen.addPreference(battery_optimization_button)
}
}
val preferenceCategoryAbout = PreferenceCategory(context)
preferenceCategoryAbout.title = getString(R.string.pref_about_title)
screen.addPreference(preferenceCategoryAbout)

View file

@ -37,7 +37,6 @@ data class Track (
var view_latitude: Double = Keys.DEFAULT_LATITUDE,
var view_longitude: Double = Keys.DEFAULT_LONGITUDE,
var trackFormatVersion: Int = Keys.CURRENT_TRACK_FORMAT_VERSION,
var zoomLevel: Double = Keys.DEFAULT_ZOOM_LEVEL,
)
{
fun delete()

View file

@ -23,10 +23,6 @@ import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.content.SharedPreferences
import android.hardware.Sensor
import android.hardware.SensorEvent
import android.hardware.SensorEventListener
import android.hardware.SensorManager
import android.location.Location
import android.location.LocationListener
import android.location.LocationManager
@ -35,13 +31,12 @@ import android.os.*
import android.util.Log
import androidx.core.content.ContextCompat
import java.util.*
import kotlinx.coroutines.Runnable
import org.y20k.trackbook.helpers.*
/*
* TrackerService class
*/
class TrackerService: Service(), SensorEventListener
class TrackerService: Service()
{
/* Define log tag */
private val TAG: String = LogHelper.makeLogTag(TrackerService::class.java)
@ -51,25 +46,22 @@ class TrackerService: Service(), SensorEventListener
var gpsProviderActive: Boolean = false
var networkProviderActive: Boolean = false
var useImperial: Boolean = false
var gpsOnly: 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 recording_started: Date = GregorianCalendar.getInstance().time
var commitInterval: Int = Keys.COMMIT_INTERVAL
var currentBestLocation: Location = getDefaultLocation()
var lastCommit: Long = 0
var location_min_time_ms: Long = 0
private val RECENT_TRKPT_COUNT = 7200
var stepCountOffset: Float = 0f
lateinit var recent_trkpts: Deque<Trkpt>
lateinit var recent_displacement_trkpts: Deque<Trkpt>
var gpsLocationListenerRegistered: Boolean = false
var networkLocationListenerRegistered: Boolean = false
var bound: Boolean = false
private val binder = LocalBinder()
private val handler: Handler = Handler(Looper.getMainLooper())
lateinit var trackbook: Trackbook
private lateinit var locationManager: LocationManager
private lateinit var sensorManager: SensorManager
private lateinit var notificationManager: NotificationManager
private lateinit var notificationHelper: NotificationHelper
private lateinit var gpsLocationListener: LocationListener
@ -77,6 +69,12 @@ class TrackerService: Service(), SensorEventListener
private fun addGpsLocationListener()
{
if (! use_gps_location)
{
LogHelper.v(TAG, "Skipping GPS listener.")
return
}
if (gpsLocationListenerRegistered)
{
LogHelper.v(TAG, "GPS location listener has already been added.")
@ -109,9 +107,9 @@ class TrackerService: Service(), SensorEventListener
private fun addNetworkLocationListener()
{
if (gpsOnly)
if (! use_network_location)
{
LogHelper.v(TAG, "Skipping Network listener. User prefers GPS-only.")
LogHelper.v(TAG, "Skipping Network listener.")
return
}
@ -167,13 +165,18 @@ class TrackerService: Service(), SensorEventListener
val trkpt = Trkpt(location=location)
trackbook.database.insert_trkpt(device_id, trkpt)
recent_trkpts.add(trkpt)
while (recent_trkpts.size > RECENT_TRKPT_COUNT)
{
recent_trkpts.removeFirst()
}
if (now - lastCommit > Keys.SAVE_TEMP_TRACK_INTERVAL)
recent_displacement_trkpts.add(trkpt)
while (recent_displacement_trkpts.size > 5)
{
recent_displacement_trkpts.removeFirst()
}
if (now - lastCommit > Keys.COMMIT_INTERVAL)
{
trackbook.database.commit()
lastCommit = now
@ -211,12 +214,6 @@ class TrackerService: Service(), SensorEventListener
return notification
}
/* Overrides onAccuracyChanged from SensorEventListener */
override fun onAccuracyChanged(sensor: Sensor?, accuracy: Int)
{
LogHelper.v(TAG, "Accuracy changed: $accuracy")
}
/* Overrides onBind from Service */
override fun onBind(p0: Intent?): IBinder
{
@ -235,13 +232,13 @@ class TrackerService: Service(), SensorEventListener
trackbook = (applicationContext as Trackbook)
trackbook.load_homepoints()
recent_trkpts = ArrayDeque<Trkpt>(RECENT_TRKPT_COUNT)
gpsOnly = PreferencesHelper.loadGpsOnly()
recent_displacement_trkpts = ArrayDeque<Trkpt>(5)
use_gps_location = PreferencesHelper.load_location_gps()
use_network_location = PreferencesHelper.load_location_network()
device_id = PreferencesHelper.load_device_id()
useImperial = PreferencesHelper.loadUseImperialUnits()
omitRests = PreferencesHelper.loadOmitRests()
commitInterval = PreferencesHelper.loadCommitInterval()
locationManager = getSystemService(Context.LOCATION_SERVICE) as LocationManager
sensorManager = this.getSystemService(Context.SENSOR_SERVICE) as SensorManager
notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
notificationHelper = NotificationHelper(this)
gpsProviderActive = isGpsEnabled(locationManager)
@ -260,7 +257,7 @@ class TrackerService: Service(), SensorEventListener
super.onDestroy()
if (trackingState == Keys.STATE_TRACKING_ACTIVE)
{
pauseTracking()
stopTracking()
}
stopForeground(STOP_FOREGROUND_REMOVE)
notificationManager.cancel(Keys.TRACKER_SERVICE_NOTIFICATION_ID) // this call was not necessary prior to Android 12
@ -277,21 +274,6 @@ class TrackerService: Service(), SensorEventListener
addNetworkLocationListener()
}
/* Overrides onSensorChanged from SensorEventListener */
override fun onSensorChanged(sensorEvent: SensorEvent?) {
var steps = 0f
if (sensorEvent != null)
{
if (stepCountOffset == 0f)
{
// store steps previously recorded by the system
stepCountOffset = (sensorEvent.values[0] - 1) - 0 // subtract any steps recorded during this session in case the app was killed
}
// calculate step count - subtract steps previously recorded
steps = sensorEvent.values[0] - stepCountOffset
}
}
/* Overrides onStartCommand from Service */
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int
{
@ -306,7 +288,7 @@ class TrackerService: Service(), SensorEventListener
}
else if (intent.action == Keys.ACTION_STOP)
{
pauseTracking()
stopTracking()
}
else if (intent.action == Keys.ACTION_START)
{
@ -360,38 +342,23 @@ class TrackerService: Service(), SensorEventListener
}
}
private fun startStepCounter()
{
val stepCounterAvailable = sensorManager.registerListener(this, sensorManager.getDefaultSensor(Sensor.TYPE_STEP_COUNTER), SensorManager.SENSOR_DELAY_UI)
if (!stepCounterAvailable)
{
LogHelper.w(TAG, "Pedometer sensor not available.")
}
}
fun startTracking(newTrack: Boolean = true)
fun startTracking()
{
addGpsLocationListener()
addNetworkLocationListener()
trackingState = Keys.STATE_TRACKING_ACTIVE
if (newTrack)
{
this.recording_started = GregorianCalendar.getInstance().time
}
PreferencesHelper.saveTrackingState(trackingState)
startStepCounter()
recent_displacement_trkpts.clear()
startForeground(Keys.TRACKER_SERVICE_NOTIFICATION_ID, displayNotification())
}
fun pauseTracking()
fun stopTracking()
{
trackbook.database.commit()
trackingState = Keys.STATE_TRACKING_STOPPED
PreferencesHelper.saveTrackingState(trackingState)
sensorManager.unregisterListener(this)
recent_displacement_trkpts.clear()
displayNotification()
stopForeground(STOP_FOREGROUND_DETACH)
}
@ -399,13 +366,28 @@ class TrackerService: Service(), SensorEventListener
private val sharedPreferenceChangeListener = SharedPreferences.OnSharedPreferenceChangeListener { sharedPreferences, key ->
when (key)
{
Keys.PREF_GPS_ONLY ->
Keys.PREF_LOCATION_GPS ->
{
gpsOnly = PreferencesHelper.loadGpsOnly()
when (gpsOnly)
use_gps_location = PreferencesHelper.load_location_gps()
if (use_gps_location)
{
true -> removeNetworkLocationListener()
false -> addNetworkLocationListener()
addGpsLocationListener()
}
else
{
removeGpsLocationListener()
}
}
Keys.PREF_LOCATION_NETWORK ->
{
use_network_location = PreferencesHelper.load_location_network()
if (use_network_location)
{
addNetworkLocationListener()
}
else
{
removeNetworkLocationListener()
}
}
Keys.PREF_USE_IMPERIAL_UNITS ->
@ -466,11 +448,11 @@ class TrackerService: Service(), SensorEventListener
return false
}
}
if (recent_trkpts.isEmpty())
if (recent_displacement_trkpts.isEmpty())
{
return true
}
if (! isDifferentEnough(recent_trkpts.last().toLocation(), location, omitRests))
if (! isDifferentEnough(recent_displacement_trkpts.first().toLocation(), location, omitRests))
{
Log.i("VOUSSOIR", "Omitting due to too close to previous.")
return false

View file

@ -22,7 +22,6 @@ import android.graphics.drawable.Icon
import android.os.Build
import android.service.quicksettings.Tile
import android.service.quicksettings.TileService
import org.y20k.trackbook.helpers.LogHelper
import org.y20k.trackbook.helpers.PreferencesHelper
/*

View file

@ -79,17 +79,6 @@ object DateTimeHelper {
return timeString
}
/* Create sortable string for date - used for filenames */
fun convertToSortableDateString(date: Date): String {
val dateFormat: SimpleDateFormat = SimpleDateFormat("yyyy-MM-dd-HH-mm-ss", Locale.US)
return dateFormat.format(date)
}
/* Creates a readable string for date - used in the UI */
fun convertToReadableDate(date: Date, dateStyle: Int = DateFormat.LONG): String {
return DateFormat.getDateInstance(dateStyle, Locale.getDefault()).format(date)
}
/* Creates a readable string date and time - used in the UI */
fun convertToReadableDateAndTime(date: Date, dateStyle: Int = DateFormat.SHORT, timeStyle: Int = DateFormat.SHORT): String {
return "${DateFormat.getDateInstance(dateStyle, Locale.getDefault()).format(date)} ${DateFormat.getTimeInstance(timeStyle, Locale.getDefault()).format(date)}"

View file

@ -24,13 +24,8 @@ import java.util.*
/*
* LengthUnitHelper object
*/
object LengthUnitHelper {
/* Converts for the given unit system a distance value to a readable string */
fun convertDistanceToString(distance: Float, useImperial: Boolean = false): String {
return convertDistanceToString(distance.toDouble(), useImperial)
}
object LengthUnitHelper
{
/* Converts for the given unit system a distance value to a readable string */
fun convertDistanceToString(distance: Double, useImperial: Boolean = false): String {
val readableDistance: Double

View file

@ -32,11 +32,8 @@ import org.y20k.trackbook.TrackerService
/*
* NotificationHelper class
*/
class NotificationHelper(private val trackerService: TrackerService) {
/* Define log tag */
private val TAG: String = LogHelper.makeLogTag(NotificationHelper::class.java)
class NotificationHelper(private val trackerService: TrackerService)
{
/* Main class variables */
private val notificationManager: NotificationManager = trackerService.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager

View file

@ -88,18 +88,18 @@ object PreferencesHelper {
return sharedPreferences.getBoolean(Keys.PREF_USE_IMPERIAL_UNITS, LengthUnitHelper.useImperialUnits())
}
fun loadGpsOnly(): Boolean {
return sharedPreferences.getBoolean(Keys.PREF_GPS_ONLY, false)
fun load_location_gps(): Boolean {
return sharedPreferences.getBoolean(Keys.PREF_LOCATION_GPS, false)
}
fun load_location_network(): Boolean {
return sharedPreferences.getBoolean(Keys.PREF_LOCATION_NETWORK, false)
}
fun loadOmitRests(): Boolean {
return sharedPreferences.getBoolean(Keys.PREF_OMIT_RESTS, true)
}
fun loadCommitInterval(): Int {
return sharedPreferences.getInt(Keys.PREF_COMMIT_INTERVAL, Keys.COMMIT_INTERVAL)
}
/* Loads the state of a map */
fun loadCurrentBestLocation(): Location {
val provider: String = sharedPreferences.getString(Keys.PREF_CURRENT_BEST_LOCATION_PROVIDER, LocationManager.NETWORK_PROVIDER) ?: LocationManager.NETWORK_PROVIDER

View file

@ -30,16 +30,13 @@ import org.y20k.trackbook.Keys
import org.y20k.trackbook.R
import org.y20k.trackbook.Database
import org.y20k.trackbook.Track
import org.y20k.trackbook.helpers.*
import java.text.DateFormat
import java.text.SimpleDateFormat
import java.util.*
class TracklistAdapter(val fragment: Fragment, val database: Database) : RecyclerView.Adapter<RecyclerView.ViewHolder>()
{
private val context: Context = fragment.activity as Context
private lateinit var tracklistListener: TracklistAdapterListener
private var useImperial: Boolean = PreferencesHelper.loadUseImperialUnits()
val tracks: ArrayList<Track> = ArrayList<Track>()
/* Listener Interface */

View file

@ -24,12 +24,9 @@ import android.view.ViewGroup
import android.widget.ImageButton
import android.widget.Toast
import androidx.constraintlayout.widget.Group
import androidx.core.view.isGone
import androidx.core.view.isVisible
import androidx.core.widget.NestedScrollView
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.textview.MaterialTextView
import org.osmdroid.api.IGeoPoint
import org.osmdroid.api.IMapController
import org.osmdroid.events.MapListener
import org.osmdroid.events.ScrollEvent
@ -68,8 +65,6 @@ data class TrackFragmentLayoutHolder(
private val statisticsSheet: NestedScrollView
private val statisticsView: View
private val distanceView: MaterialTextView
private val stepsTitleView: MaterialTextView
private val stepsView: MaterialTextView
private val waypointsView: MaterialTextView
private val durationView: MaterialTextView
private val velocityView: MaterialTextView
@ -102,14 +97,12 @@ data class TrackFragmentLayoutHolder(
mapView.setMultiTouchControls(true)
mapView.zoomController.setVisibility(org.osmdroid.views.CustomZoomButtonsController.Visibility.NEVER)
controller.setCenter(GeoPoint(track.view_latitude, track.view_longitude))
controller.setZoom(track.zoomLevel)
controller.setZoom(Keys.DEFAULT_ZOOM_LEVEL)
// get views for statistics sheet
statisticsSheet = rootView.findViewById(R.id.statistics_sheet)
statisticsView = rootView.findViewById(R.id.statistics_view)
distanceView = rootView.findViewById(R.id.statistics_data_distance)
stepsTitleView = rootView.findViewById(R.id.statistics_p_steps)
stepsView = rootView.findViewById(R.id.statistics_data_steps)
waypointsView = rootView.findViewById(R.id.statistics_data_waypoints)
durationView = rootView.findViewById(R.id.statistics_data_duration)
velocityView = rootView.findViewById(R.id.statistics_data_velocity)
@ -190,25 +183,13 @@ data class TrackFragmentLayoutHolder(
/* Overrides onZoom from MapListener */
override fun onZoom(event: ZoomEvent?): Boolean
{
if (event == null) {
return false
} else {
track.zoomLevel = event.zoomLevel
return true
}
return (event != null)
}
/* Overrides onScroll from MapListener */
override fun onScroll(event: ScrollEvent?): Boolean
{
if (event == null) {
return false
} else {
val center: IGeoPoint = mapView.mapCenter
track.view_latitude = center.latitude
track.view_longitude = center.longitude
return true
}
return (event != null)
}
}

View file

@ -78,29 +78,6 @@
app:layout_constraintTop_toTopOf="@+id/statistics_p_distance"
tools:text="@string/sample_text_default_data" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/statistics_p_steps"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="@string/statistics_sheet_p_steps"
android:textAppearance="@style/TextAppearance.Material3.BodyMedium"
android:textColor="@color/text_lightweight"
app:layout_constraintStart_toStartOf="@+id/statistics_p_distance"
app:layout_constraintTop_toBottomOf="@+id/statistics_p_distance" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/statistics_data_steps"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:textAppearance="@style/TextAppearance.Material3.BodyLarge"
android:textColor="@color/text_default"
app:layout_constraintBottom_toBottomOf="@+id/statistics_p_steps"
app:layout_constraintStart_toEndOf="@+id/statistics_p_steps"
app:layout_constraintTop_toTopOf="@+id/statistics_p_steps"
tools:text="@string/sample_text_default_data" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/statistics_p_waypoints"
android:layout_width="wrap_content"
@ -109,8 +86,8 @@
android:text="@string/statistics_sheet_p_waypoints"
android:textAppearance="@style/TextAppearance.Material3.BodyMedium"
android:textColor="@color/text_lightweight"
app:layout_constraintStart_toStartOf="@+id/statistics_p_steps"
app:layout_constraintTop_toBottomOf="@+id/statistics_p_steps" />
app:layout_constraintStart_toStartOf="@+id/statistics_p_distance"
app:layout_constraintTop_toBottomOf="@+id/statistics_p_distance" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/statistics_data_waypoints"

View file

@ -86,9 +86,6 @@
<string name="track_list_p_element_statistics">Samlet registreret distance</string>
<string name="pref_report_issue_summary">Rapporter fejl og foreslå forbedringer på GitHub.</string>
<string name="pref_imperial_measurement_units_summary_metric">I øjeblikket anvendes metriske enheder (kilometer, meter).</string>
<string name="pref_gps_only_summary_gps_only">I øjeblikket bruger vi kun GPS til lokalisering.</string>
<string name="pref_gps_only_summary_gps_and_network">I øjeblikket bruges GPS og netværk til lokalisering.</string>
<string name="pref_gps_only_title">Begræns til GPS</string>
<string name="pref_maintenance_title">Vedligeholdelse</string>
<string name="pref_imperial_measurement_units_summary_imperial">I øjeblikket anvendes britiske enheder (miles, fødder).</string>
<string name="pref_theme_selection_mode_device_default">Samme som enhed</string>

View file

@ -79,8 +79,6 @@
<string name="toast_message_save_gpx">Aufnahme wird als GPX gepeichert.</string>
<string name="dialog_yes_no_message_delete_non_starred">Alle nicht markierten Aufnahmen löschen\? Dies kann nicht rückgängig gemacht werden.</string>
<string name="pref_delete_non_starred_title">Lösche alle nicht markierten Aufnahmen</string>
<string name="pref_gps_only_summary_gps_only">Zur Ortung wird derzeit nur GPS verwendet.</string>
<string name="pref_gps_only_summary_gps_and_network">Zur Ortung werden derzeit GPS und Netzwerk verwendet.</string>
<string name="pref_theme_selection_title">Design der Anwendung</string>
<string name="pref_theme_selection_summary">Aktuelles Design:</string>
<string name="pref_reset_advanced_title">Zurücksetzen</string>
@ -88,7 +86,6 @@
<string name="pref_imperial_measurement_units_title">Imperiale Maße verwenden</string>
<string name="pref_imperial_measurement_units_summary_imperial">Derzeit werden imperiale Einheiten (Meilen, Fuß) verwendet.</string>
<string name="pref_imperial_measurement_units_summary_metric">Derzeit werden metrische Einheiten (Kilometer, Meter) verwendet.</string>
<string name="pref_gps_only_title">Auf GPS beschränken</string>
<string name="pref_maintenance_title">Instandhaltung</string>
<string name="pref_general_title">Generell</string>
<string name="pref_advanced_title">Erweitert</string>

View file

@ -7,7 +7,6 @@
<string name="abbreviation_seconds">Segundos</string>
<string name="track_list_onboarding_h1_part_2">...se mostrara aqui.</string>
<string name="pref_about_title">Acerca de</string>
<string name="pref_gps_only_summary_gps_only">Actualmente se usa solo GPS para la localización.</string>
<string name="pref_imperial_measurement_units_summary_imperial">Actualmente se utilizan unidades imperiales (millas, pies).</string>
<string name="pref_report_issue_summary">Informar errores y sugerir mejoras en GitHub.</string>
<string name="descr_button_resume">Resumir grabación</string>
@ -72,8 +71,6 @@
<string name="pref_delete_non_starred_title">Eliminar grabaciones no destacadas</string>
<string name="pref_general_title">General</string>
<string name="pref_maintenance_title">Mantenimiento</string>
<string name="pref_gps_only_title">Restringir a GPS</string>
<string name="pref_gps_only_summary_gps_and_network">Actualmente usando GPS y Red para localización.</string>
<string name="pref_imperial_measurement_units_summary_metric">Actualmente se utilizan unidades métricas (Kilómetro, Metro).</string>
<string name="pref_imperial_measurement_units_title">Utilizar medidas imperiales</string>
<string name="pref_report_issue_title">Reportar problema</string>

View file

@ -69,9 +69,6 @@
<string name="pref_accuracy_threshold_title">Seuil de précision</string>
<string name="pref_advanced_title">Avancé</string>
<string name="pref_general_title">Général</string>
<string name="pref_gps_only_title">N\'utiliser que le GPS</string>
<string name="pref_gps_only_summary_gps_and_network">Utilise actuellement le GPS et le réseau pour la localisation.</string>
<string name="pref_gps_only_summary_gps_only">Utilise actuellement seulement le GPS pour la localisation.</string>
<string name="pref_imperial_measurement_units_summary_metric">Utilise actuellement les unités métriques (kilomètre, mètre).</string>
<string name="pref_imperial_measurement_units_summary_imperial">Utilise actuellement les unités impériales (miles, pieds).</string>
<string name="pref_imperial_measurement_units_title">Utiliser les unités impériales</string>

View file

@ -5,7 +5,6 @@
<string name="statistics_sheet_p_velocity">Prosječna brzina:</string>
<string name="toast_message_save_gpx">Spremanje snimanja kao GPX.</string>
<string name="dialog_share_gpx">Dijeli GPX datoteku s</string>
<string name="pref_gps_only_title">Ograniči na GPS</string>
<string name="statistics_sheet_p_steps_no_pedometer">brojač koraka nije dostupan</string>
<string name="dialog_generic_details_button">Prikaži detalje</string>
<string name="descr_statistics_sheet_edit_button">Gumb za uređivanje puta</string>
@ -39,7 +38,6 @@
<string name="statistics_sheet_p_recording_stop">Snimanje prekinuto:</string>
<string name="dialog_rename_track_input_hint">Unesi novo ime</string>
<string name="pref_reset_advanced_summary">Vrati sve napredne postavke na standardne vrijednosti.</string>
<string name="pref_gps_only_summary_gps_and_network">Za određivanje lokacije trenutačno se koristi GPS i mreža.</string>
<string name="quick_settings_tile_title_default">Snima se</string>
<string name="pref_theme_selection_mode_device_default">Isto kao uređaj</string>
<string name="tab_map">Karta</string>
@ -80,7 +78,6 @@
<string name="layout_onboarding_description_app_icon">Ikona programa Trackbook</string>
<string name="dialog_error_empty_recording_button_resume">Nastavi snimati</string>
<string name="pref_maintenance_title">Održavanje</string>
<string name="pref_gps_only_summary_gps_only">Za određivanje lokacije trenutačno se koristi samo GPS.</string>
<string name="dialog_yes_no_positive_button_delete_non_starred">Izbriši</string>
<string name="track_list_onboarding_h1_part_2">… će se ovdje prikazati.</string>
<string name="statistics_sheet_p_min_altitude">Najniža točka rute:</string>

View file

@ -129,9 +129,6 @@
<string name="pref_imperial_measurement_units_title">Gunakan Pengukuran Imperial</string>
<string name="pref_imperial_measurement_units_summary_imperial">Saat ini menggunakan satuan imperial (Miles, Feet).</string>
<string name="pref_imperial_measurement_units_summary_metric">Saat ini menggunakan satuan metrik (Kilometer, Meter).</string>
<string name="pref_gps_only_summary_gps_only">Saat ini hanya menggunakan GPS untuk lokalisasi.</string>
<string name="pref_gps_only_summary_gps_and_network">Saat ini menggunakan GPS dan Jaringan untuk lokalisasi.</string>
<string name="pref_gps_only_title">Batasi ke GPS</string>
<string name="pref_maintenance_title">Pemeliharaan</string>
<string name="pref_general_title">Umum</string>
<string name="pref_delete_non_starred_title">Hapus Rekaman Tidak Berbintang</string>

View file

@ -79,9 +79,6 @@
<string name="pref_delete_non_starred_title">Cancella tutte le registrazioni non marcate</string>
<string name="pref_general_title">Generale</string>
<string name="pref_maintenance_title">Manutenzione</string>
<string name="pref_gps_only_title">Limita a GPS</string>
<string name="pref_gps_only_summary_gps_and_network">Sto usando GPS e rete per la localizzazione.</string>
<string name="pref_gps_only_summary_gps_only">Sto usando solo GPS per la localizzazione.</string>
<string name="pref_imperial_measurement_units_summary_metric">Sto usando il sistema metrico (kilometri, metri).</string>
<string name="pref_imperial_measurement_units_summary_imperial">Sto usando il sistema imperiale (miglia, piedi).</string>
<string name="pref_imperial_measurement_units_title">Usa il sistema imperiale</string>

View file

@ -69,9 +69,6 @@
<string name="pref_accuracy_threshold_title">Nøyaktighetsterskel</string>
<string name="pref_advanced_title">Avansert</string>
<string name="pref_general_title">Generelt</string>
<string name="pref_gps_only_title">Begrens til GPS</string>
<string name="pref_gps_only_summary_gps_and_network">Bruker nå GPS og nettverk for posisjonering.</string>
<string name="pref_gps_only_summary_gps_only">Bruker nå kun GPS for posisjonering.</string>
<string name="pref_imperial_measurement_units_summary_metric">Bruker nå kun metriske enheter (kilometer, meter).</string>
<string name="pref_imperial_measurement_units_summary_imperial">Bruker nå britiske måleenheter (mil, fot).</string>
<string name="pref_imperial_measurement_units_title">Bruk det britiske enhetssystem for mål og vekt</string>

View file

@ -69,9 +69,6 @@
<string name="pref_accuracy_threshold_title">Nauwkeurigheidsdrempel</string>
<string name="pref_advanced_title">Extra</string>
<string name="pref_general_title">Algemeen</string>
<string name="pref_gps_only_title">Alleen GPS gebruiken</string>
<string name="pref_gps_only_summary_gps_and_network">Gebruikt nu GPS en netwerk voor lokalisatie.</string>
<string name="pref_gps_only_summary_gps_only">Gebruikt nu alleen GPS voor lokalisatie.</string>
<string name="pref_imperial_measurement_units_summary_metric">Gebruikt nu metrische eenheden (kilometer, meter).</string>
<string name="pref_imperial_measurement_units_summary_imperial">Gebruikt nu imperiale eenheden (Miles, Feet).</string>
<string name="pref_imperial_measurement_units_title">Imperiale eenheden gebruiken</string>

View file

@ -37,9 +37,6 @@
<string name="pref_report_issue_title">Raport Wydanie</string>
<string name="pref_imperial_measurement_units_summary_imperial">Obecnie używane są jednostki imperialne (mile, stopy).</string>
<string name="pref_imperial_measurement_units_summary_metric">Obecnie używane są jednostki metryczne (Kilometr, Meter).</string>
<string name="pref_gps_only_summary_gps_only">Obecnie używa tylko GPS do lokalizacji.</string>
<string name="pref_gps_only_summary_gps_and_network">Obecnie wykorzystuje GPS i sieć do lokalizacji.</string>
<string name="pref_gps_only_title">Ograniczenie do GPS</string>
<string name="pref_maintenance_title">Konserwacja</string>
<string name="pref_advanced_title">Zaawansowane</string>
<string name="marker_description_accuracy">Dokładność</string>

View file

@ -79,9 +79,6 @@
<string name="pref_delete_non_starred_title">Apagar gravações sem estrelas</string>
<string name="pref_general_title">Geral</string>
<string name="pref_maintenance_title">Manutenção</string>
<string name="pref_gps_only_title">Restrito a GPS</string>
<string name="pref_gps_only_summary_gps_and_network">Atualmente usando GPS e rede para localização.</string>
<string name="pref_gps_only_summary_gps_only">Atualmente usando apenas GPS para localização.</string>
<string name="pref_imperial_measurement_units_summary_metric">Atualmente usando sistema internacional de unidade (Kilometer, Meter).</string>
<string name="pref_imperial_measurement_units_summary_imperial">Atualmente usando sistema imperial de unidade (Miles, Feet).</string>
<string name="pref_imperial_measurement_units_title">Usar Sistema Imperial</string>

View file

@ -63,9 +63,7 @@
<string name="pref_accuracy_threshold_title">Порог точности</string>
<string name="pref_accuracy_threshold_summary">Отбросьте исправления местоположения с точностью более (метров):</string>
<string name="pref_delete_non_starred_summary">Удалите все записи в \"Дорожках\", не отмеченные звездочками.</string>
<string name="pref_gps_only_summary_gps_and_network">В настоящее время для локализации используется GPS и сеть.</string>
<string name="pref_imperial_measurement_units_summary_metric">В настоящее время используются метрические единицы (километр, метр).</string>
<string name="pref_gps_only_summary_gps_only">В настоящее время для локализации используется только GPS.</string>
<string name="pref_reset_advanced_summary">Сброс расширенных настроек до значений по умолчанию.</string>
<string name="pref_report_issue_title">Выпуск отчета</string>
<string name="pref_theme_selection_mode_dark">Темный режим</string>
@ -80,7 +78,6 @@
<string name="pref_report_issue_summary">Сообщайте об ошибках и предлагайте улучшения на GitHub.</string>
<string name="pref_imperial_measurement_units_title">Используйте имперские меры</string>
<string name="pref_imperial_measurement_units_summary_imperial">В настоящее время используются имперские единицы (мили, футы).</string>
<string name="pref_gps_only_title">Ограничение на GPS</string>
<string name="pref_maintenance_title">Обслуживание</string>
<string name="pref_delete_non_starred_title">Удаление записей, не включенных в список</string>
<string name="track_list_p_element_statistics">Общее зарегистрированное расстояние</string>

View file

@ -82,8 +82,6 @@
<!--<string name="descr_delete_button"></string>-->
<!--<string name="descr_share_button_gpx"></string>-->
<string name="tab_settings">Inställningar</string>
<string name="pref_gps_only_summary_gps_and_network">För närvarande används GPS och nätverk för lokalisering.</string>
<string name="pref_gps_only_title">Begränsa till GPS</string>
<string name="pref_maintenance_title">Underhåll</string>
<string name="pref_general_title">Allmänt</string>
<string name="pref_delete_non_starred_title">Ta bort inspelningar som inte är starred</string>
@ -154,7 +152,6 @@
<string name="descr_mark_starred_button">Markera som stjärnmärkt</string>
<string name="descr_button_resume">Återuppta inspelning</string>
<string name="statistics_sheet_p_duration">Total varaktighet:</string>
<string name="pref_gps_only_summary_gps_only">För närvarande används endast GPS för lokalisering.</string>
<string name="pref_delete_non_starred_summary">Ta bort alla inspelningar i \"Tracks\" som inte har stjärnor.</string>
<string name="descr_button_start">Starta inspelning</string>
<string name="pref_theme_selection_summary">Aktuellt tema:</string>

View file

@ -28,9 +28,6 @@
<string name="pref_imperial_measurement_units_title">İngiliz Ölçülerini Kullan</string>
<string name="pref_imperial_measurement_units_summary_imperial">Şu anda İngiliz ölçü birimleri (mil, fit) kullanılıyor.</string>
<string name="pref_imperial_measurement_units_summary_metric">Şu anda metrik birimler (kilometre, metre) kullanılıyor.</string>
<string name="pref_gps_only_summary_gps_only">Konumu belirlemek için şu anda yalnızca GPS kullanılıyor.</string>
<string name="pref_gps_only_summary_gps_and_network">Konumu belirlemek için şu anda GPS ve ağ kullanılıyor.</string>
<string name="pref_gps_only_title">Yalnızca GPS kullan</string>
<string name="pref_maintenance_title">Bakım</string>
<string name="pref_general_title">Genel</string>
<string name="pref_delete_non_starred_title">Yıldızlı Olmayan Kayıtları Sil</string>

View file

@ -85,9 +85,6 @@
<string name="pref_delete_non_starred_title">删除未加星的记录</string>
<string name="pref_general_title">常规</string>
<string name="pref_maintenance_title">维护</string>
<string name="pref_gps_only_title">仅限 GPS</string>
<string name="pref_gps_only_summary_gps_and_network">当前正使用 GPS 和网络进行定位。</string>
<string name="pref_gps_only_summary_gps_only">当前正仅使用 GPS 进行定位。</string>
<string name="pref_imperial_measurement_units_summary_metric">当前正使用公制单位(千米,米)。</string>
<string name="pref_imperial_measurement_units_summary_imperial">当前正使用英制单位(英里,英尺)。</string>
<string name="pref_imperial_measurement_units_title">使用英制测量</string>

View file

@ -95,9 +95,12 @@
<string name="pref_delete_non_starred_title">Delete Non-Starred Recordings</string>
<string name="pref_general_title">General</string>
<string name="pref_maintenance_title">Maintenance</string>
<string name="pref_gps_only_title">Restrict to GPS</string>
<string name="pref_gps_only_summary_gps_and_network">Currently using GPS and Network for location.</string>
<string name="pref_gps_only_summary_gps_only">Currently using only GPS for location.</string>
<string name="pref_location_gps_title">Use GPS location</string>
<string name="pref_location_gps_summary_on">GPS location enabled</string>
<string name="pref_location_gps_summary_off">GPS location disabled</string>
<string name="pref_location_network_title">Use Network location</string>
<string name="pref_location_network_summary_on">Network location enabled</string>
<string name="pref_location_network_summary_off">Network location disabled</string>
<string name="pref_imperial_measurement_units_summary_metric">Currently using metric units (Kilometer, Meter).</string>
<string name="pref_imperial_measurement_units_summary_imperial">Currently using imperial units (Miles, Feet).</string>
<string name="pref_imperial_measurement_units_title">Use Imperial Measurements</string>