Hide logs behind authentication prompt
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<se.ajpanton.notificationlog.SafeInsetDrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<se.ajpanton.notificationlog.SafeInsetDrawerLayout
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/drawer_layout"
|
||||
android:layout_width="match_parent"
|
||||
@@ -61,3 +65,22 @@
|
||||
app:menu="@menu/drawer_menu" />
|
||||
|
||||
</se.ajpanton.notificationlog.SafeInsetDrawerLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/lock_overlay"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/window_background"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Notification Log is locked"
|
||||
android:textAppearance="?attr/textAppearanceHeadline6" />
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
||||
|
||||
Reference in New Issue
Block a user