Hide logs behind authentication prompt

This commit is contained in:
ajp_anton
2026-07-26 15:15:45 +00:00
parent 6b93492a0e
commit 3bc71cdc61
2 changed files with 43 additions and 4 deletions
@@ -39,6 +39,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
WindowCompat.setDecorFitsSystemWindows(window, true)
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
showLockedOverlay(AppLockStore(this).enabled)
val isNightMode = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK ==
Configuration.UI_MODE_NIGHT_YES
WindowInsetsControllerCompat(window, binding.root).isAppearanceLightNavigationBars = !isNightMode
@@ -84,12 +85,20 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
override fun onResume() {
super.onResume()
if (needsUnlock && AppLockStore(this).enabled) requestUnlock()
if (needsUnlock && AppLockStore(this).enabled) {
showLockedOverlay(true)
requestUnlock()
} else {
showLockedOverlay(false)
}
}
override fun onStop() {
super.onStop()
if (!isChangingConfigurations) needsUnlock = true
if (!isChangingConfigurations) {
needsUnlock = true
if (AppLockStore(this).enabled) showLockedOverlay(true)
}
}
private fun requestUnlock() {
@@ -98,11 +107,18 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
.setAllowedAuthenticators(Authenticators.BIOMETRIC_STRONG or Authenticators.DEVICE_CREDENTIAL)
.build()
.authenticate(CancellationSignal(), mainExecutor, object : BiometricPrompt.AuthenticationCallback() {
override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult?) { needsUnlock = false }
override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult?) {
needsUnlock = false
showLockedOverlay(false)
}
override fun onAuthenticationError(errorCode: Int, errString: CharSequence?) { finishAndRemoveTask() }
})
}
private fun showLockedOverlay(visible: Boolean) {
binding.lockOverlay.visibility = if (visible) View.VISIBLE else View.GONE
}
override fun onNavigationItemSelected(item: MenuItem): Boolean {
navigateTo(item.itemId)
if (!permanentSidebar) {