[Android] Add safe mode lock and unlock icons to the video advanced settings

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


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Thu Jul  6 11:07:23 2023 +0200| [1d50b34a96f1bbff98e12b5015f6cd98474bb7a2] | committer: Duncan McNamara

Add safe mode lock and unlock icons to the video advanced settings

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

 .../src/main/res/drawable/ic_pin_lock.xml          | 33 ++++++++++++++++++++++
 .../src/main/res/drawable/ic_pin_unlock.xml        | 33 ++++++++++++++++++++++
 .../vlc/gui/helpers/PlayerOptionsDelegate.kt       | 22 ++++++++++++++-
 3 files changed, 87 insertions(+), 1 deletion(-)

diff --git a/application/resources/src/main/res/drawable/ic_pin_lock.xml b/application/resources/src/main/res/drawable/ic_pin_lock.xml
new file mode 100644
index 0000000000..d081081527
--- /dev/null
+++ b/application/resources/src/main/res/drawable/ic_pin_lock.xml
@@ -0,0 +1,33 @@
+<!--
+  ~ *************************************************************************
+  ~  pin_lock.xml
+  ~ **************************************************************************
+  ~ Copyright © 2023 VLC authors and VideoLAN
+  ~ Author: Nicolas POMEPUY
+  ~ This program is free software; you can redistribute it and/or modify
+  ~ it under the terms of the GNU General Public License as published by
+  ~ the Free Software Foundation; either version 2 of the License, or
+  ~ (at your option) any later version.
+  ~
+  ~ This program is distributed in the hope that it will be useful,
+  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  ~ GNU General Public License for more details.
+  ~
+  ~ You should have received a copy of the GNU General Public License
+  ~ along with this program; if not, write to the Free Software
+  ~ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+  ~ ***************************************************************************
+  ~
+  ~
+  -->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+        android:width="48dp"
+        android:height="48dp"
+        android:viewportWidth="24"
+        android:viewportHeight="24">
+    <path
+            android:fillColor="@color/white"
+            android:pathData="M12,2L4,5v6.09c0,5.05 3.41,9.76 8,10.91c4.59,-1.15 8,-5.86 8,-10.91V5L12,2zM18,11.09c0,4 -2.55,7.7 -6,8.83c-3.45,-1.13 -6,-4.82 -6,-8.83V6.31l6,-2.12l6,2.12V11.09zM8.82,10.59L7.4,12l3.54,3.54l5.66,-5.66l-1.41,-1.41l-4.24,4.24L8.82,10.59z" />
+</vector>
diff --git a/application/resources/src/main/res/drawable/ic_pin_unlock.xml b/application/resources/src/main/res/drawable/ic_pin_unlock.xml
new file mode 100644
index 0000000000..3eb81ba78b
--- /dev/null
+++ b/application/resources/src/main/res/drawable/ic_pin_unlock.xml
@@ -0,0 +1,33 @@
+<!--
+  ~ *************************************************************************
+  ~  ic_am_pin_unlock.xml
+  ~ **************************************************************************
+  ~ Copyright © 2023 VLC authors and VideoLAN
+  ~ Author: Nicolas POMEPUY
+  ~ This program is free software; you can redistribute it and/or modify
+  ~ it under the terms of the GNU General Public License as published by
+  ~ the Free Software Foundation; either version 2 of the License, or
+  ~ (at your option) any later version.
+  ~
+  ~ This program is distributed in the hope that it will be useful,
+  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  ~ GNU General Public License for more details.
+  ~
+  ~ You should have received a copy of the GNU General Public License
+  ~ along with this program; if not, write to the Free Software
+  ~ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+  ~ ***************************************************************************
+  ~
+  ~
+  -->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+        android:width="48dp"
+        android:height="48dp"
+        android:viewportWidth="24"
+        android:viewportHeight="24">
+    <path
+            android:fillColor="@color/white"
+            android:pathData="M12,2L4,5v6.09c0,5.05 3.41,9.76 8,10.91c4.59,-1.15 8,-5.86 8,-10.91V5L12,2zM18,11.09c0,4 -2.55,7.7 -6,8.83c-3.45,-1.13 -6,-4.82 -6,-8.83v-4.7l6,-2.25l6,2.25V11.09zM9.91,8.5L8.5,9.91L10.59,12L8.5,14.09l1.41,1.41L12,13.42l2.09,2.08l1.41,-1.41L13.42,12l2.08,-2.09L14.09,8.5L12,10.59L9.91,8.5z" />
+</vector>
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/helpers/PlayerOptionsDelegate.kt b/application/vlc-android/src/org/videolan/vlc/gui/helpers/PlayerOptionsDelegate.kt
index c01ef35b0f..87030f32e9 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/helpers/PlayerOptionsDelegate.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/helpers/PlayerOptionsDelegate.kt
@@ -16,6 +16,7 @@ import androidx.fragment.app.FragmentActivity
 import androidx.leanback.widget.BrowseFrameLayout
 import androidx.leanback.widget.BrowseFrameLayout.OnFocusSearchListener
 import androidx.lifecycle.LifecycleObserver
