On vibrate on wake if debug mode is active.

The vibration provides a confirmation that the device's motion sensors
work as expected. But it makes sense to turn that off when not
debugging.
This commit is contained in:
voussoir 2023-09-03 10:58:33 -07:00
parent dadce17f5e
commit 00ee14303d
2 changed files with 15 additions and 3 deletions

View file

@ -47,6 +47,7 @@ class TrackerService: Service()
var useImperial: Boolean = false var useImperial: Boolean = false
var omitRests: Boolean = true var omitRests: Boolean = true
var max_accuracy: Float = Keys.DEFAULT_MAX_ACCURACY var max_accuracy: Float = Keys.DEFAULT_MAX_ACCURACY
var show_debug: Boolean = false
var allow_sleep: Boolean = true var allow_sleep: Boolean = true
var device_id: String = random_device_id() var device_id: String = random_device_id()
var currentBestLocation: Location = getDefaultLocation() var currentBestLocation: Location = getDefaultLocation()
@ -611,6 +612,7 @@ class TrackerService: Service()
useImperial = PreferencesHelper.loadUseImperialUnits() useImperial = PreferencesHelper.loadUseImperialUnits()
omitRests = PreferencesHelper.loadOmitRests() omitRests = PreferencesHelper.loadOmitRests()
max_accuracy = PreferencesHelper.load_max_accuracy() max_accuracy = PreferencesHelper.load_max_accuracy()
show_debug = PreferencesHelper.loadShowDebug()
allow_sleep = PreferencesHelper.loadAllowSleep() allow_sleep = PreferencesHelper.loadAllowSleep()
locationManager = getSystemService(Context.LOCATION_SERVICE) as LocationManager locationManager = getSystemService(Context.LOCATION_SERVICE) as LocationManager
notification_manager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager notification_manager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
@ -640,7 +642,10 @@ class TrackerService: Service()
last_significant_motion = System.currentTimeMillis() last_significant_motion = System.currentTimeMillis()
if (tracking_state == Keys.STATE_SLEEP || tracking_state == Keys.STATE_DEAD) if (tracking_state == Keys.STATE_SLEEP || tracking_state == Keys.STATE_DEAD)
{ {
vibrator.vibrate(100) if (show_debug)
{
vibrator.vibrate(100)
}
state_full_recording() state_full_recording()
} }
sensor_manager.requestTriggerSensor(this, significant_motion_sensor) sensor_manager.requestTriggerSensor(this, significant_motion_sensor)
@ -660,7 +665,10 @@ class TrackerService: Service()
last_significant_motion = System.currentTimeMillis() last_significant_motion = System.currentTimeMillis()
if (tracking_state == Keys.STATE_SLEEP || tracking_state == Keys.STATE_DEAD) if (tracking_state == Keys.STATE_SLEEP || tracking_state == Keys.STATE_DEAD)
{ {
vibrator.vibrate(100) if (show_debug)
{
vibrator.vibrate(100)
}
state_full_recording() state_full_recording()
} }
} }
@ -766,6 +774,10 @@ class TrackerService: Service()
{ {
max_accuracy = PreferencesHelper.load_max_accuracy() max_accuracy = PreferencesHelper.load_max_accuracy()
} }
Keys.PREF_SHOW_DEBUG ->
{
show_debug = PreferencesHelper.loadShowDebug()
}
Keys.PREF_ALLOW_SLEEP -> Keys.PREF_ALLOW_SLEEP ->
{ {
allow_sleep = PreferencesHelper.loadAllowSleep() allow_sleep = PreferencesHelper.loadAllowSleep()

View file

@ -115,7 +115,7 @@
<string name="pref_theme_selection_summary">Current theme:</string> <string name="pref_theme_selection_summary">Current theme:</string>
<string name="pref_theme_selection_title">App theme</string> <string name="pref_theme_selection_title">App theme</string>
<string name="pref_show_debug_title">Show debug info</string> <string name="pref_show_debug_title">Show debug info</string>
<string name="pref_show_debug_summary_on">Debug info shown on map screen.</string> <string name="pref_show_debug_summary_on">Debug info shown on map screen. Device will vibrate when woken by motion sensors.</string>
<string name="pref_show_debug_summary_off">Debug info hidden.</string> <string name="pref_show_debug_summary_off">Debug info hidden.</string>
<string name="pref_disable_battery_optimization_title">Disable battery optimization</string> <string name="pref_disable_battery_optimization_title">Disable battery optimization</string>
<string name="pref_disable_battery_optimization_summary">If your device kills the app, you can give this a try.</string> <string name="pref_disable_battery_optimization_summary">If your device kills the app, you can give this a try.</string>