Skip to content

Add Recently Played tab to Android Auto#3567

Open
hazemelraffiee wants to merge 3 commits intoquran:mainfrom
hazemelraffiee:auto_recently_played
Open

Add Recently Played tab to Android Auto#3567
hazemelraffiee wants to merge 3 commits intoquran:mainfrom
hazemelraffiee:auto_recently_played

Conversation

@hazemelraffiee
Copy link

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:

  • New RecentQariManager to persist recently played entries via SharedPreferences
  • BrowsableSurahBuilder now returns a "Recently Played" folder at root when history exists
  • Recent items show the qari name as subtitle for context
  • Service extends MediaLibraryService (was MediaSessionService) and accepts subscriptions so notifyChildrenChanged properly refreshes the browse tree
  • PlayerEventListener records plays and notifies the browse tree on track transitions

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.
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

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.
Copy link
Contributor

@ahmedre ahmedre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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.

2 participants