From 13d0a3570b3634da777a791e89008ad7cef5bd29 Mon Sep 17 00:00:00 2001 From: saqura Date: Fri, 1 Apr 2016 18:05:58 +0200 Subject: Optionally show rewind/ff buttons on lockscreen Show additional playback buttons (rewind and fast forward) in the notification on the lockscreen if the option "Expand Notification" is enabled. Fixes #337 Fixes #571 --- .../antennapod/core/preferences/UserPreferences.java | 10 ++++++++++ .../antennapod/core/service/playback/PlaybackService.java | 15 +++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java b/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java index 58caedc3e..222c69a1d 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java +++ b/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java @@ -193,6 +193,16 @@ public class UserPreferences { } } + /** + * Returns true if additional playback buttons should be shown in the notification even when + * on the lockscreen + * + * @return {@code true} if additional playback buttons should be shown, {@code false} otherwise + */ + public static boolean showAdditionalNotificationButtons() { + return prefs.getBoolean(PREF_EXPANDED_NOTIFICATION, false); + } + /** * Returns true if notifications are persistent * 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 729ea9e7a..9b37ce76d 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 @@ -867,7 +867,13 @@ public class PlaybackService extends Service { notificationBuilder.addAction(android.R.drawable.ic_media_rew, getString(R.string.rewind_label), rewindButtonPendingIntent); - numActions++; + if(UserPreferences.showAdditionalNotificationButtons()) { + // always show the rewind button (even on the lockscreen) + compactActionList.add(numActions++); + } else { + numActions++; + } + if (playerStatus == PlayerStatus.PLAYING) { PendingIntent pauseButtonPendingIntent = getPendingIntentForMediaAction( @@ -891,7 +897,12 @@ public class PlaybackService extends Service { notificationBuilder.addAction(android.R.drawable.ic_media_ff, getString(R.string.fast_forward_label), ffButtonPendingIntent); - numActions++; + if(UserPreferences.showAdditionalNotificationButtons()) { + // always show the ff button (even on the lockscreen) + compactActionList.add(numActions++); + } else { + numActions++; + } if (UserPreferences.isFollowQueue()) { PendingIntent skipButtonPendingIntent = getPendingIntentForMediaAction( -- cgit v1.2.3