[Android] Persist audio time mode upon orientation change and app restart

Nicolas Pomepuy git at videolan.org
Fri Jan 8 09:05:47 UTC 2021


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Fri Jan  8 07:24:17 2021 +0100| [03d399531cb40d5172855e92210e0a89ee037b89] | committer: Nicolas Pomepuy

Persist audio time mode upon orientation change and app restart

Fixes #1602

> https://code.videolan.org/videolan/vlc-android/commit/03d399531cb40d5172855e92210e0a89ee037b89
---

 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