From cfa64162b0b5c4d6a60916bec55087b2df758a0c Mon Sep 17 00:00:00 2001 From: Andries Smit Date: Sat, 5 Mar 2022 20:00:26 +0100 Subject: [PATCH] fix: asking for app protection only once --- .../java/info/nightscout/androidaps/MainActivity.kt | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.kt b/app/src/main/java/info/nightscout/androidaps/MainActivity.kt index bf7e2982cf..dbd152c315 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.kt @@ -89,7 +89,7 @@ class MainActivity : NoSplashAppCompatActivity() { private var pluginPreferencesMenuItem: MenuItem? = null private var menu: Menu? = null private var menuOpen = false - + private var isProtectionCheckActive = false private lateinit var binding: ActivityMainBinding override fun onCreate(savedInstanceState: Bundle?) { @@ -168,10 +168,13 @@ class MainActivity : NoSplashAppCompatActivity() { override fun onResume() { super.onResume() - protectionCheck.queryProtection(this, ProtectionCheck.Protection.APPLICATION, null, - UIRunnable { OKDialog.show(this, "", rh.gs(R.string.authorizationfailed)) { finish() } }, - UIRunnable { OKDialog.show(this, "", rh.gs(R.string.authorizationfailed)) { finish() } } - ) + if (!isProtectionCheckActive) { + isProtectionCheckActive = true + protectionCheck.queryProtection(this, ProtectionCheck.Protection.APPLICATION, UIRunnable { isProtectionCheckActive = false }, + UIRunnable { OKDialog.show(this, "", rh.gs(R.string.authorizationfailed)) { isProtectionCheckActive = false; finish() } }, + UIRunnable { OKDialog.show(this, "", rh.gs(R.string.authorizationfailed)) { isProtectionCheckActive = false; finish() } } + ) + } } private fun setWakeLock() {