diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index c1eb857d5..e848915cf 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -81,6 +81,12 @@ android:key="prefPauseForFocusLoss" android:summary="@string/pref_pausePlaybackForFocusLoss_sum" android:title="@string/pref_pausePlaybackForFocusLoss_title" /> + 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 bfc0cfb61..76f72e69b 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 @@ -60,6 +60,7 @@ public class UserPreferences implements private static final String PREF_PLAYBACK_SPEED = "prefPlaybackSpeed"; private static final String PREF_PLAYBACK_SPEED_ARRAY = "prefPlaybackSpeedArray"; public static final String PREF_PAUSE_PLAYBACK_FOR_FOCUS_LOSS = "prefPauseForFocusLoss"; + public static final String PREF_RESUME_AFTER_CALL = "prefResumeAfterCall"; private static final String PREF_FAST_FORWARD_SECS = "prefFastForwardSecs"; private static final String PREF_REWIND_SECS = "prefRewindSecs"; private static final String PREF_EXPANDED_NOTIFICATION = "prefExpandNotify"; @@ -98,6 +99,7 @@ public class UserPreferences implements private String playbackSpeed; private String[] playbackSpeedArray; private boolean pauseForFocusLoss; + private boolean resumeAfterCall; private int fastForwardSecs; private int rewindSecs; private boolean isFreshInstall; @@ -164,6 +166,7 @@ public class UserPreferences implements playbackSpeedArray = readPlaybackSpeedArray(sp.getString( PREF_PLAYBACK_SPEED_ARRAY, null)); pauseForFocusLoss = sp.getBoolean(PREF_PAUSE_PLAYBACK_FOR_FOCUS_LOSS, false); + resumeAfterCall = sp.getBoolean(PREF_RESUME_AFTER_CALL, true); fastForwardSecs = sp.getInt(PREF_FAST_FORWARD_SECS, 30); rewindSecs = sp.getInt(PREF_REWIND_SECS, 30); if (sp.getBoolean(PREF_EXPANDED_NOTIFICATION, false)) { @@ -393,6 +396,11 @@ public class UserPreferences implements return instance.pauseForFocusLoss; } + public static boolean shouldResumeAfterCall() { + instanceAvailable();; + return instance.resumeAfterCall; + } + public static boolean isFreshInstall() { instanceAvailable(); return instance.isFreshInstall; @@ -454,6 +462,8 @@ public class UserPreferences implements PREF_PLAYBACK_SPEED_ARRAY, null)); } else if (key.equals(PREF_PAUSE_PLAYBACK_FOR_FOCUS_LOSS)) { pauseForFocusLoss = sp.getBoolean(PREF_PAUSE_PLAYBACK_FOR_FOCUS_LOSS, false); + } else if (key.equals(PREF_RESUME_AFTER_CALL)) { + resumeAfterCall = sp.getBoolean(PREF_RESUME_AFTER_CALL, false); } else if (key.equals(PREF_FAST_FORWARD_SECS)) { fastForwardSecs = sp.getInt(PREF_FAST_FORWARD_SECS, 30); } else if (key.equals(PREF_REWIND_SECS)) { diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackServiceMediaPlayer.java b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackServiceMediaPlayer.java index 448ab05b9..243ee78e4 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackServiceMediaPlayer.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackServiceMediaPlayer.java @@ -40,7 +40,7 @@ import de.danoeh.antennapod.core.util.playback.VideoPlayer; * Manages the MediaPlayer object of the PlaybackService. */ public class PlaybackServiceMediaPlayer { - public static final String TAG = "PlaybackServiceMediaPlayer"; + public static final String TAG = "PlaybackSvcMediaPlayer"; /** * Return value of some PSMP methods if the method call failed. @@ -799,10 +799,10 @@ public class PlaybackServiceMediaPlayer { // If there is an incoming call, playback should be paused permanently TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); final int callState = (tm != null) ? tm.getCallState() : 0; - Log.d(TAG, "Call state: " + callState); Log.i(TAG, "Call state:" + callState); - if (focusChange == AudioManager.AUDIOFOCUS_LOSS || callState != TelephonyManager.CALL_STATE_IDLE) { + if (focusChange == AudioManager.AUDIOFOCUS_LOSS || + (!UserPreferences.shouldResumeAfterCall() && callState != TelephonyManager.CALL_STATE_IDLE)) { Log.d(TAG, "Lost audio focus"); pause(true, false); callback.shouldStop(); diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index 3421d3c52..b957adc45 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -379,6 +379,8 @@ Choose default folder Pause playback instead of lowering volume when another app wants to play sounds Pause for interruptions + Resume playback after a phone call completes + Resume after call Subscribe