Decode: optionally clear decodes + reset TX target on band/mode change#351
Merged
Conversation
Changing band or mode left the decode list showing stale spots from the old band/mode and kept the previous TX target. A tester asked for an option to auto-clear the decode scene and TX target on such a change. Add a clearOnBandModeChange setting (default ON, persisted as "clearOnBandModeChange", with a toggle in Transmission settings). When on, clearDecodesAndTarget() wipes the decode list and resets the TX target to CQ from the three change paths: - setOperatingMode (mode change), - selectBandIndex (operator picks a band), - onFreqChanged (rig reports a band change). The band paths gate on shouldClearOnBandChange(), a pure predicate that clears only when the band index actually changed (so a no-op re-select or a small in-band dial report doesn't wipe the list). Unit-tested. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #351 +/- ##
============================================
- Coverage 11.70% 11.45% -0.26%
- Complexity 113 120 +7
============================================
Files 85 89 +4
Lines 11691 12580 +889
Branches 2110 2249 +139
============================================
+ Hits 1369 1441 +72
- Misses 10191 11008 +817
Partials 131 131
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds a new setting to optionally clear stale decodes and reset the TX target when the operator changes band or operating mode, aiming to prevent the UI and TX target from reflecting the previous band/mode after a change.
Changes:
- Introduces
clearOnBandModeChange(default ON), persisted asclearOnBandModeChange, and exposes it as a toggle in Transmission settings. - Clears decodes + resets TX target on mode changes and on band changes coming from either user selection or rig-reported frequency changes (with an attempted “no-op band change” gate).
- Adds a unit test suite for the band-change gating predicate.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| ft8af/app/src/test/java/com/k1af/ft8af/ClearOnBandChangeTest.java | Adds unit tests for the band-change clearing predicate. |
| ft8af/app/src/main/res/values/strings_compose.xml | Adds user-facing strings for the new Transmission setting toggle. |
| ft8af/app/src/main/kotlin/radio/ks3ckc/ft8af/ui/settings/TransmissionSettings.kt | Adds UI toggle + persistence for clearOnBandModeChange. |
| ft8af/app/src/main/kotlin/radio/ks3ckc/ft8af/ui/components/FrequencyPickerSheet.kt | Clears decodes/target on user-selected band changes when enabled. |
| ft8af/app/src/main/java/com/k1af/ft8af/MainViewModel.java | Implements clearing behavior and band-change predicate; wires clearing into rig freq change + mode change paths. |
| ft8af/app/src/main/java/com/k1af/ft8af/GeneralVariables.java | Adds new global boolean clearOnBandModeChange defaulting to true. |
| ft8af/app/src/main/java/com/k1af/ft8af/database/DatabaseOpr.java | Loads the persisted clearOnBandModeChange config value into GeneralVariables. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
shouldClearOnBandChange compared band-list indices, but OperationBand.getIndexByFreq() appends a new entry for any previously-unseen frequency, so a small in-band dial move changes the index without changing the band — and wrongly cleared decodes/TX target. Compare the meter (wavelength) band instead, which only changes on a real band hop. - shouldClearOnBandChange(enabled, oldWaveLength, newWaveLength) - Update both callers (rig onFreqChanged, band-picker selectBandIndex) to derive wavelengths via BaseRigOperation.getMeterFromFreq. - Rewrite ClearOnBandChangeTest for wavelength semantics: different wavelength clears; same wavelength (incl. different in-band freq) does not; disabled never clears; null wavelengths compare equal. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Tester request: "how about add new option for auto clear decode scene & tx target when change mode / band :)"
Today, changing band or mode leaves the decode list showing stale spots from the old band/mode and keeps the previous TX target.
Change
New
clearOnBandModeChangesetting (default ON), persisted as"clearOnBandModeChange", with a toggle in Transmission settings under the existing TX/RX split row.When enabled,
clearDecodesAndTarget()wipes the decode list and resets the TX target to CQ from the three change paths:setOperatingMode— mode change (FT8 ⇄ FT4 ⇄ …),selectBandIndex— operator picks a band in the frequency picker,onFreqChanged— rig reports a band change (e.g. dial turned).The band paths gate on
shouldClearOnBandChange(enabled, oldIndex, newIndex), a pure predicate that clears only when the band index actually changed — so a no-op band re-select or a small in-band dial report doesn't wipe the list. The TX target is only reset when not mid-transmit.Tests
ClearOnBandChangeTestcovering the predicate (enabled+changed clears; same band doesn't; disabled never).testDebugUnitTestgreen; built and installed on the Pixel 8, launches cleanly.Part of a series addressing tester feedback on the Android UI (item 4 of 4 in this batch).