[Android] Save and restore bookmark list visibility upon orientation changes
Nicolas Pomepuy
git at videolan.org
Wed Jul 12 13:10:26 UTC 2023
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Tue Jul 11 07:12:59 2023 +0200| [84a271b3c5399a71a0755c86b52b6ded632a8c70] | committer: Nicolas Pomepuy
Save and restore bookmark list visibility upon orientation changes
> https://code.videolan.org/videolan/vlc-android/commit/84a271b3c5399a71a0755c86b52b6ded632a8c70
---
.../src/org/videolan/vlc/gui/AudioPlayerContainerActivity.kt | 9 +++++++++
.../vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.kt | 2 +-
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.kt b/application/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.kt
index fecd16ad40..d8d4da40b8 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.kt
@@ -76,6 +76,7 @@ private const val ACTION_HIDE_PLAYER = 1341
private const val BOTTOM_IS_HIDDEN = "bottom_is_hidden"
private const val PLAYER_OPENED = "player_opened"
private const val SHOWN_TIPS = "shown_tips"
+private const val BOOKMARK_VISIBLE: String = "bookmark_visible"
open class AudioPlayerContainerActivity : BaseActivity(), KeycodeListener {
@@ -124,6 +125,7 @@ open class AudioPlayerContainerActivity : BaseActivity(), KeycodeListener {
get() = isAudioPlayerReady && playerBehavior.state == STATE_EXPANDED
var bottomIsHiddden: Boolean = false
+ var restoreBookmarks: Boolean = false
override fun getSnackAnchorView(overAudioPlayer: Boolean): View? {
return if (::audioPlayerContainer.isInitialized && audioPlayerContainer.visibility != View.GONE && ::playerBehavior.isInitialized && playerBehavior.state == STATE_COLLAPSED)
@@ -136,6 +138,7 @@ open class AudioPlayerContainerActivity : BaseActivity(), KeycodeListener {
this.startMedialibrary(firstRun = false, upgrade = false, parse = true)
bottomIsHiddden = savedInstanceState.getBoolean(BOTTOM_IS_HIDDEN, false) && !savedInstanceState.getBoolean(PLAYER_OPENED, false)
savedInstanceState.getIntegerArrayList(SHOWN_TIPS)?.let { shownTips.addAll(it) }
+ restoreBookmarks = savedInstanceState.getBoolean(BOOKMARK_VISIBLE, false)
}
super.onCreate(savedInstanceState)
if (AndroidUtil.isLolliPopOrLater && this is MainActivity) WindowCompat.setDecorFitsSystemWindows(window, false)
@@ -282,6 +285,10 @@ open class AudioPlayerContainerActivity : BaseActivity(), KeycodeListener {
})
showTipViewIfNeeded(R.id.audio_player_tips, PREF_AUDIOPLAYER_TIPS_SHOWN)
if (playlistTipsDelegate.currentTip != null) lockPlayer(true)
+ if (restoreBookmarks) {
+ audioPlayer.showBookmarks()
+ restoreBookmarks = false
+ }
}
private fun hideStatusIfNeeded(newState: Int) {
@@ -361,9 +368,11 @@ open class AudioPlayerContainerActivity : BaseActivity(), KeycodeListener {
?: false)
outState.putBoolean(PLAYER_OPENED, if (::playerBehavior.isInitialized) playerBehavior.state == STATE_EXPANDED else false)
outState.putIntegerArrayList(SHOWN_TIPS, shownTips)
+ if (::audioPlayer.isInitialized) outState.putBoolean(BOOKMARK_VISIBLE, audioPlayer.areBookmarksVisible())
super.onSaveInstanceState(outState)
}
+
fun expandAppBar() {
appBarLayout.setExpanded(true)
}
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 4bf0282c83..427b2d392f 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
@@ -103,7 +103,7 @@ class AudioPlayer : Fragment(), PlaylistAdapter.IPlayer, TextWatcher, IAudioPlay
lateinit var playlistModel: PlaylistModel
lateinit var bookmarkModel: BookmarkModel
private lateinit var optionsDelegate: PlayerOptionsDelegate
- private lateinit var bookmarkListDelegate: BookmarkListDelegate
+ lateinit var bookmarkListDelegate: BookmarkListDelegate
private var showRemainingTime = false
private var previewingSeek = false
More information about the Android
mailing list