Skip to content

Commit 7f5fe55

Browse files
eriedclaude
andcommitted
link auto-record idle-stop to motion-start, drop separate toggle
Recording auto-control is now a single loop: "Start recording when in motion" gates both the motion-triggered start AND the idle-timeout auto-stop, so the wheel auto-starts again on the next ride instead of staying silent after the first idle stop. - Rename autoRecordOnlyInMotion → autoRecordStartInMotion - Drop autoRecordStopWhenIdle (implicit when start-in-motion is on) - Settings: single switch + idle-seconds slider below it - DB schema 17 → 18 (destructive migration) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 192dd8d commit 7f5fe55

7 files changed

Lines changed: 23 additions & 32 deletions

File tree

app/src/main/java/com/eried/eucplanet/data/db/AppDatabase.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import com.eried.eucplanet.data.model.TripRecord
88

99
@Database(
1010
entities = [AppSettings::class, TripRecord::class, AlarmRule::class],
11-
version = 17,
11+
version = 18,
1212
exportSchema = false
1313
)
1414
abstract class AppDatabase : RoomDatabase() {

app/src/main/java/com/eried/eucplanet/data/model/AppSettings.kt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,10 @@ data class AppSettings(
6565

6666
// Recording
6767
val autoRecord: Boolean = false,
68-
// Only start auto-recording once the wheel actually starts moving (speed > 0).
68+
// Motion-linked loop: wait for speed > 0 to start recording, auto-stop after idle timeout,
69+
// restart on next motion. When false, recording starts at connect and runs until disconnect.
6970
@ColumnInfo(defaultValue = "0")
70-
val autoRecordOnlyInMotion: Boolean = false,
71-
// Stop auto-recording if the wheel is idle (speed == 0) OR disconnected for this many seconds.
72-
@ColumnInfo(defaultValue = "0")
73-
val autoRecordStopWhenIdle: Boolean = false,
71+
val autoRecordStartInMotion: Boolean = false,
7472
@ColumnInfo(defaultValue = "60")
7573
val autoRecordStopIdleSeconds: Int = 60,
7674

app/src/main/java/com/eried/eucplanet/data/sync/SyncManager.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,7 @@ class SyncManager @Inject constructor(
195195
put("announceSafetyMode", s.announceSafetyMode)
196196
put("announceWelcome", s.announceWelcome)
197197
put("autoRecord", s.autoRecord)
198-
put("autoRecordOnlyInMotion", s.autoRecordOnlyInMotion)
199-
put("autoRecordStopWhenIdle", s.autoRecordStopWhenIdle)
198+
put("autoRecordStartInMotion", s.autoRecordStartInMotion)
200199
put("autoRecordStopIdleSeconds", s.autoRecordStopIdleSeconds)
201200
put("flic1Name", s.flic1Name)
202201
put("flic1Click", s.flic1Click)
@@ -258,8 +257,10 @@ class SyncManager @Inject constructor(
258257
announceSafetyMode = j.optBoolean("announceSafetyMode", base.announceSafetyMode),
259258
announceWelcome = j.optBoolean("announceWelcome", base.announceWelcome),
260259
autoRecord = j.optBoolean("autoRecord", base.autoRecord),
261-
autoRecordOnlyInMotion = j.optBoolean("autoRecordOnlyInMotion", base.autoRecordOnlyInMotion),
262-
autoRecordStopWhenIdle = j.optBoolean("autoRecordStopWhenIdle", base.autoRecordStopWhenIdle),
260+
autoRecordStartInMotion = j.optBoolean(
261+
"autoRecordStartInMotion",
262+
j.optBoolean("autoRecordOnlyInMotion", base.autoRecordStartInMotion)
263+
),
263264
autoRecordStopIdleSeconds = j.optInt("autoRecordStopIdleSeconds", base.autoRecordStopIdleSeconds),
264265
flic1Name = j.optString("flic1Name", base.flic1Name),
265266
flic1Click = j.optString("flic1Click", base.flic1Click),

app/src/main/java/com/eried/eucplanet/service/WheelService.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ class WheelService : LifecycleService() {
116116
voiceService.announceEvent(getString(R.string.voice_wheel_connected))
117117
}
118118
// Auto-record: start recording when wheel connects, unless the user
119-
// gated it on "only while in motion" — then the telemetry handler starts it.
120-
if (settings.autoRecord && !settings.autoRecordOnlyInMotion &&
119+
// gated it on "start in motion" — then the telemetry handler starts it.
120+
if (settings.autoRecord && !settings.autoRecordStartInMotion &&
121121
!tripRepository.recording.value) {
122122
lifecycleScope.launch { tripRepository.startRecording() }
123123
}
@@ -207,8 +207,8 @@ class WheelService : LifecycleService() {
207207
val moving = kotlin.math.abs(data.speed) > 0f
208208
if (moving) lastMotionAtMs = System.currentTimeMillis()
209209

210-
// "Only while in motion": start as soon as we see speed > 0, and only while connected.
211-
if (settings.autoRecordOnlyInMotion &&
210+
// Motion-linked loop: start on first motion and restart after each idle auto-stop.
211+
if (settings.autoRecordStartInMotion &&
212212
moving &&
213213
wheelRepository.connectionState.value == ConnectionState.CONNECTED &&
214214
!tripRepository.recording.value
@@ -222,7 +222,7 @@ class WheelService : LifecycleService() {
222222
while (true) {
223223
delay(1000L)
224224
val settings = settingsRepository.get()
225-
if (!settings.autoRecord || !settings.autoRecordStopWhenIdle) continue
225+
if (!settings.autoRecord || !settings.autoRecordStartInMotion) continue
226226
if (!tripRepository.recording.value) continue
227227

228228
val connected = wheelRepository.connectionState.value == ConnectionState.CONNECTED

app/src/main/java/com/eried/eucplanet/ui/settings/SettingsScreen.kt

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -221,16 +221,11 @@ private fun GeneralTab(
221221
HintText(stringResource(R.string.auto_record_caption), small = true)
222222
if (settings.autoRecord) {
223223
SwitchSetting(
224-
stringResource(R.string.auto_record_only_in_motion),
225-
settings.autoRecordOnlyInMotion
226-
) { viewModel.updateAutoRecordOnlyInMotion(it) }
227-
HintText(stringResource(R.string.auto_record_only_in_motion_caption), small = true)
228-
SwitchSetting(
229-
stringResource(R.string.auto_record_stop_when_idle),
230-
settings.autoRecordStopWhenIdle
231-
) { viewModel.updateAutoRecordStopWhenIdle(it) }
232-
HintText(stringResource(R.string.auto_record_stop_when_idle_caption), small = true)
233-
if (settings.autoRecordStopWhenIdle) {
224+
stringResource(R.string.auto_record_start_in_motion),
225+
settings.autoRecordStartInMotion
226+
) { viewModel.updateAutoRecordStartInMotion(it) }
227+
HintText(stringResource(R.string.auto_record_start_in_motion_caption), small = true)
228+
if (settings.autoRecordStartInMotion) {
234229
SliderSetting(
235230
label = stringResource(R.string.auto_record_stop_idle_seconds),
236231
value = settings.autoRecordStopIdleSeconds.toFloat(),

app/src/main/java/com/eried/eucplanet/ui/settings/SettingsViewModel.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,7 @@ class SettingsViewModel @Inject constructor(
108108
fun updateVoiceAudioFocus(v: String) = update { copy(voiceAudioFocus = v) }
109109
fun updateVoiceOutputChannel(v: String) = update { copy(voiceOutputChannel = v) }
110110
fun updateAutoRecord(v: Boolean) = update { copy(autoRecord = v) }
111-
fun updateAutoRecordOnlyInMotion(v: Boolean) = update { copy(autoRecordOnlyInMotion = v) }
112-
fun updateAutoRecordStopWhenIdle(v: Boolean) = update { copy(autoRecordStopWhenIdle = v) }
111+
fun updateAutoRecordStartInMotion(v: Boolean) = update { copy(autoRecordStartInMotion = v) }
113112
fun updateAutoRecordStopIdleSeconds(v: Int) = update { copy(autoRecordStopIdleSeconds = v.coerceIn(10, 600)) }
114113
fun updateAutoConnect(v: Boolean) = update { copy(autoConnect = v) }
115114

app/src/main/res/values/strings.xml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,9 @@
102102
<string name="section_connection">Connection</string>
103103
<string name="section_display">Display</string>
104104
<string name="auto_record_on_start">Auto-record on start</string>
105-
<string name="auto_record_caption">Starts recording automatically as soon as the wheel connects</string>
106-
<string name="auto_record_only_in_motion">Only record when in motion</string>
107-
<string name="auto_record_only_in_motion_caption">Waits for the wheel to start moving before starting the recording</string>
108-
<string name="auto_record_stop_when_idle">Auto-stop when idle</string>
109-
<string name="auto_record_stop_when_idle_caption">Stops the recording if the wheel is stopped or disconnected for the selected time</string>
105+
<string name="auto_record_caption">Records every trip without tapping Start</string>
106+
<string name="auto_record_start_in_motion">Start recording when in motion</string>
107+
<string name="auto_record_start_in_motion_caption">Waits for movement to start recording, auto-stops after the idle time, and restarts on the next ride. When off, recording runs the whole time the wheel is connected</string>
110108
<string name="auto_record_stop_idle_seconds">Idle time before stopping</string>
111109
<string name="auto_connect_on_start">Auto-connect on start</string>
112110
<string name="auto_connect_caption">Reconnects to the last wheel you paired. You need to connect manually the first time</string>

0 commit comments

Comments
 (0)