[Android] Implement the settings PIN code restriction 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 09:23:50 2023 +0200| [452456a9b314a9323019073c3695420db6b1bb04] | committer: Duncan McNamara

Implement the settings PIN code restriction on TV

> https://code.videolan.org/videolan/vlc-android/commit/452456a9b314a9323019073c3695420db6b1bb04
---

 .../television/ui/preferences/PreferencesActivity.kt     | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesActivity.kt b/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesActivity.kt
index 0caa563c07..1298ea53fd 100644
--- a/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesActivity.kt
+++ b/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesActivity.kt
@@ -24,15 +24,20 @@
 package org.videolan.television.ui.preferences
 
 import android.annotation.TargetApi
+import android.app.Activity
+import android.content.Intent
 import android.os.Build
 import android.os.Bundle
 import android.view.MenuItem
 import org.videolan.television.R
 import org.videolan.television.ui.browser.BaseTvActivity
+import org.videolan.tools.KEY_RESTRICT_SETTINGS
 import org.videolan.tools.RESULT_RESTART
 import org.videolan.tools.RESULT_RESTART_APP
 import org.videolan.tools.Settings
 import org.videolan.vlc.PlaybackService
+import org.videolan.vlc.gui.PinCodeActivity
+import org.videolan.vlc.gui.PinCodeReason
 
 @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
 class PreferencesActivity : BaseTvActivity() {
@@ -41,6 +46,17 @@ class PreferencesActivity : BaseTvActivity() {
         super.onCreate(savedInstanceState)
 
         setContentView(R.layout.tv_preferences_activity)
+        if (Settings.getInstance(this).getBoolean(KEY_RESTRICT_SETTINGS, false)) {
+            val intent = PinCodeActivity.getIntent(this, PinCodeReason.CHECK)
+            startActivityForResult(intent, 0)
+        }
+    }
+
+    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
+        if (resultCode != Activity.RESULT_OK) {
+            finish()
+        }
+        super.onActivityResult(requestCode, resultCode, data)
     }
 
     override fun refresh() {}



More information about the Android mailing list