summaryrefslogtreecommitdiff
path: root/core/src/main/java/de
diff options
context:
space:
mode:
authorTom Hennen <TomHennen@users.noreply.github.com>2016-04-04 19:20:14 -0400
committerTom Hennen <TomHennen@users.noreply.github.com>2016-04-04 19:20:14 -0400
commitab88df91bac8e58343933aba50fcad545a60d096 (patch)
treeab9117992294ef0da01fe805a1a078c1664c12e4 /core/src/main/java/de
parente75ab9c1fa18817761491660819c7515cf8cbc36 (diff)
parente3408565dcc15cd97548b664773bc684dca4edeb (diff)
downloadAntennaPod-ab88df91bac8e58343933aba50fcad545a60d096.zip
Merge pull request #1843 from saqura/develop
Optionally show rewind/forward buttons on the lockscreen
Diffstat (limited to 'core/src/main/java/de')
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java51
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java12
2 files changed, 59 insertions, 4 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 aee70f7d4..569dfd2c4 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
@@ -52,6 +52,7 @@ public class UserPreferences {
public static final String PREF_DRAWER_FEED_COUNTER = "prefDrawerFeedIndicator";
public static final String PREF_EXPANDED_NOTIFICATION = "prefExpandNotify";
public static final String PREF_PERSISTENT_NOTIFICATION = "prefPersistNotify";
+ public static final String PREF_COMPACT_NOTIFICATION_BUTTONS = "prefCompactNotificationButtons";
public static final String PREF_LOCKSCREEN_BACKGROUND = "prefLockscreenBackground";
public static final String PREF_SHOW_DOWNLOAD_REPORT = "prefShowDownloadReport";
@@ -115,6 +116,9 @@ public class UserPreferences {
public static final int EPISODE_CLEANUP_DEFAULT = 0;
// Constants
+ private static final int NOTIFICATION_BUTTON_REWIND = 0;
+ private static final int NOTIFICATION_BUTTON_FAST_FORWARD = 1;
+ private static final int NOTIFICATION_BUTTON_SKIP = 2;
private static int EPISODE_CACHE_SIZE_UNLIMITED = -1;
public static int FEED_ORDER_COUNTER = 0;
public static int FEED_ORDER_ALPHABETICAL = 1;
@@ -165,6 +169,42 @@ public class UserPreferences {
return new ArrayList<>(Arrays.asList(TextUtils.split(hiddenItems, ",")));
}
+ public static List<Integer> getCompactNotificationButtons() {
+ String[] buttons = TextUtils.split(
+ prefs.getString(PREF_COMPACT_NOTIFICATION_BUTTONS,
+ String.valueOf(NOTIFICATION_BUTTON_SKIP)),
+ ",");
+ List<Integer> notificationButtons = new ArrayList<>();
+ for (int i=0; i<buttons.length; i++) {
+ notificationButtons.add(Integer.parseInt(buttons[i]));
+ }
+ return notificationButtons;
+ }
+
+ /**
+ * Helper function to return whether the specified button should be shown on compact
+ * notifications.
+ *
+ * @param buttonId Either NOTIFICATION_BUTTON_REWIND, NOTIFICATION_BUTTON_FAST_FORWARD or
+ * NOTIFICATION_BUTTON_SKIP.
+ * @return {@code true} if button should be shown, {@code false} otherwise
+ */
+ private static boolean showButtonOnCompactNotification(int buttonId) {
+ return getCompactNotificationButtons().contains(buttonId);
+ }
+
+ public static boolean showRewindOnCompactNotification() {
+ return showButtonOnCompactNotification(NOTIFICATION_BUTTON_REWIND);
+ }
+
+ public static boolean showFastForwardOnCompactNotification() {
+ return showButtonOnCompactNotification(NOTIFICATION_BUTTON_FAST_FORWARD);
+ }
+
+ public static boolean showSkipOnCompactNotification() {
+ return showButtonOnCompactNotification(NOTIFICATION_BUTTON_SKIP);
+ }
+
public static int getFeedOrder() {
String value = prefs.getString(PREF_DRAWER_FEED_ORDER, "0");
return Integer.parseInt(value);
@@ -198,9 +238,9 @@ public class UserPreferences {
}
/**
- * Returns true if notifications are persistent
+ * Returns true if the lockscreen background should be set to the current episode's image
*
- * @return {@code true} if notifications are persistent, {@code false} otherwise
+ * @return {@code true} if the lockscreen background should be set, {@code false} otherwise
*/
public static boolean setLockscreenBackground() {
return prefs.getBoolean(PREF_LOCKSCREEN_BACKGROUND, true);
@@ -512,6 +552,13 @@ public class UserPreferences {
.apply();
}
+ public static void setCompactNotificationButtons(List<Integer> items) {
+ String str = TextUtils.join(",", items);
+ prefs.edit()
+ .putString(PREF_COMPACT_NOTIFICATION_BUTTONS, str)
+ .apply();
+ }
+
public static void setQueueLocked(boolean locked) {
prefs.edit()
.putBoolean(PREF_QUEUE_LOCKED, locked)
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..edea3962f 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
@@ -858,7 +858,6 @@ public class PlaybackService extends Service {
.setPriority(UserPreferences.getNotifyPriority()); // set notification priority
IntList compactActionList = new IntList();
-
int numActions = 0; // we start and 0 and then increment by 1 for each call to addAction
// always let them rewind
@@ -867,6 +866,9 @@ public class PlaybackService extends Service {
notificationBuilder.addAction(android.R.drawable.ic_media_rew,
getString(R.string.rewind_label),
rewindButtonPendingIntent);
+ if(UserPreferences.showRewindOnCompactNotification()) {
+ compactActionList.add(numActions);
+ }
numActions++;
if (playerStatus == PlayerStatus.PLAYING) {
@@ -891,6 +893,9 @@ public class PlaybackService extends Service {
notificationBuilder.addAction(android.R.drawable.ic_media_ff,
getString(R.string.fast_forward_label),
ffButtonPendingIntent);
+ if(UserPreferences.showFastForwardOnCompactNotification()) {
+ compactActionList.add(numActions);
+ }
numActions++;
if (UserPreferences.isFollowQueue()) {
@@ -899,7 +904,10 @@ public class PlaybackService extends Service {
notificationBuilder.addAction(android.R.drawable.ic_media_next,
getString(R.string.skip_episode_label),
skipButtonPendingIntent);
- compactActionList.add(numActions++);
+ if(UserPreferences.showSkipOnCompactNotification()) {
+ compactActionList.add(numActions);
+ }
+ numActions++;
}
PendingIntent stopButtonPendingIntent = getPendingIntentForMediaAction(