[Android] Safe mode implementation on TV

Nicolas Pomepuy git at videolan.org
Wed Jul 12 08:30:36 UTC 2023


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Tue Jul  4 11:49:03 2023 +0200| [14935027f53bb320c038bc0d6f1ba26a6bcad23c] | committer: Duncan McNamara

Safe mode implementation on TV

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

 .../resources/src/main/res/values/strings.xml      |  1 +
 .../television/ui/details/MediaListActivity.kt     | 24 ++++++++++++++--------
 2 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/application/resources/src/main/res/values/strings.xml b/application/resources/src/main/res/values/strings.xml
index 6232077570..0d3d363e6d 100644
--- a/application/resources/src/main/res/values/strings.xml
+++ b/application/resources/src/main/res/values/strings.xml
@@ -974,6 +974,7 @@
     <string name="pin_code_reason_modify">Change your PIN code</string>
     <string name="pin_code_modified">PIN code successfully modified</string>
     <string name="pin_code_reason_check">Access restricted. Please enter your PIN code</string>
+    <string name="pin_code_access_granted">Access granted. You can re-lock in the main screen</string>
     <string name="restricted_access">Access restricted</string>
     <string name="unlock">Unlock</string>
     <string name="lock_with_pin">Re-enable PIN lock</string>
diff --git a/application/television/src/main/java/org/videolan/television/ui/details/MediaListActivity.kt b/application/television/src/main/java/org/videolan/television/ui/details/MediaListActivity.kt
index 21a6ae73cc..2549d3f7a5 100644
--- a/application/television/src/main/java/org/videolan/television/ui/details/MediaListActivity.kt
+++ b/application/television/src/main/java/org/videolan/television/ui/details/MediaListActivity.kt
@@ -26,6 +26,7 @@ import org.videolan.television.ui.dialogs.ConfirmationTvActivity.Companion.CONFI
 import org.videolan.television.ui.updateBackground
 import org.videolan.vlc.gui.dialogs.SavePlaylistDialog
 import org.videolan.vlc.gui.helpers.UiTools.addToPlaylist
+import org.videolan.vlc.gui.helpers.UiTools.showPinIfNeeded
 import org.videolan.vlc.interfaces.ITVEventsHandler
 import org.videolan.vlc.media.MediaUtils
 import org.videolan.vlc.viewmodels.mobile.PlaylistViewModel
@@ -80,10 +81,12 @@ class MediaListActivity : BaseTvActivity(), ITVEventsHandler {
         binding.insertNext.setOnClickListener { MediaUtils.insertNext(this, item.tracks) }
         binding.addPlaylist.setOnClickListener { addToPlaylist(item.tracks, SavePlaylistDialog.KEY_NEW_TRACKS) }
         binding.delete.setOnClickListener {
-            val intent = Intent(this, ConfirmationTvActivity::class.java)
-            intent.putExtra(CONFIRMATION_DIALOG_TITLE, getString(R.string.validation_delete_playlist))
-            intent.putExtra(CONFIRMATION_DIALOG_TEXT, getString(R.string.validation_delete_playlist_text))
-            startActivityForResult(intent, REQUEST_DELETE_PLAYLIST)
+            if (!showPinIfNeeded()) {
+                val intent = Intent(this, ConfirmationTvActivity::class.java)
+                intent.putExtra(CONFIRMATION_DIALOG_TITLE, getString(R.string.validation_delete_playlist))
+                intent.putExtra(CONFIRMATION_DIALOG_TEXT, getString(R.string.validation_delete_playlist_text))
+                startActivityForResult(intent, REQUEST_DELETE_PLAYLIST)
+            }
         }
 
         if (item.itemType == MediaLibraryItem.TYPE_PLAYLIST) {
@@ -137,16 +140,21 @@ class MediaListActivity : BaseTvActivity(), ITVEventsHandler {
     }
 
     override fun onClickMoveUp(v: View, position: Int) {
-
-        (viewModel.playlist as Playlist).move(position, position - 1)
+        if (!showPinIfNeeded()) {
+            (viewModel.playlist as Playlist).move(position, position - 1)
+        }
     }
 
     override fun onClickMoveDown(v: View, position: Int) {
-        (viewModel.playlist as Playlist).move(position, position + 1)
+        if (!showPinIfNeeded()) {
+            (viewModel.playlist as Playlist).move(position, position + 1)
+        }
     }
 
     override fun onClickRemove(v: View, position: Int) {
-        (viewModel.playlist as Playlist).remove(position)
+        if (!showPinIfNeeded()) {
+            (viewModel.playlist as Playlist).remove(position)
+        }
     }
 
     override fun onFocusChanged(item: MediaLibraryItem) {



More information about the Android mailing list