diff options
author | Tony Tam <149837+tonytamsf@users.noreply.github.com> | 2023-12-29 08:50:31 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-29 17:50:31 +0100 |
commit | 7508e15ab1a102e3fdc258cf829a622d08baf2e8 (patch) | |
tree | 42457074f9f5dffeefede6802d9605f9713736cb | |
parent | 55f83eb9e13408639043aafa9d2f376fa25c1830 (diff) | |
download | AntennaPod-7508e15ab1a102e3fdc258cf829a622d08baf2e8.zip |
Show currently playing episode in Android Auto (#6816)
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java | 10 | ||||
-rw-r--r-- | ui/i18n/src/main/res/values/strings.xml | 2 |
2 files changed, 9 insertions, 3 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 0423cfa01..3ef2e2214 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 @@ -326,7 +326,8 @@ public class PlaybackService extends MediaBrowserServiceCompat { 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); + Log.d(TAG, "OnGetRoot: Returning BrowserRoot " + R.string.current_playing_episode); + return new BrowserRoot(getResources().getString(R.string.current_playing_episode), extras); } // Name visible in Android Auto @@ -407,6 +408,11 @@ public class PlaybackService extends MediaBrowserServiceCompat { private List<MediaBrowserCompat.MediaItem> loadChildrenSynchronous(@NonNull String parentId) { List<MediaBrowserCompat.MediaItem> mediaItems = new ArrayList<>(); if (parentId.equals(getResources().getString(R.string.app_name))) { + long currentlyPlaying = PlaybackPreferences.getCurrentPlayerStatus(); + if (currentlyPlaying == PlaybackPreferences.PLAYER_STATUS_PLAYING + || currentlyPlaying == PlaybackPreferences.PLAYER_STATUS_PAUSED) { + mediaItems.add(createBrowsableMediaItem(R.string.current_playing_episode, R.drawable.ic_play_48dp, 1)); + } mediaItems.add(createBrowsableMediaItem(R.string.queue_label, R.drawable.ic_playlist_play_black, DBReader.getTotalEpisodeCount(new FeedItemFilter(FeedItemFilter.QUEUED)))); mediaItems.add(createBrowsableMediaItem(R.string.downloads_label, R.drawable.ic_download_black, @@ -433,7 +439,7 @@ public class PlaybackService extends MediaBrowserServiceCompat { long feedId = Long.parseLong(parentId.split(":")[1]); Feed feed = DBReader.getFeed(feedId); feedItems = DBReader.getFeedItemList(feed, FeedItemFilter.unfiltered(), feed.getSortOrder()); - } else if (parentId.equals(getString(R.string.recently_played_episodes))) { + } else if (parentId.equals(getString(R.string.current_playing_episode))) { Playable playable = PlaybackPreferences.createInstanceFromPreferences(this); if (playable instanceof FeedMedia) { feedItems = Collections.singletonList(((FeedMedia) playable).getItem()); diff --git a/ui/i18n/src/main/res/values/strings.xml b/ui/i18n/src/main/res/values/strings.xml index 467570ba5..9b5ddd07e 100644 --- a/ui/i18n/src/main/res/values/strings.xml +++ b/ui/i18n/src/main/res/values/strings.xml @@ -26,7 +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> + <string name="current_playing_episode">Current</string> <string name="antennapod_echo" translatable="false">AntennaPod Echo</string> <string name="antennapod_echo_year" translatable="false">AntennaPod Echo %d</string> |