diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/de/danoeh/antennapod/preferences/UserPreferences.java | 10 | ||||
-rw-r--r-- | src/de/danoeh/antennapod/service/PlaybackService.java | 17 |
2 files changed, 22 insertions, 5 deletions
diff --git a/src/de/danoeh/antennapod/preferences/UserPreferences.java b/src/de/danoeh/antennapod/preferences/UserPreferences.java index f2f35f41d..662db9b17 100644 --- a/src/de/danoeh/antennapod/preferences/UserPreferences.java +++ b/src/de/danoeh/antennapod/preferences/UserPreferences.java @@ -41,6 +41,7 @@ public class UserPreferences implements public static final String PREF_ENABLE_AUTODL_WIFI_FILTER = "prefEnableAutoDownloadWifiFilter"; private static final String PREF_AUTODL_SELECTED_NETWORKS = "prefAutodownloadSelectedNetworks"; public static final String PREF_EPISODE_CACHE_SIZE = "prefEpisodeCacheSize"; + public static final String PREF_PAUSE_PLAYBACK_FOR_NOTIFICATIONS = "prefPauseForNotifications"; private static int EPISODE_CACHE_SIZE_UNLIMITED = -1; @@ -60,6 +61,7 @@ public class UserPreferences implements private boolean enableAutodownloadWifiFilter; private String[] autodownloadSelectedNetworks; private int episodeCacheSize; + private boolean pauseForNotifications; private UserPreferences(Context context) { this.context = context; @@ -108,6 +110,7 @@ public class UserPreferences implements episodeCacheSize = readEpisodeCacheSize(sp.getString( PREF_EPISODE_CACHE_SIZE, "20")); enableAutodownload = sp.getBoolean(PREF_ENABLE_AUTODL, false); + pauseForNotifications = sp.getBoolean(PREF_PAUSE_PLAYBACK_FOR_NOTIFICATIONS, false); } private int readThemeValue(String valueFromPrefs) { @@ -210,6 +213,11 @@ public class UserPreferences implements instanceAvailable(); return instance.enableAutodownload; } + + public static boolean shouldPauseForNotifications() { + instanceAvailable(); + return instance.pauseForNotifications; + } @Override public void onSharedPreferenceChanged(SharedPreferences sp, String key) { @@ -250,6 +258,8 @@ public class UserPreferences implements PREF_EPISODE_CACHE_SIZE, "20")); } else if (key.equals(PREF_ENABLE_AUTODL)) { enableAutodownload = sp.getBoolean(PREF_ENABLE_AUTODL, false); + } else if (key.equals(PREF_PAUSE_PLAYBACK_FOR_NOTIFICATIONS)) { + pauseForNotifications = sp.getBoolean(PREF_PAUSE_PLAYBACK_FOR_NOTIFICATIONS, false); } } diff --git a/src/de/danoeh/antennapod/service/PlaybackService.java b/src/de/danoeh/antennapod/service/PlaybackService.java index 7c306984c..5e0f6b46e 100644 --- a/src/de/danoeh/antennapod/service/PlaybackService.java +++ b/src/de/danoeh/antennapod/service/PlaybackService.java @@ -353,11 +353,18 @@ public class PlaybackService extends Service { break; case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK: if (status == PlayerStatus.PLAYING) { - if (AppConfig.DEBUG) - Log.d(TAG, "Lost audio focus temporarily. Ducking..."); - audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, - AudioManager.ADJUST_LOWER, 0); - pausedBecauseOfTransientAudiofocusLoss = true; + if (!UserPreferences.shouldPauseForNotifications()) { + if (AppConfig.DEBUG) + Log.d(TAG, "Lost audio focus temporarily. Ducking..."); + audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, + AudioManager.ADJUST_LOWER, 0); + pausedBecauseOfTransientAudiofocusLoss = true; + } else { + if (AppConfig.DEBUG) + Log.d(TAG, "Lost audio focus temporarily. Could duck, but won't, pausing..."); + pause(false, false); + pausedBecauseOfTransientAudiofocusLoss = true; + } } break; case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT: |