+import androidx.lifecycle.lifecycleScope
 import androidx.recyclerview.widget.LinearLayoutManager
 import androidx.recyclerview.widget.RecyclerView
 import androidx.window.layout.FoldingFeature
@@ -36,6 +37,8 @@ import org.videolan.vlc.gui.DiffUtilAdapter
 import org.videolan.vlc.gui.audio.EqualizerFragment
 import org.videolan.vlc.gui.dialogs.*
 import org.videolan.vlc.gui.helpers.UiTools.addToPlaylist
+import org.videolan.vlc.gui.helpers.hf.PinCodeDelegate
+import org.videolan.vlc.gui.helpers.hf.checkPIN
 import org.videolan.vlc.gui.video.VideoPlayerActivity
 import org.videolan.vlc.media.PlayerController
 import org.videolan.vlc.util.getScreenHeight
@@ -65,6 +68,8 @@ private const val ID_SHOW_AUDIO_TIPS = 17L
 private const val ID_SHOW_PLAYLIST_TIPS = 18L
 private const val ID_VIDEO_CONTROL_SETTING = 19L
 private const val ID_AUDIO_CONTROL_SETTING = 20L
+private const val ID_SAFE_MODE_LOCK = 21L
+private const val ID_SAFE_MODE_UNLOCK = 22L
 @SuppressLint("ShowToast")
 class PlayerOptionsDelegate(val activity: FragmentActivity, val service: PlaybackService, private val showABReapeat:Boolean = true) : LifecycleObserver {
 
@@ -112,8 +117,12 @@ class PlayerOptionsDelegate(val activity: FragmentActivity, val service: Playbac
         options.add(PlayerOption(ID_SAVE_PLAYLIST, R.drawable.ic_addtoplaylist, res.getString(R.string.playlist_save)))
         if (service.playlistManager.player.canDoPassthrough() && settings.getString("aout", "0") != "2")
             options.add(PlayerOption(ID_PASSTHROUGH, R.drawable.ic_passthrough, res.getString(R.string.audio_digital_title)))
-        if (video)
+
+        if (video) {
+            if (PinCodeDelegate.pinUnlocked.value == true) options.add(PlayerOption(ID_SAFE_MODE_LOCK, R.drawable.ic_pin_lock, res.getString(R.string.lock_with_pin)))
+            if (Settings.safeMode && PinCodeDelegate.pinUnlocked.value == false) options.add(PlayerOption(ID_SAFE_MODE_UNLOCK, R.drawable.ic_pin_unlock, res.getString(R.string.unlock_with_pin)))
             options.add(PlayerOption(ID_VIDEO_CONTROL_SETTING, R.drawable.ic_video_controls, res.getString(R.string.control_setting)))
+        }
 
         if (!Settings.showTvUi) {
             if (video) {
@@ -245,6 +254,17 @@ class PlayerOptionsDelegate(val activity: FragmentActivity, val service: Playbac
                 val audioControlsSettingsDialog = AudioControlsSettingsDialog()
                 audioControlsSettingsDialog.show(activity.supportFragmentManager, "fragment_audio_controls_settings")
             }
+            ID_SAFE_MODE_LOCK -> {
+                hide()
+                PinCodeDelegate.pinUnlocked.postValue(false)
+                (activity as? VideoPlayerActivity)?.overlayDelegate?.showOverlay()
+                UiTools.snacker(activity, R.string.safe_mode_enabled)
+            }
+
+            ID_SAFE_MODE_UNLOCK -> {
+                hide()
+                activity.lifecycleScope.launch { activity.checkPIN(true) }
+            }
             else -> showFragment(option.id)
         }
     }



More information about the Android mailing list