diff options
author | ByteHamster <ByteHamster@users.noreply.github.com> | 2023-02-25 16:33:11 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-25 16:33:11 +0100 |
commit | 9cd59a67207411d428963de501347444f08989f0 (patch) | |
tree | 1cf11339a502318beb51ab5c405d8a6569e28b03 | |
parent | 2833812238c19d16d464c337adeecc575ff484ba (diff) | |
download | AntennaPod-9cd59a67207411d428963de501347444f08989f0.zip |
Support media resumption (#6350)
This fixes the disappearing media notification after pressing the play button.
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java | 21 | ||||
-rw-r--r-- | ui/i18n/src/main/res/values/strings.xml | 1 |
2 files changed, 17 insertions, 5 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java index 434aa77e7..4f352aa15 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java @@ -316,9 +316,14 @@ public class PlaybackService extends MediaBrowserServiceCompat { public BrowserRoot onGetRoot(@NonNull String clientPackageName, int clientUid, Bundle rootHints) { Log.d(TAG, "OnGetRoot: clientPackageName=" + clientPackageName + "; clientUid=" + clientUid + " ; rootHints=" + rootHints); - return new BrowserRoot( - getResources().getString(R.string.app_name), // Name visible in Android Auto - null); // Bundle of optional extras + if (rootHints != null && rootHints.getBoolean(BrowserRoot.EXTRA_RECENT)) { + Bundle extras = new Bundle(); + extras.putBoolean(BrowserRoot.EXTRA_RECENT, true); + return new BrowserRoot(getResources().getString(R.string.recently_played_episodes), extras); + } + + // Name visible in Android Auto + return new BrowserRoot(getResources().getString(R.string.app_name), null); } private void loadQueueForMediaSession() { @@ -392,8 +397,7 @@ public class PlaybackService extends MediaBrowserServiceCompat { }); } - private List<MediaBrowserCompat.MediaItem> loadChildrenSynchronous(@NonNull String parentId) - throws InterruptedException { + private List<MediaBrowserCompat.MediaItem> loadChildrenSynchronous(@NonNull String parentId) { List<MediaBrowserCompat.MediaItem> mediaItems = new ArrayList<>(); if (parentId.equals(getResources().getString(R.string.app_name))) { mediaItems.add(createBrowsableMediaItem(R.string.queue_label, R.drawable.ic_playlist_play_black, @@ -421,6 +425,13 @@ public class PlaybackService extends MediaBrowserServiceCompat { } else if (parentId.startsWith("FeedId:")) { long feedId = Long.parseLong(parentId.split(":")[1]); feedItems = DBReader.getFeedItemList(DBReader.getFeed(feedId)); + } else if (parentId.equals(getString(R.string.recently_played_episodes))) { + Playable playable = PlaybackPreferences.createInstanceFromPreferences(this); + if (playable instanceof FeedMedia) { + feedItems = Collections.singletonList(((FeedMedia) playable).getItem()); + } else { + return null; + } } else { Log.e(TAG, "Parent ID not found: " + parentId); return null; diff --git a/ui/i18n/src/main/res/values/strings.xml b/ui/i18n/src/main/res/values/strings.xml index 184ceeabd..4943f5a1e 100644 --- a/ui/i18n/src/main/res/values/strings.xml +++ b/ui/i18n/src/main/res/values/strings.xml @@ -26,6 +26,7 @@ <string name="episode_cache_full_message">The episode cache limit has been reached. You can increase the cache size in the Settings.</string> <string name="years_statistics_label">Years</string> <string name="notification_pref_fragment">Notifications</string> + <string name="recently_played_episodes">Recently played episodes</string> <!-- Google Assistant --> <string name="app_action_not_found">\"%1$s\" not found</string> |