From d9151351b02e632b55d34f1fac6bada08c59731c Mon Sep 17 00:00:00 2001 From: Tony Tam Date: Sat, 21 Nov 2020 18:20:17 -0800 Subject: [PATCH 1/3] pause button for autos --- .../antennapod/core/service/playback/PlaybackService.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 92fd9cb55..ab989c44b 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 @@ -149,7 +149,7 @@ public class PlaybackService extends MediaBrowserServiceCompat { public static final String ACTION_PAUSE_PLAY_CURRENT_EPISODE = "action.de.danoeh.antennapod.core.service.pausePlayCurrentEpisode"; /** - * Custom action used by Android Wear + * Custom action used by Android Wear, Android Auto */ private static final String CUSTOM_ACTION_FAST_FORWARD = "action.de.danoeh.antennapod.core.service.fastForward"; private static final String CUSTOM_ACTION_REWIND = "action.de.danoeh.antennapod.core.service.rewind"; @@ -1204,6 +1204,7 @@ public class PlaybackService extends MediaBrowserServiceCompat { sessionState.setState(state, getCurrentPosition(), getCurrentPlaybackSpeed()); long capabilities = PlaybackStateCompat.ACTION_PLAY_PAUSE | PlaybackStateCompat.ACTION_REWIND + | PlaybackStateCompat.ACTION_PAUSE | PlaybackStateCompat.ACTION_FAST_FORWARD | PlaybackStateCompat.ACTION_SKIP_TO_NEXT | PlaybackStateCompat.ACTION_SEEK_TO; From aebc62d1364c6c4578f6b43802dbad7b01eee409 Mon Sep 17 00:00:00 2001 From: Tony Tam Date: Sun, 22 Nov 2020 18:20:10 -0800 Subject: [PATCH 2/3] only show the play button for non-car mode, since that is taken care of already --- .../core/service/playback/PlaybackService.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 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 ab989c44b..3e4fccba5 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 @@ -1224,6 +1224,7 @@ public class PlaybackService extends MediaBrowserServiceCompat { } UiModeManager uiModeManager = (UiModeManager) getApplicationContext().getSystemService(Context.UI_MODE_SERVICE); + // if (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_CAR) { sessionState.addCustomAction( new PlaybackStateCompat.CustomAction.Builder( @@ -1235,17 +1236,20 @@ public class PlaybackService extends MediaBrowserServiceCompat { CUSTOM_ACTION_FAST_FORWARD, getString(R.string.fast_forward_label), R.drawable.ic_notification_fast_forward) .build()); + } else { + // This would give the PIP of videos a play button + capabilities = capabilities | PlaybackStateCompat.ACTION_PLAY; + if (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_WATCH) { + flavorHelper.sessionStateAddActionForWear(sessionState, + CUSTOM_ACTION_REWIND, getString(R.string.rewind_label), android.R.drawable.ic_media_rew); + flavorHelper.sessionStateAddActionForWear(sessionState, + CUSTOM_ACTION_FAST_FORWARD, getString(R.string.fast_forward_label), android.R.drawable.ic_media_ff); + flavorHelper.mediaSessionSetExtraForWear(mediaSession); + } } sessionState.setActions(capabilities); - flavorHelper.sessionStateAddActionForWear(sessionState, - CUSTOM_ACTION_REWIND, getString(R.string.rewind_label), android.R.drawable.ic_media_rew); - flavorHelper.sessionStateAddActionForWear(sessionState, - CUSTOM_ACTION_FAST_FORWARD, getString(R.string.fast_forward_label), android.R.drawable.ic_media_ff); - - flavorHelper.mediaSessionSetExtraForWear(mediaSession); - mediaSession.setPlaybackState(sessionState.build()); } From ed47e27baae481ff0faf76ff972360211c329799 Mon Sep 17 00:00:00 2001 From: Tony Tam Date: Sun, 22 Nov 2020 18:25:33 -0800 Subject: [PATCH 3/3] line > 120 --- .../core/service/playback/PlaybackService.java | 9 ++++++--- 1 file changed, 6 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 3e4fccba5..f59fc8046 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 @@ -1224,7 +1224,6 @@ public class PlaybackService extends MediaBrowserServiceCompat { } UiModeManager uiModeManager = (UiModeManager) getApplicationContext().getSystemService(Context.UI_MODE_SERVICE); - // if (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_CAR) { sessionState.addCustomAction( new PlaybackStateCompat.CustomAction.Builder( @@ -1241,9 +1240,13 @@ public class PlaybackService extends MediaBrowserServiceCompat { capabilities = capabilities | PlaybackStateCompat.ACTION_PLAY; if (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_WATCH) { flavorHelper.sessionStateAddActionForWear(sessionState, - CUSTOM_ACTION_REWIND, getString(R.string.rewind_label), android.R.drawable.ic_media_rew); + CUSTOM_ACTION_REWIND, + getString(R.string.rewind_label), + android.R.drawable.ic_media_rew); flavorHelper.sessionStateAddActionForWear(sessionState, - CUSTOM_ACTION_FAST_FORWARD, getString(R.string.fast_forward_label), android.R.drawable.ic_media_ff); + CUSTOM_ACTION_FAST_FORWARD, + getString(R.string.fast_forward_label), + android.R.drawable.ic_media_ff); flavorHelper.mediaSessionSetExtraForWear(mediaSession); } }