[Android] Persist audio time mode upon orientation change and app restart
Nicolas Pomepuy
git at videolan.org
Wed Jan 20 09:54:27 UTC 2021
vlc-android | branch: 3.3.x | Nicolas Pomepuy <nicolas at videolabs.io> | Fri Jan 8 07:24:17 2021 +0100| [c60e57262381fa8397f27c65b220ba1f9165f71a] | committer: Nicolas Pomepuy
Persist audio time mode upon orientation change and app restart
Fixes #1602
(cherry picked from commit 03d399531cb40d5172855e92210e0a89ee037b89)
> https://code.videolan.org/videolan/vlc-android/commit/c60e57262381fa8397f27c65b220ba1f9165f71a
---
application/tools/src/main/java/org/videolan/tools/Settings.kt | 1 +
application/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.kt | 4 ++++
2 files changed, 5 insertions(+)
diff --git a/application/tools/src/main/java/org/videolan/tools/Settings.kt b/application/tools/src/main/java/org/videolan/tools/Settings.kt
index 81a97d6dd..15bb0f730 100644
--- a/application/tools/src/main/java/org/videolan/tools/Settings.kt
+++ b/application/tools/src/main/java/org/videolan/tools/Settings.kt
@@ -55,6 +55,7 @@ const val LIST_TITLE_ELLIPSIZE = "list_title_ellipsize"
// AudioPlayer
+const val SHOW_REMAINING_TIME = "show_remaining_time"
const val PREF_PLAYLIST_TIPS_SHOWN = "playlist_tips_shown"
const val PREF_AUDIOPLAYER_TIPS_SHOWN = "audioplayer_tips_shown"
const val KEY_MEDIALIBRARY_SCAN = "ml_scan"
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.kt b/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.kt
index 560fbb693..34dd40b34 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.kt
@@ -107,6 +107,7 @@ class AudioPlayer : Fragment(), PlaylistAdapter.IPlayer, TextWatcher, IAudioPlay
savedInstanceState?.let {
playerState = it.getInt("player_state")
wasPlaying = it.getBoolean("was_playing")
+ showRemainingTime = it.getBoolean("show_remaining_time")
}
playlistAdapter = PlaylistAdapter(this)
settings = Settings.getInstance(requireContext())
@@ -183,6 +184,7 @@ class AudioPlayer : Fragment(), PlaylistAdapter.IPlayer, TextWatcher, IAudioPlay
override fun onResume() {
onStateChanged(playerState)
+ showRemainingTime = Settings.getInstance(requireContext()).getBoolean(SHOW_REMAINING_TIME, false)
super.onResume()
}
@@ -190,6 +192,7 @@ class AudioPlayer : Fragment(), PlaylistAdapter.IPlayer, TextWatcher, IAudioPlay
super.onSaveInstanceState(outState)
outState.putInt("player_state", playerState)
outState.putBoolean("was_playing", wasPlaying)
+ outState.putBoolean("show_remaining_time", showRemainingTime)
}
private val ctxReceiver: CtxActionReceiver = object : CtxActionReceiver {
@@ -338,6 +341,7 @@ class AudioPlayer : Fragment(), PlaylistAdapter.IPlayer, TextWatcher, IAudioPlay
fun onTimeLabelClick(view: View) {
showRemainingTime = !showRemainingTime
+ Settings.getInstance(requireContext()).edit().putBoolean(SHOW_REMAINING_TIME, showRemainingTime).apply()
playlistModel.progress.value?.let { updateProgress(it) }
}
More information about the Android
mailing list