[Android] Fix the PIN unlock feature when using a DialogActivity
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 15:34:19 2023 +0200| [6e622d9bab5d650dd7c73f568186c944d7724ca8] | committer: Duncan McNamara
Fix the PIN unlock feature when using a DialogActivity
> https://code.videolan.org/videolan/vlc-android/commit/6e622d9bab5d650dd7c73f568186c944d7724ca8
---
.../vlc-android/src/org/videolan/vlc/gui/DialogActivity.kt | 13 +++++++++++++
.../src/org/videolan/vlc/gui/helpers/hf/PinCodeDelegate.kt | 3 +++
2 files changed, 16 insertions(+)
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/DialogActivity.kt b/application/vlc-android/src/org/videolan/vlc/gui/DialogActivity.kt
index e77c10a14b..b117a71be1 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/DialogActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/DialogActivity.kt
@@ -37,6 +37,7 @@ import org.videolan.vlc.util.showVlcDialog
class DialogActivity : BaseActivity() {
override fun getSnackAnchorView(overAudioPlayer:Boolean): View? = findViewById<View>(android.R.id.content)
+ private var preventFinish = false
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@@ -85,6 +86,18 @@ class DialogActivity : BaseActivity() {
finish()
}
+ override fun finish() {
+ if (preventFinish) {
+ preventFinish = false
+ return
+ }
+ super.finish()
+ }
+
+ fun preventFinish() {
+ preventFinish = true
+ }
+
companion object {
var dialog : Dialog? = null
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 f1af6242cb..302485edc0 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
@@ -9,6 +9,7 @@ import androidx.activity.viewModels
import androidx.fragment.app.FragmentActivity
import androidx.lifecycle.MutableLiveData
import org.videolan.tools.Settings
+import org.videolan.vlc.gui.DialogActivity
import org.videolan.vlc.gui.PinCodeActivity
import org.videolan.vlc.gui.PinCodeReason
@@ -19,6 +20,7 @@ class PinCodeDelegate : BaseHeadlessFragment() {
model.complete(result.resultCode == Activity.RESULT_OK)
if (result.resultCode == Activity.RESULT_OK && unlock) pinUnlocked.postValue(true)
exit()
+ (activity as? DialogActivity)?.finish()
}
@TargetApi(Build.VERSION_CODES.O)
@@ -44,6 +46,7 @@ suspend fun FragmentActivity.checkPIN(unlock:Boolean = false) : Boolean {
}
model.setupDeferred()
supportFragmentManager.beginTransaction().add(fragment, PinCodeDelegate.TAG).commitAllowingStateLoss()
+ if (this is DialogActivity) this.preventFinish()
return model.deferredGrant.await()
}
More information about the Android
mailing list