Skip to content

fix(play): keep a song heard on a radio app, and name it by the first listen - #1311

Merged
astrovm merged 4 commits into
mainfrom
fix/cover-kept-on-resend
Nov 28, 2026
Merged

astrovm merged 4 commits into
mainfrom
fix/cover-kept-on-resend

Conversation

@astrovm

@astrovm astrovm commented Nov 28, 2026 •

Copy link
Copy Markdown
Owner

A song heard on a radio app that names only its station (VRadio) did not stay on the bar, and took two listens to name after Crosstune came back in sight. A user reported the station shown as the song in 2.26.0. The song is named now; this PR makes it stay.

Causes and fixes

Measured on the Samsung with VRadio playing Mía FM.

1. The station's cover was dropped each time its app said it again

  1. VRadio says its station again every 30 to 60 seconds: the same name and logo, with a longer length.
  2. On each one, PlaybackCovers.forget dropped the logo saved for that session. The next read had no cover until the same picture was saved again.
  3. What plays went from "station with cover" to "station without cover" and back. MainViewModel took each as another station, dropped the song heard and listened again.

Fix: PlaybackCovers keeps the cover a session had, under the same name, until the new one is saved. A new picture still replaces the old one. This also stops a song's bitmap cover from blinking out when its app resends the same song.

2. The first listen after the app is watched anew was thrown away

  1. When what plays is watched anew (Crosstune back in sight), the listen by ear started before the app's follow said how it plays.
  2. The song heard then had nothing to be checked by. When the follow arrived, checkHeard saw "nothing" become "something" and dropped the hearing. Naming took two listens, about 10 s in place of 5 s.

Fix: nameByEar waits up to 1 s (FOLLOW_SAID_MS) for the follow of the station it is about to hear. The wait is skipped for apps that report no state, for Radio Garden and when no station plays. It is cleared each time a station is followed anew.

