Merge branch 'pause-on-interrupt' of git://github.com/TomHennen/AntennaPod into TomHennen-pause-on-interrupt
This commit is contained in:
commit
088878fcfd
@ -309,9 +309,11 @@
|
|||||||
<string name="folder_not_empty_dialog_title">Folder is not empty</string>
|
<string name="folder_not_empty_dialog_title">Folder is not empty</string>
|
||||||
<string name="folder_not_empty_dialog_msg">The folder you have selected is not empty. Media downloads and other files will be placed directly in this folder. Continue anyway?</string>
|
<string name="folder_not_empty_dialog_msg">The folder you have selected is not empty. Media downloads and other files will be placed directly in this folder. Continue anyway?</string>
|
||||||
<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_title">Pause for interruptions</string>
|
||||||
|
|
||||||
<!-- Online feed view -->
|
<!-- Online feed view -->
|
||||||
<string name="subscribe_label">Subscribe</string>
|
<string name="subscribe_label">Subscribe</string>
|
||||||
<string name="subscribed_label">Subscribed</string>
|
<string name="subscribed_label">Subscribed</string>
|
||||||
<string name="downloading_label">Downloading...</string>
|
<string name="downloading_label">Downloading...</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -31,6 +31,13 @@
|
|||||||
android:key="prefPlaybackSpeedLauncher"
|
android:key="prefPlaybackSpeedLauncher"
|
||||||
android:summary="@string/pref_playback_speed_sum"
|
android:summary="@string/pref_playback_speed_sum"
|
||||||
android:title="@string/pref_playback_speed_title" />
|
android:title="@string/pref_playback_speed_title" />
|
||||||
|
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:enabled="true"
|
||||||
|
android:key="prefPauseForFocusLoss"
|
||||||
|
android:summary="@string/pref_pausePlaybackForFocusLoss_sum"
|
||||||
|
android:title="@string/pref_pausePlaybackForFocusLoss_title" />
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
<PreferenceCategory android:title="@string/network_pref">
|
<PreferenceCategory android:title="@string/network_pref">
|
||||||
<ListPreference
|
<ListPreference
|
||||||
@ -127,4 +134,4 @@
|
|||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
@ -48,6 +48,7 @@ public class UserPreferences implements
|
|||||||
public static final String PREF_EPISODE_CACHE_SIZE = "prefEpisodeCacheSize";
|
public static final String PREF_EPISODE_CACHE_SIZE = "prefEpisodeCacheSize";
|
||||||
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";
|
||||||
|
|
||||||
private static int EPISODE_CACHE_SIZE_UNLIMITED = -1;
|
private static int EPISODE_CACHE_SIZE_UNLIMITED = -1;
|
||||||
|
|
||||||
@ -69,6 +70,7 @@ public class UserPreferences implements
|
|||||||
private int episodeCacheSize;
|
private int episodeCacheSize;
|
||||||
private String playbackSpeed;
|
private String playbackSpeed;
|
||||||
private String[] playbackSpeedArray;
|
private String[] playbackSpeedArray;
|
||||||
|
private boolean pauseForFocusLoss;
|
||||||
|
|
||||||
private UserPreferences(Context context) {
|
private UserPreferences(Context context) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
@ -121,6 +123,7 @@ public class UserPreferences implements
|
|||||||
playbackSpeed = sp.getString(PREF_PLAYBACK_SPEED, "1.0");
|
playbackSpeed = sp.getString(PREF_PLAYBACK_SPEED, "1.0");
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int readThemeValue(String valueFromPrefs) {
|
private int readThemeValue(String valueFromPrefs) {
|
||||||
@ -264,6 +267,11 @@ public class UserPreferences implements
|
|||||||
instanceAvailable();
|
instanceAvailable();
|
||||||
return instance.enableAutodownload;
|
return instance.enableAutodownload;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean shouldPauseForFocusLoss() {
|
||||||
|
instanceAvailable();
|
||||||
|
return instance.pauseForFocusLoss;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSharedPreferenceChanged(SharedPreferences sp, String key) {
|
public void onSharedPreferenceChanged(SharedPreferences sp, String key) {
|
||||||
@ -309,6 +317,8 @@ public class UserPreferences implements
|
|||||||
} else if (key.equals(PREF_PLAYBACK_SPEED_ARRAY)) {
|
} else if (key.equals(PREF_PLAYBACK_SPEED_ARRAY)) {
|
||||||
playbackSpeedArray = readPlaybackSpeedArray(sp.getString(
|
playbackSpeedArray = readPlaybackSpeedArray(sp.getString(
|
||||||
PREF_PLAYBACK_SPEED_ARRAY, null));
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -381,11 +381,18 @@ public class PlaybackService extends Service {
|
|||||||
break;
|
break;
|
||||||
case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK:
|
case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK:
|
||||||
if (status == PlayerStatus.PLAYING) {
|
if (status == PlayerStatus.PLAYING) {
|
||||||
if (AppConfig.DEBUG)
|
if (!UserPreferences.shouldPauseForFocusLoss()) {
|
||||||
Log.d(TAG, "Lost audio focus temporarily. Ducking...");
|
if (AppConfig.DEBUG)
|
||||||
audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC,
|
Log.d(TAG, "Lost audio focus temporarily. Ducking...");
|
||||||
AudioManager.ADJUST_LOWER, 0);
|
audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC,
|
||||||
pausedBecauseOfTransientAudiofocusLoss = true;
|
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;
|
break;
|
||||||
case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT:
|
case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT:
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 643cc2a1afd4f849d5a33f014f877f7d7c10b2db
|
Subproject commit c56bf97269d5dc90df1c428fd18df0e7619eff0e
|
Loading…
x
Reference in New Issue
Block a user