Add Recently Played tab to Android Auto#3567
Add Recently Played tab to Android Auto#3567hazemelraffiee wants to merge 3 commits intoquran:mainfrom
Conversation
Track recently played sura+qari combinations and surface them as a browsable "Recently Played" tab alongside the existing Qaris tab. Keeps up to 5 entries, deduped by sura+qari pair. Also fixes the service to extend MediaLibraryService (instead of MediaSessionService) and accept subscriptions so that notifyChildrenChanged properly refreshes the browse tree when new tracks are played.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 48c5bcedd6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| BrowsableSurahBuilder.RECENT_ID, recentCount, null | ||
| ) | ||
| mediaSession?.notifyChildrenChanged( | ||
| BrowsableSurahBuilder.ROOT_ID, recentCount + 1, null |
There was a problem hiding this comment.
Use correct root child count in change notifications
When a new recent item is recorded, this notifies ROOT_ID with recentCount + 1, but the root node only ever exposes one child (Qaris) or two children (Recently Played + Qaris). After the second recent entry, browsers are told there are 3+ root children that do not exist, which can lead Android Auto clients to request non-existent items and show inconsistent/empty UI. The root notification count should be fixed to the actual root size (typically 2 when recents exist, otherwise 1, or ITEM_COUNT_UNKNOWN).
Useful? React with 👍 / 👎.
The root browse tree always has exactly 2 children (Recently Played + Qaris) when a track transition records a recent qari. Using recentCount + 1 was incorrect since recentCount is the number of recent entries, not the number of root children. Add a test for the root child count invariant.
ahmedre
left a comment
There was a problem hiding this comment.
code looks good جزاكم الله خيراً - I will test it in sha' Allah before merging.
small suggestion - instead of the manual json stuff can we use moshi since it's already a dependency in the repo and will make things a bit clearer.
Adds a "Recently Played" browsable tab to the Android Auto browse tree, shown alongside the existing Qaris tab. Tracks the last 5 played sura+qari combinations and updates in real time as new tracks play.
Changes:
RecentQariManagerto persist recently played entries via SharedPreferencesBrowsableSurahBuildernow returns a "Recently Played" folder at root when history existsMediaLibraryService(wasMediaSessionService) and accepts subscriptions sonotifyChildrenChangedproperly refreshes the browse treePlayerEventListenerrecords plays and notifies the browse tree on track transitions