Other changes

  1. PlaybackCovers.of is split into known and saveLater (detekt's complexity limit).
  2. The 2.29.0 changelog is rewritten to fit Play's 500 characters (457), with the card redesign of PR feat(card): put the app on the main button and the rarer tools behind a menu #1309 and "A song heard on a radio app stays named."

Tests

  1. PlaybackTest.aStationSaidAgainKeepsItsCoverSoItStaysTheSameStation: fails without fix 1.
  2. PlaybackTest.aCoverKeptWhileItsSavedAgainIsOnlyForItsOwnSessionAndName: the kept cover is never given to another name or session.
  3. MainViewModelTest.aStationWatchedAgainIsNamedByItsFirstListen: fails without fix 2 ("expected 1 but was 2"). Its last step (station, then a song its app names, then the station again) fails without the reset in collectLatest ("expected 4 but was 5").
  4. comingBackToCrosstuneDropsTheSongHeardThenListensAgainAtOnceOnceTheBarIsInSight: with the follow held, the listen comes after FOLLOW_SAID_MS.

Done when

  • :app:ci passes locally (7d472e7: BUILD SUCCESSFUL, 16m 38s; the merge of main after it touched none of this PR's files)
  • CI and mutation testing pass (da6d0ae: 20 of 20 checks; 53 of 55 mutants caught, the two left are explained under Mutants)
  • Checked on the Samsung with VRadio, perf build of da6d0ae, screen kept on: named 7 s after opening by the first listen; the song stayed 51 s and 44 s through VRadio's resends, changing only when the station went to its next song; after leaving and coming back, named again within 8 s by one listen. The song card of PR feat(card): put the app on the main button and the rarer tools behind a menu #1309 shows as designed in the same build. No crash in the log.
  • Agent review

Mutants

Two survived, and neither is a test gap:

  1. MainViewModel.kt:1138, the reset of followSaid in watchPlayingNow, removed. The reset at the start of each follow covers the same case in the tests. This one stays as a guard for a listen that could start before the follow does.
  2. MainViewModel.kt:1234, the value of the wait's block set to null. The value is never read, so the change does nothing.

Review

Three Sonnet reviews.

  1. Review 1 (cover fix): no defect. Its suggested tests were added (test 2).
  2. Review 2 (wait for the follow): two defects, both fixed. The wait came after the joins of the other listeners, so time could pass between it and the listen. followSaid was not cleared when a station was followed anew, so a stale value skipped the wait.
  3. Review 3 (those fixes): no defect. Rejected findings:
    a. "No test fails without the reset": measured, the test fails without it (4 expected, 5 listens).
    b. "1 s per listen if the follow never says anything": the follow always says a first value on registration; if it said nothing, the cost is 1 s on listens 30 s or more apart, and the hearing is kept.
    c. "A late write from an old follow job": the old watch is cancelled on the main thread before the new one resets the value, so a cancelled collector cannot write after it.

Known issues

  1. A song heard is not kept across a screen off and on: it costs one listen (about 5 s) on return. Kept as it is on purpose, since the station may have moved to another song meanwhile.
  2. When a station's session ends, its follow can end a moment before the station does, which starts one listen that is cancelled at once. main does the same.

@github-actions

github-actions Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Mutation testing: 53 of 55 changes caught by a test.

MainViewModel.kt:1138  survived: removed call to kotlinx/coroutines/flow/MutableStateFlow::setValue [class=com.astrovm.crosstune.MainViewModel method=watchPlayingNow(Lkotlin/coroutines/Continuation;)Ljava/lang/Object; mutator=org.pitest.mutationtest.engine.gregor.mutators.VoidMethodCallMutator index=106 block=20]
MainViewModel.kt:1234  survived: replaced return value with null for com/astrovm/crosstune/MainViewModel$untilFollowSaid$2::invokeSuspend [class=com.astrovm.crosstune.MainViewModel$untilFollowSaid$2 method=invokeSuspend(Ljava/lang/Object;)Ljava/lang/Object; mutator=org.pitest.mutationtest.engine.gregor.mutators.returns.NullReturnValsMutator index=49 block=10]

Each one is a change to the code no test noticed. Not a blocker: real gaps get their own PR. Full report

astrovm added a commit that referenced this pull request Nov 28, 2026
… a menu (#1309)

A song's card had four rows of controls: the app chip, the main button
with two icons beside it, and a row of up to six tools. This makes it
two.

## What changes

1. **The app is part of the main button.** The app's icon sits at the
end of **Play** (or **Open**, **Search**), behind a thin line. A tap
there opens the same list of apps the chip opened. The chip above the
button is gone.
2. **The other ways in are tools with a word.** **Search** and **Open**
were icon-only buttons beside **Play**, which moved under it at big
fonts. They are now flat tools in the row under the button, after
**Lyrics**, each with its word.
3. **A song's rarer tools are behind ⋮.** **Copy link**, **Share link**
and **Download** are rows of a menu, each said whole with its icon. A
playlist or album keeps all its tools in the row, as it has fewer ways
in.
4. **Download stays in sight once it's used.** While a song is being
saved, is kept, or there is no room left, **Download** is in the row and
shows its state, as before. After the song is let go, it stays in the
row until another song's card, so the button does not jump away under
the finger or the remote.
5. **A main button that can't be pressed is grey**, with both of its
ends.
6. **Screen readers** hear the app's name and then "Choose app" on the
button's end, as before. The main button, its app end and ⋮ are
announced as buttons.

## Tests

1. `CardButtonsLayoutTest` is rewritten for the new button: both ends as
tall, the line between, the card's width, the roles, the grey fill,
mirrored right to left, the tools under it.
2. `CardToolsFitTest` checks, in 16 languages at the largest fonts on a
narrow phone, a common one and a TV, that the button spans the card, its
word is never smaller than at the default font, each tool and ⋮ is in
sight and at least 48 dp, each menu row is shown, and a kept song's
fuller row fits.
3. `KeepOfflineButtonTest` checks the menu row's text per state, that a
kept song has **Download** in the row, and that it stays there after the
song is let go, until another song.
4. `TvPlayTest`: right from **Play** lands on the app and left goes
back, down goes to the tools, and a tool picked behind ⋮ leaves the
remote on ⋮.
5. `MainActivityTest` and `ListeningTest` helpers open ⋮ when a tool is
behind it. The swipe tests tell the player by its cover, as the card has
a ⋮ too.

## Done when

- [x] `:app:ci` passes locally (all tests, 100% line coverage, lint,
detekt): green on the tree of 67ac7cf
- [x] CI and mutation testing pass on 67ac7cf
- [x] Checked on the Samsung, build of 67ac7cf: song, ⋮ menu, kept,
let go, another song, playlist, a link not found, German at 2x font with
the menu, light, dark, pure black. 0 crashes
- [x] Checked on the TV emulator: focus starts on **Play**, right
reaches the app and back returns to it, down reaches ⋮, the menu opens
on **Copy link**, focus returns to ⋮ after a pick
- [x] Store screenshots and site clips redrawn (754b66d)
- [x] Agent review: three reviews, the third found no defect

## Review

Fixed from the reviews:

1. A kept song's **Download** state was hidden behind ⋮. It is in the
row now while it is saving, kept or out of room.
2. Un-keeping a song on a TV moved the button under the remote. It stays
in the row until another song.
3. The main button, its app end and ⋮ had no button role.
4. A main button that can't be pressed looked enabled.
5. Tests: sizes, roles, the menu rows and the kept row were not held.

Not changed, and why:

1. *The press animation covers the whole button, also for a press on its
app end.* It is one button with two ends, and it reads as one.
2. *Two things are named "More": ⋮ and the last row of the app list.* It
is the same word the app uses elsewhere for "the rest", and a second
word costs more than it gives.
3. *The ⋮ menu's open state could outlive its card.* The menu closes
when the result changes; `KeepOfflineButtonTest` shows another song's
card with its row as new.
4. *The floating **Play** does not look disabled.* It was so before this
PR: Issue #1310.
5. *When a song's details change right after it is let go, **Download**
can go back behind ⋮ early.* Rare, and it costs one tap.
6. *`CardToolsFitTest` measures the room a word has, not its drawn
size.* Robolectric does not report the drawn size of auto-sized text.
The phone check at 2x font covers what it cannot.

## Known issues

1. Issue #1310: the floating **Play** button does not look disabled
while it can't be pressed. Not from this PR.
2. Found during the phone check, not from this PR: a song heard on a
radio app (VRadio) dropped back to the station name every 15 to 30
seconds. The fix is in PR #1311.
@astrovm astrovm changed the title fix(play): keep a station's cover when its app says it again, so the song heard in it stays fix(play): keep a song heard on a radio app, and name it by the first listen Nov 28, 2026
@astrovm
astrovm marked this pull request as ready for review November 28, 2026 22:23
@astrovm
astrovm merged commit 12067ae into main Nov 28, 2026
20 checks passed
@astrovm
astrovm deleted the fix/cover-kept-on-resend branch November 28, 2026 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant