[Android] Browser: backpressed pops the backstack

Duncan McNamara git at videolan.org
Tue Jan 31 14:23:27 UTC 2023


vlc-android | branch: master | Duncan McNamara <dcn.mcnamara at gmail.com> | Tue Jan 31 14:00:45 2023 +0100| [d38a206b8da5225e81b157d9a92ec0424432d832] | committer: Duncan McNamara

Browser: backpressed pops the backstack

Fix for a navigation regression.
Instead of calling finish when back is pressed, this will check if there
are any fragments backstacked, and pop the latest. If there aren't any
left, then finish is called, leaving the browser.

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

 .../src/org/videolan/vlc/gui/AudioPlayerContainerActivity.kt        | 6 +++++-
 1 file changed, 5 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 74f4826ee2..fecd16ad40 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.kt
@@ -170,7 +170,11 @@ open class AudioPlayerContainerActivity : BaseActivity(), KeycodeListener {
         onBackPressedDispatcher.addCallback(this, object : OnBackPressedCallback(true) {
             override fun handleOnBackPressed() {
                 if (slideDownAudioPlayer()) return
-                finish()
+                if (supportFragmentManager.backStackEntryCount == 0)
+                    finish()
+                else {
+                    supportFragmentManager.popBackStack()
+                }
             }
         })
     }



More information about the Android mailing list