[Android] SafeMode: add videoplayer lock to pin lock

Duncan McNamara git at videolan.org
Mon Aug 5 12:13:44 UTC 2024


vlc-android | branch: master | Duncan McNamara <dcn.mcnamara at gmail.com> | Fri Jul 19 16:54:59 2024 +0200| [7d46b230413a1a227066a87923a9644f0768ce4a] | committer: Nicolas Pomepuy

SafeMode: add videoplayer lock to pin lock

Unlocking the video player should be protected by pin when safe mode is
enabled. A kid with lock enabled wouldn't be able to leave the
videoplayer.

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

 .../videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt  | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt
index b5cf619549..5dda6864de 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt
@@ -51,12 +51,16 @@ import androidx.core.net.toUri
 import androidx.core.view.children
 import androidx.databinding.DataBindingUtil
 import androidx.lifecycle.ViewModelProvider
+import androidx.lifecycle.lifecycleScope
 import androidx.recyclerview.widget.ItemTouchHelper
 import androidx.recyclerview.widget.LinearLayoutManager
 import androidx.recyclerview.widget.RecyclerView
 import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat
 import androidx.window.layout.FoldingFeature
 import com.google.android.material.textfield.TextInputLayout
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
+import kotlinx.coroutines.withContext
 import org.videolan.libvlc.util.AndroidUtil
 import org.videolan.medialibrary.interfaces.media.MediaWrapper
 import org.videolan.medialibrary.media.MediaWrapperImpl
@@ -71,6 +75,7 @@ import org.videolan.vlc.gui.browser.KEY_MEDIA
 import org.videolan.vlc.gui.dialogs.VideoTracksDialog
 import org.videolan.vlc.gui.helpers.*
 import org.videolan.vlc.gui.helpers.UiTools.showVideoTrack
+import org.videolan.vlc.gui.helpers.hf.checkPIN
 import org.videolan.vlc.gui.view.PlayerProgress
 import org.videolan.vlc.media.MediaUtils
 import org.videolan.vlc.util.*
@@ -623,7 +628,15 @@ class VideoPlayerOverlayDelegate (private val player: VideoPlayerActivity) {
             hudBinding.orientationToggle.setOnLongClickListener(if (enabled) player else null)
             hudBinding.swipeToUnlock.setOnStartTouchingListener { showOverlayTimeout(VideoPlayerActivity.OVERLAY_INFINITE) }
             hudBinding.swipeToUnlock.setOnStopTouchingListener { showOverlayTimeout(Settings.videoHudDelay * 1000) }
-            hudBinding.swipeToUnlock.setOnUnlockListener { player.toggleLock() }
+            hudBinding.swipeToUnlock.setOnUnlockListener {
+                player.lifecycleScope.launch(Dispatchers.IO) {
+                    if (!player.checkPIN())
+                        player.isLocked = false
+                    withContext(Dispatchers.Main) {
+                        player.toggleLock()
+                    }
+                }
+            }
         }
         if (::hudRightBinding.isInitialized){
             hudRightBinding.playerOverlayNavmenu.setOnClickListener(if (enabled) player else null)



More information about the Android mailing list