Add setting for continuing playback when app is closed
This commit is contained in:
@@ -60,6 +60,8 @@ interface PlaybackSettings : Settings<PlaybackSettings.Listener> {
|
|||||||
val pauseOnRepeat: Boolean
|
val pauseOnRepeat: Boolean
|
||||||
/** Whether to maintain the play/pause state when skipping or editing the queue */
|
/** Whether to maintain the play/pause state when skipping or editing the queue */
|
||||||
val rememberPause: Boolean
|
val rememberPause: Boolean
|
||||||
|
/** Whether playback should continue when the app is dismissed from recents. */
|
||||||
|
val continueWhenAppClosed: Boolean
|
||||||
|
|
||||||
interface Listener {
|
interface Listener {
|
||||||
/** Called when one of the ReplayGain configurations have changed. */
|
/** Called when one of the ReplayGain configurations have changed. */
|
||||||
@@ -134,6 +136,11 @@ class PlaybackSettingsImpl @Inject constructor(@ApplicationContext context: Cont
|
|||||||
override val rememberPause: Boolean
|
override val rememberPause: Boolean
|
||||||
get() = sharedPreferences.getBoolean(getString(R.string.set_key_remember_pause), false)
|
get() = sharedPreferences.getBoolean(getString(R.string.set_key_remember_pause), false)
|
||||||
|
|
||||||
|
override val continueWhenAppClosed: Boolean
|
||||||
|
get() =
|
||||||
|
sharedPreferences.getBoolean(
|
||||||
|
getString(R.string.set_key_continue_app_closed), true)
|
||||||
|
|
||||||
override fun migrate() {
|
override fun migrate() {
|
||||||
// MusicMode was converted to PlaySong in 3.2.0
|
// MusicMode was converted to PlaySong in 3.2.0
|
||||||
fun Int.migrateMusicMode() =
|
fun Int.migrateMusicMode() =
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import org.oxycblt.auxio.AuxioService.Companion.INTENT_KEY_START_ID
|
|||||||
import org.oxycblt.auxio.ForegroundListener
|
import org.oxycblt.auxio.ForegroundListener
|
||||||
import org.oxycblt.auxio.ForegroundServiceNotification
|
import org.oxycblt.auxio.ForegroundServiceNotification
|
||||||
import org.oxycblt.auxio.IntegerTable
|
import org.oxycblt.auxio.IntegerTable
|
||||||
|
import org.oxycblt.auxio.playback.PlaybackSettings
|
||||||
import org.oxycblt.auxio.playback.state.DeferredPlayback
|
import org.oxycblt.auxio.playback.state.DeferredPlayback
|
||||||
import org.oxycblt.auxio.playback.state.PlaybackStateManager
|
import org.oxycblt.auxio.playback.state.PlaybackStateManager
|
||||||
import org.oxycblt.auxio.widgets.WidgetComponent
|
import org.oxycblt.auxio.widgets.WidgetComponent
|
||||||
@@ -37,6 +38,7 @@ private constructor(
|
|||||||
context: Context,
|
context: Context,
|
||||||
private val foregroundListener: ForegroundListener,
|
private val foregroundListener: ForegroundListener,
|
||||||
private val playbackManager: PlaybackStateManager,
|
private val playbackManager: PlaybackStateManager,
|
||||||
|
private val playbackSettings: PlaybackSettings,
|
||||||
exoHolderFactory: ExoPlaybackStateHolder.Factory,
|
exoHolderFactory: ExoPlaybackStateHolder.Factory,
|
||||||
sessionHolderFactory: MediaSessionHolder.Factory,
|
sessionHolderFactory: MediaSessionHolder.Factory,
|
||||||
widgetComponentFactory: WidgetComponent.Factory,
|
widgetComponentFactory: WidgetComponent.Factory,
|
||||||
@@ -46,6 +48,7 @@ private constructor(
|
|||||||
@Inject
|
@Inject
|
||||||
constructor(
|
constructor(
|
||||||
private val playbackManager: PlaybackStateManager,
|
private val playbackManager: PlaybackStateManager,
|
||||||
|
private val playbackSettings: PlaybackSettings,
|
||||||
private val exoHolderFactory: ExoPlaybackStateHolder.Factory,
|
private val exoHolderFactory: ExoPlaybackStateHolder.Factory,
|
||||||
private val sessionHolderFactory: MediaSessionHolder.Factory,
|
private val sessionHolderFactory: MediaSessionHolder.Factory,
|
||||||
private val widgetComponentFactory: WidgetComponent.Factory,
|
private val widgetComponentFactory: WidgetComponent.Factory,
|
||||||
@@ -56,6 +59,7 @@ private constructor(
|
|||||||
context,
|
context,
|
||||||
foregroundListener,
|
foregroundListener,
|
||||||
playbackManager,
|
playbackManager,
|
||||||
|
playbackSettings,
|
||||||
exoHolderFactory,
|
exoHolderFactory,
|
||||||
sessionHolderFactory,
|
sessionHolderFactory,
|
||||||
widgetComponentFactory,
|
widgetComponentFactory,
|
||||||
@@ -80,7 +84,7 @@ private constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun handleTaskRemoved() {
|
fun handleTaskRemoved() {
|
||||||
if (!playbackManager.progression.isPlaying) {
|
if (!playbackSettings.continueWhenAppClosed || !playbackManager.progression.isPlaying) {
|
||||||
playbackManager.endSession()
|
playbackManager.endSession()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,6 +40,7 @@
|
|||||||
<string name="set_key_rewind_prev" translatable="false">KEY_PREV_REWIND</string>
|
<string name="set_key_rewind_prev" translatable="false">KEY_PREV_REWIND</string>
|
||||||
<string name="set_key_repeat_pause" translatable="false">KEY_LOOP_PAUSE</string>
|
<string name="set_key_repeat_pause" translatable="false">KEY_LOOP_PAUSE</string>
|
||||||
<string name="set_key_remember_pause" translatable="false">auxio_remember_pause</string>
|
<string name="set_key_remember_pause" translatable="false">auxio_remember_pause</string>
|
||||||
|
<string name="set_key_continue_app_closed" translatable="false">auxio_continue_app_closed</string>
|
||||||
|
|
||||||
<string name="set_key_home_tabs" translatable="false">auxio_home_tabs</string>
|
<string name="set_key_home_tabs" translatable="false">auxio_home_tabs</string>
|
||||||
<string name="set_key_hide_collaborators" translatable="false">auxio_hide_collaborators</string>
|
<string name="set_key_hide_collaborators" translatable="false">auxio_hide_collaborators</string>
|
||||||
|
|||||||
@@ -303,6 +303,8 @@
|
|||||||
<string name="set_repeat_pause_desc">Pause when a song repeats</string>
|
<string name="set_repeat_pause_desc">Pause when a song repeats</string>
|
||||||
<string name="set_remember_pause">Remember pause</string>
|
<string name="set_remember_pause">Remember pause</string>
|
||||||
<string name="set_remember_pause_desc">Remain playing/paused when skipping or editing queue</string>
|
<string name="set_remember_pause_desc">Remain playing/paused when skipping or editing queue</string>
|
||||||
|
<string name="set_continue_app_closed">Continue when app closed</string>
|
||||||
|
<string name="set_continue_app_closed_desc">Continue playback when app is swiped away from recents</string>
|
||||||
<string name="set_replay_gain">Volume normalization</string>
|
<string name="set_replay_gain">Volume normalization</string>
|
||||||
<string name="set_replay_gain_mode">ReplayGain strategy</string>
|
<string name="set_replay_gain_mode">ReplayGain strategy</string>
|
||||||
<string name="set_replay_gain_mode_off">Off</string>
|
<string name="set_replay_gain_mode_off">Off</string>
|
||||||
|
|||||||
@@ -27,6 +27,12 @@
|
|||||||
app:summary="@string/set_remember_pause_desc"
|
app:summary="@string/set_remember_pause_desc"
|
||||||
app:title="@string/set_remember_pause" />
|
app:title="@string/set_remember_pause" />
|
||||||
|
|
||||||
|
<SwitchPreferenceCompat
|
||||||
|
app:defaultValue="true"
|
||||||
|
app:key="@string/set_key_continue_app_closed"
|
||||||
|
app:summary="@string/set_continue_app_closed_desc"
|
||||||
|
app:title="@string/set_continue_app_closed" />
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory android:title="@string/set_replay_gain">
|
<PreferenceCategory android:title="@string/set_replay_gain">
|
||||||
|
|||||||
Reference in New Issue
Block a user