[Android] Prevent the video player activity from closing when waiting for PIN unlock on TV
Nicolas Pomepuy
git at videolan.org
Wed Jul 12 08:30:37 UTC 2023
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Mon Jul 10 13:57:02 2023 +0200| [60ce3510621fc52fb7d87d25279b8e8789a054bc] | committer: Duncan McNamara
Prevent the video player activity from closing when waiting for PIN unlock on TV
> https://code.videolan.org/videolan/vlc-android/commit/60ce3510621fc52fb7d87d25279b8e8789a054bc
---
.../src/org/videolan/vlc/gui/helpers/hf/PinCodeDelegate.kt | 2 ++
.../src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt | 5 ++++-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/helpers/hf/PinCodeDelegate.kt b/application/vlc-android/src/org/videolan/vlc/gui/helpers/hf/PinCodeDelegate.kt
index b7c2a0f2f2..3f4b46d086 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/helpers/hf/PinCodeDelegate.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/helpers/hf/PinCodeDelegate.kt
@@ -12,6 +12,7 @@ import org.videolan.tools.Settings
import org.videolan.vlc.gui.DialogActivity
import org.videolan.vlc.gui.PinCodeActivity
import org.videolan.vlc.gui.PinCodeReason
+import org.videolan.vlc.gui.video.VideoPlayerActivity
private const val UNLOCK = "unlock"
class PinCodeDelegate : BaseHeadlessFragment() {
@@ -38,6 +39,7 @@ class PinCodeDelegate : BaseHeadlessFragment() {
}
suspend fun FragmentActivity.checkPIN(unlock:Boolean = false) : Boolean {
+ if (this is VideoPlayerActivity) this.waitingForPin = true
if (!Settings.safeMode) return true
val model : PermissionViewmodel by viewModels()
val fragment = PinCodeDelegate().apply {
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
index f1d1bd1ab3..a8b65ebe31 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
@@ -201,6 +201,7 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback,
private val dialogsDelegate = DialogDelegate()
private var baseContextWrappingDelegate: AppCompatDelegate? = null
+ var waitingForPin = false
/**
* Flag to indicate whether the media should be paused once loaded
@@ -623,6 +624,8 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback,
overridePendingTransition(0, 0)
super.onResume()
isShowingDialog = false
+ waitingForPin = false
+
/*
* Set listeners here to avoid NPE when activity is closing
*/
@@ -915,7 +918,7 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback,
if (!isFinishing) {
currentAudioTrack = audioTrack
currentSpuTrack = spuTrack
- if (tv) finish() // Leave player on TV, restauration can be difficult
+ if (tv && !waitingForPin) finish() // Leave player on TV, restauration can be difficult
}
if (isMute) mute(false)
More information about the Android
mailing list