Optionally resume playback after call.
Defaults to true. fixes AntennaPod/AntennaPod#753
This commit is contained in:
parent
cd4bd0e37d
commit
db0ce285a3
|
@ -81,6 +81,12 @@
|
||||||
android:key="prefPauseForFocusLoss"
|
android:key="prefPauseForFocusLoss"
|
||||||
android:summary="@string/pref_pausePlaybackForFocusLoss_sum"
|
android:summary="@string/pref_pausePlaybackForFocusLoss_sum"
|
||||||
android:title="@string/pref_pausePlaybackForFocusLoss_title" />
|
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>
|
||||||
<PreferenceCategory android:title="@string/network_pref">
|
<PreferenceCategory android:title="@string/network_pref">
|
||||||
|
|
|
@ -60,6 +60,7 @@ public class UserPreferences implements
|
||||||
private static final String PREF_PLAYBACK_SPEED = "prefPlaybackSpeed";
|
private static final String PREF_PLAYBACK_SPEED = "prefPlaybackSpeed";
|
||||||
private static final String PREF_PLAYBACK_SPEED_ARRAY = "prefPlaybackSpeedArray";
|
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_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_FAST_FORWARD_SECS = "prefFastForwardSecs";
|
||||||
private static final String PREF_REWIND_SECS = "prefRewindSecs";
|
private static final String PREF_REWIND_SECS = "prefRewindSecs";
|
||||||
private static final String PREF_EXPANDED_NOTIFICATION = "prefExpandNotify";
|
private static final String PREF_EXPANDED_NOTIFICATION = "prefExpandNotify";
|
||||||
|
@ -98,6 +99,7 @@ public class UserPreferences implements
|
||||||
private String playbackSpeed;
|
private String playbackSpeed;
|
||||||
private String[] playbackSpeedArray;
|
private String[] playbackSpeedArray;
|
||||||
private boolean pauseForFocusLoss;
|
private boolean pauseForFocusLoss;
|
||||||
|
private boolean resumeAfterCall;
|
||||||
private int fastForwardSecs;
|
private int fastForwardSecs;
|
||||||
private int rewindSecs;
|
private int rewindSecs;
|
||||||
private boolean isFreshInstall;
|
private boolean isFreshInstall;
|
||||||
|
@ -164,6 +166,7 @@ public class UserPreferences implements
|
||||||
playbackSpeedArray = readPlaybackSpeedArray(sp.getString(
|
playbackSpeedArray = readPlaybackSpeedArray(sp.getString(
|
||||||
PREF_PLAYBACK_SPEED_ARRAY, null));
|
PREF_PLAYBACK_SPEED_ARRAY, null));
|
||||||
pauseForFocusLoss = sp.getBoolean(PREF_PAUSE_PLAYBACK_FOR_FOCUS_LOSS, false);
|
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);
|
fastForwardSecs = sp.getInt(PREF_FAST_FORWARD_SECS, 30);
|
||||||
rewindSecs = sp.getInt(PREF_REWIND_SECS, 30);
|
rewindSecs = sp.getInt(PREF_REWIND_SECS, 30);
|
||||||
if (sp.getBoolean(PREF_EXPANDED_NOTIFICATION, false)) {
|
if (sp.getBoolean(PREF_EXPANDED_NOTIFICATION, false)) {
|
||||||
|
@ -393,6 +396,11 @@ public class UserPreferences implements
|
||||||
return instance.pauseForFocusLoss;
|
return instance.pauseForFocusLoss;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean shouldResumeAfterCall() {
|
||||||
|
instanceAvailable();;
|
||||||
|
return instance.resumeAfterCall;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isFreshInstall() {
|
public static boolean isFreshInstall() {
|
||||||
instanceAvailable();
|
instanceAvailable();
|
||||||
return instance.isFreshInstall;
|
return instance.isFreshInstall;
|
||||||
|
@ -454,6 +462,8 @@ public class UserPreferences implements
|
||||||
PREF_PLAYBACK_SPEED_ARRAY, null));
|
PREF_PLAYBACK_SPEED_ARRAY, null));
|
||||||
} else if (key.equals(PREF_PAUSE_PLAYBACK_FOR_FOCUS_LOSS)) {
|
} else if (key.equals(PREF_PAUSE_PLAYBACK_FOR_FOCUS_LOSS)) {
|
||||||
pauseForFocusLoss = sp.getBoolean(PREF_PAUSE_PLAYBACK_FOR_FOCUS_LOSS, false);
|
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)) {
|
} else if (key.equals(PREF_FAST_FORWARD_SECS)) {
|
||||||
fastForwardSecs = sp.getInt(PREF_FAST_FORWARD_SECS, 30);
|
fastForwardSecs = sp.getInt(PREF_FAST_FORWARD_SECS, 30);
|
||||||
} else if (key.equals(PREF_REWIND_SECS)) {
|
} else if (key.equals(PREF_REWIND_SECS)) {
|
||||||
|
|
|
@ -40,7 +40,7 @@ import de.danoeh.antennapod.core.util.playback.VideoPlayer;
|
||||||
* Manages the MediaPlayer object of the PlaybackService.
|
* Manages the MediaPlayer object of the PlaybackService.
|
||||||
*/
|
*/
|
||||||
public class PlaybackServiceMediaPlayer {
|
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.
|
* 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
|
// If there is an incoming call, playback should be paused permanently
|
||||||
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||||
final int callState = (tm != null) ? tm.getCallState() : 0;
|
final int callState = (tm != null) ? tm.getCallState() : 0;
|
||||||
Log.d(TAG, "Call state: " + callState);
|
|
||||||
Log.i(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");
|
Log.d(TAG, "Lost audio focus");
|
||||||
pause(true, false);
|
pause(true, false);
|
||||||
callback.shouldStop();
|
callback.shouldStop();
|
||||||
|
|
|
@ -379,6 +379,8 @@
|
||||||
<string name="set_to_default_folder">Choose default folder</string>
|
<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_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_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 -->
|
<!-- Online feed view -->
|
||||||
<string name="subscribe_label">Subscribe</string>
|
<string name="subscribe_label">Subscribe</string>
|
||||||
|
|
Loading…
Reference in New Issue