[Android] FileBrowser: fix back pressed
Duncan McNamara
git at videolan.org
Wed Jun 5 11:59:32 UTC 2024
vlc-android | branch: master | Duncan McNamara <dcn.mcnamara at gmail.com> | Thu May 23 17:17:20 2024 +0200| [09c6326f5f8c30003af4e88defd8d0db181d7905] | committer: Nicolas Pomepuy
FileBrowser: fix back pressed
The addition of the onBackPressed callback in
3125cb2c396fba934bdd6408dde1e5d99ad49062 overrides the browser
onBackPressed behavior by forcing finish() instead of going back up the
directory tree.
> https://code.videolan.org/videolan/vlc-android/commit/09c6326f5f8c30003af4e88defd8d0db181d7905
---
.../src/org/videolan/vlc/gui/OTPCodeActivity.kt | 13 +++++++++++++
.../src/org/videolan/vlc/gui/SecondaryActivity.kt | 16 ----------------
2 files changed, 13 insertions(+), 16 deletions(-)
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/OTPCodeActivity.kt b/application/vlc-android/src/org/videolan/vlc/gui/OTPCodeActivity.kt
index 1b50a63088..0259521747 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/OTPCodeActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/OTPCodeActivity.kt
@@ -25,7 +25,11 @@
package org.videolan.vlc.gui
import android.os.Bundle
+import androidx.activity.OnBackPressedCallback
+import androidx.lifecycle.lifecycleScope
+import kotlinx.coroutines.launch
import org.videolan.vlc.R
+import org.videolan.vlc.util.RemoteAccessUtils
class OTPCodeActivity : BaseActivity() {
@@ -38,6 +42,15 @@ class OTPCodeActivity : BaseActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.otp_code_activity)
+
+ onBackPressedDispatcher.addCallback(this, object : OnBackPressedCallback(true) {
+ override fun handleOnBackPressed() {
+ lifecycleScope.launch {
+ RemoteAccessUtils.otpFlow.emit(null)
+ }
+ finish()
+ }
+ })
}
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/SecondaryActivity.kt b/application/vlc-android/src/org/videolan/vlc/gui/SecondaryActivity.kt
index 7f79e2c7ae..35277cceaf 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/SecondaryActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/SecondaryActivity.kt
@@ -28,14 +28,11 @@ import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import android.view.View
-import androidx.activity.OnBackPressedCallback
import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.core.os.bundleOf
import androidx.core.view.WindowInsetsControllerCompat
import androidx.fragment.app.Fragment
-import androidx.lifecycle.lifecycleScope
import com.google.android.material.appbar.AppBarLayout
-import kotlinx.coroutines.launch
import org.videolan.libvlc.Dialog
import org.videolan.medialibrary.interfaces.Medialibrary
import org.videolan.medialibrary.interfaces.media.MediaWrapper
@@ -61,7 +58,6 @@ import org.videolan.vlc.reloadLibrary
import org.videolan.vlc.util.DialogDelegate
import org.videolan.vlc.util.IDialogManager
import org.videolan.vlc.util.Permissions
-import org.videolan.vlc.util.RemoteAccessUtils
import org.videolan.vlc.util.isSchemeNetwork
class SecondaryActivity : ContentActivity(), IDialogManager {
@@ -79,8 +75,6 @@ class SecondaryActivity : ContentActivity(), IDialogManager {
if (intent.getStringExtra(KEY_FRAGMENT) == STORAGE_BROWSER_ONBOARDING) R.style.Theme_VLC_Black
else null
- override var isOTPActivity = false
-
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.secondary)
@@ -113,16 +107,6 @@ class SecondaryActivity : ContentActivity(), IDialogManager {
}
dialogsDelegate.observeDialogs(this, this)
if (intent.getBooleanExtra(KEY_ANIMATED, false)) supportActionBar?.setHomeAsUpIndicator(R.drawable.ic_close_up)
- onBackPressedDispatcher.addCallback(this, object : OnBackPressedCallback(true) {
- override fun handleOnBackPressed() {
- if (isOTPActivity) {
- lifecycleScope.launch {
- RemoteAccessUtils.otpFlow.emit(null)
- }
- }
- finish()
- }
- })
}
override fun fireDialog(dialog: Dialog) {
More information about the Android
mailing list