diff options
author | Tom Hennen <TomHennen@users.noreply.github.com> | 2015-05-08 17:46:15 -0400 |
---|---|---|
committer | Tom Hennen <TomHennen@users.noreply.github.com> | 2015-05-08 17:46:15 -0400 |
commit | 11a66f451ab76b1ef5c45f12c6ed7100040b9084 (patch) | |
tree | f5e4fc63b4c2b06dc91b4893ea2ff6ddf07a8108 | |
parent | b32fa4ec71343aa443e01c5e5c3526b387ccefc5 (diff) | |
parent | 1725966bc4f7c4e20ad88d63f563954db98f0036 (diff) | |
download | AntennaPod-11a66f451ab76b1ef5c45f12c6ed7100040b9084.zip |
Merge pull request #790 from TomHennen/resume_after_call_753
Optionally resume playback after call
4 files changed, 21 insertions, 3 deletions
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" /> + <CheckBoxPreference + android:defaultValue="true" + android:enabled="true" + android:key="prefResumeAfterCall" + android:summary="@string/pref_resumeAfterCall_sum" + android:title="@string/pref_resumeAfterCall_title"/> </PreferenceCategory> <PreferenceCategory android:title="@string/network_pref"> 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..43a189bb9 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, true); } 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 f01d60f22..14222be56 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -385,6 +385,8 @@ <string name="set_to_default_folder">Choose default folder</string> <string name="pref_pausePlaybackForFocusLoss_sum">Pause playback instead of lowering volume when another app wants to play sounds</string> <string name="pref_pausePlaybackForFocusLoss_title">Pause for interruptions</string> + <string name="pref_resumeAfterCall_sum">Resume playback after a phone call completes</string> + <string name="pref_resumeAfterCall_title">Resume after call</string> <!-- Online feed view --> <string name="subscribe_label">Subscribe</string> |