Commit 03d39953 authored by Nicolas Pomepuy's avatar Nicolas Pomepuy

Persist audio time mode upon orientation change and app restart

Fixes #1602
parent 3ecff4d7
Pipeline #55575 passed with stage
in 3 minutes and 17 seconds
...@@ -55,6 +55,7 @@ const val LIST_TITLE_ELLIPSIZE = "list_title_ellipsize" ...@@ -55,6 +55,7 @@ const val LIST_TITLE_ELLIPSIZE = "list_title_ellipsize"
// AudioPlayer // AudioPlayer
const val SHOW_REMAINING_TIME = "show_remaining_time"
const val PREF_PLAYLIST_TIPS_SHOWN = "playlist_tips_shown" const val PREF_PLAYLIST_TIPS_SHOWN = "playlist_tips_shown"
const val PREF_AUDIOPLAYER_TIPS_SHOWN = "audioplayer_tips_shown" const val PREF_AUDIOPLAYER_TIPS_SHOWN = "audioplayer_tips_shown"
const val KEY_MEDIALIBRARY_SCAN = "ml_scan" const val KEY_MEDIALIBRARY_SCAN = "ml_scan"
......
...@@ -107,6 +107,7 @@ class AudioPlayer : Fragment(), PlaylistAdapter.IPlayer, TextWatcher, IAudioPlay ...@@ -107,6 +107,7 @@ class AudioPlayer : Fragment(), PlaylistAdapter.IPlayer, TextWatcher, IAudioPlay
savedInstanceState?.let { savedInstanceState?.let {
playerState = it.getInt("player_state") playerState = it.getInt("player_state")
wasPlaying = it.getBoolean("was_playing") wasPlaying = it.getBoolean("was_playing")
showRemainingTime = it.getBoolean("show_remaining_time")
} }
playlistAdapter = PlaylistAdapter(this) playlistAdapter = PlaylistAdapter(this)
settings = Settings.getInstance(requireContext()) settings = Settings.getInstance(requireContext())
...@@ -183,6 +184,7 @@ class AudioPlayer : Fragment(), PlaylistAdapter.IPlayer, TextWatcher, IAudioPlay ...@@ -183,6 +184,7 @@ class AudioPlayer : Fragment(), PlaylistAdapter.IPlayer, TextWatcher, IAudioPlay
override fun onResume() { override fun onResume() {
onStateChanged(playerState) onStateChanged(playerState)
showRemainingTime = Settings.getInstance(requireContext()).getBoolean(SHOW_REMAINING_TIME, false)
super.onResume() super.onResume()
} }
...@@ -190,6 +192,7 @@ class AudioPlayer : Fragment(), PlaylistAdapter.IPlayer, TextWatcher, IAudioPlay ...@@ -190,6 +192,7 @@ class AudioPlayer : Fragment(), PlaylistAdapter.IPlayer, TextWatcher, IAudioPlay
super.onSaveInstanceState(outState) super.onSaveInstanceState(outState)
outState.putInt("player_state", playerState) outState.putInt("player_state", playerState)
outState.putBoolean("was_playing", wasPlaying) outState.putBoolean("was_playing", wasPlaying)
outState.putBoolean("show_remaining_time", showRemainingTime)
} }
private val ctxReceiver: CtxActionReceiver = object : CtxActionReceiver { private val ctxReceiver: CtxActionReceiver = object : CtxActionReceiver {
...@@ -338,6 +341,7 @@ class AudioPlayer : Fragment(), PlaylistAdapter.IPlayer, TextWatcher, IAudioPlay ...@@ -338,6 +341,7 @@ class AudioPlayer : Fragment(), PlaylistAdapter.IPlayer, TextWatcher, IAudioPlay
fun onTimeLabelClick(view: View) { fun onTimeLabelClick(view: View) {
showRemainingTime = !showRemainingTime showRemainingTime = !showRemainingTime
Settings.getInstance(requireContext()).edit().putBoolean(SHOW_REMAINING_TIME, showRemainingTime).apply()
playlistModel.progress.value?.let { updateProgress(it) } playlistModel.progress.value?.let { updateProgress(it) }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment