feat(ui): add a Resume playback launcher shortcut - #511
Open
alltechdev wants to merge 3 commits into
Open
Conversation
Long-pressing the app icon now offers a Resume playback shortcut that continues whatever was last playing. It fires a new RESUME action handled in MainActivity: the persistent queue already restores paused on launch, so the shortcut waits for the restored item to land (cold start restores asynchronously) and then plays. If nothing was saved (Persistent Queue disabled or nothing ever played) it shows a brief "Nothing to resume" toast instead of doing nothing. Mirrors the existing search and library shortcuts.
…bug builds The debug source set carried its own copy of shortcuts.xml (search + library only), which shadows the main resource in debug builds, so the Resume shortcut added to the main file never appeared when testing a debug APK. The override was byte-identical to the old main and there is no debug applicationId suffix, so it was pure redundancy. Delete it so both build types use the single main source.
The Resume shortcut opened the app to start playback. A launcher shortcut can only launch an Activity, so route it through a no-display trampoline (ResumePlaybackActivity) that forwards a resume action to MusicService and finishes, resuming in the background without any UI - the same mechanism the widget's play control uses. MusicService handles the action in onStartCommand: the persistent queue restores asynchronously on a cold start (playQueue loads its items off the main thread and pins playWhenReady=false), so wait for the queue to land and leave STATE_IDLE - meaning playQueue's setup is done and can no longer re-pause - before playing, instead of reading a still-empty player and firing a false "nothing to resume". Genuinely nothing to restore (Persistent Queue off / never played) times out into a brief toast. Drops the earlier MainActivity-based handling.
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.
Fixes #508.
What
Adds a Resume playback launcher shortcut: long-press the app icon and pick Resume playback to continue whatever was last playing. It resumes in the background - the app UI does not open.
How
shortcuts.xml(iconshortcut_resume, labelresume_playback), mirroring the existing search/library shortcuts.ResumePlaybackActivity(Theme.NoDisplay, excluded from recents) that forwards a resume action toMusicServiceand finishes immediately - no window. This reuses the exact background mechanism the home-screen widget's play control uses (startService->MusicService.onStartCommand).MusicServicehandlesACTION_RESUME_PLAYBACK: the persistent queue restores asynchronously on a cold start (playQueueloads items off the main thread, then pinsplayWhenReady=false), so the handler waits for the queue to land and leaveSTATE_IDLE- which meansplayQueuehas finished its setup and can no longer re-pause - before playing, rather than reading a still-empty player. Media3 promotes the service to the foreground once playback starts.Testing
:app:assembleDebugbuilds;scripts/ui-audit.shandscripts/check-dead-resources.shgreen (new drawable/strings referenced).