summaryrefslogtreecommitdiff
path: root/core/src/main/java/de/danoeh
diff options
context:
space:
mode:
authorLee Yeong Khang <sindrosa.24@gmail.com>2014-12-20 17:25:52 +0900
committerLee Yeong Khang <sindrosa.24@gmail.com>2014-12-20 17:25:52 +0900
commit282b29eb5d2b27379662854220476d591494265d (patch)
tree51eda8324062d18850daa2bf9469407ccfe3c142 /core/src/main/java/de/danoeh
parente9ed796fd432f8bcd9b41f52c2777b00cadcbed8 (diff)
downloadAntennaPod-282b29eb5d2b27379662854220476d591494265d.zip
Honor User Preference on Persistence notification
commented in https://github.com/danieloeh/AntennaPod/pull/578#issuecomment-67489354 - option disabled notification has only "play/pause" button, hitting pause hides notification - option enabled notification has both "play/pause" button and "close" button, hitting pause does not hide notification
Diffstat (limited to 'core/src/main/java/de/danoeh')
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java32
1 files changed, 25 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 7df4af504..649ca42b8 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
@@ -290,7 +290,11 @@ public class PlaybackService extends Service {
case KeyEvent.KEYCODE_HEADSETHOOK:
case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
if (status == PlayerStatus.PLAYING) {
- mediaPlayer.pause(false, true);
+ if (UserPreferences.isPersistNotify()) {
+ mediaPlayer.pause(false, true);
+ } else {
+ mediaPlayer.pause(true, true);
+ }
} else if (status == PlayerStatus.PAUSED || status == PlayerStatus.PREPARED) {
mediaPlayer.resume();
} else if (status == PlayerStatus.PREPARING) {
@@ -312,6 +316,12 @@ public class PlaybackService extends Service {
if (status == PlayerStatus.PLAYING) {
mediaPlayer.pause(false, true);
}
+ if (UserPreferences.isPersistNotify()) {
+ mediaPlayer.pause(false, true);
+ } else {
+ mediaPlayer.pause(true, true);
+ }
+
break;
case KeyEvent.KEYCODE_MEDIA_NEXT:
case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD:
@@ -402,7 +412,14 @@ public class PlaybackService extends Service {
taskManager.cancelPositionSaver();
saveCurrentPosition(false, 0);
taskManager.cancelWidgetUpdater();
- setupNotification(newInfo);
+ if (UserPreferences.isPersistNotify() && android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
+ // do not remove notification on pause based on user pref and whether android version supports expanded notifications
+ // Change [Play] button to [Pause]
+ setupNotification(newInfo);
+ } else {
+ // remove notifcation on pause
+ stopForeground(true);
+ }
break;
@@ -767,7 +784,7 @@ public class PlaybackService extends Service {
.setLargeIcon(icon)
.setSmallIcon(smallIcon)
.setPriority(UserPreferences.getNotifyPriority()); // set notification priority
- if(newInfo.playerStatus==PlayerStatus.PLAYING){
+ if(newInfo.playerStatus == PlayerStatus.PLAYING){
notificationBuilder.addAction(android.R.drawable.ic_media_pause, //pause action
getString(R.string.pause_label),
pauseButtonPendingIntent);
@@ -776,9 +793,11 @@ public class PlaybackService extends Service {
getString(R.string.play_label),
playButtonPendingIntent);
}
- notificationBuilder.addAction(android.R.drawable.ic_menu_close_clear_cancel, // stop action
- getString(R.string.stop_label),
- stopButtonPendingIntent);
+ if(UserPreferences.isPersistNotify()) {
+ notificationBuilder.addAction(android.R.drawable.ic_menu_close_clear_cancel, // stop action
+ getString(R.string.stop_label),
+ stopButtonPendingIntent);
+ }
notification = notificationBuilder.build();
} else {
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(
@@ -1000,7 +1019,6 @@ public class PlaybackService extends Service {
} else {
mediaPlayer.pause(true, true);
}
- }
}
private BroadcastReceiver shutdownReceiver = new BroadcastReceiver() {