Add secure screen setting

This commit is contained in:
arkon
2020-02-22 13:30:36 -05:00
parent b06f1c81bc
commit 61d2107e9c
10 changed files with 49 additions and 15 deletions
@@ -28,7 +28,7 @@ class BiometricUnlockActivity : AppCompatActivity() {
override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) {
super.onAuthenticationSucceeded(result)
BiometricUnlockDelegate.locked = false
SecureActivityDelegate.locked = false
preferences.lastAppUnlock().set(Date().time)
finish()
}
@@ -1,6 +1,7 @@
package eu.kanade.tachiyomi.ui.security
import android.content.Intent
import android.view.WindowManager
import androidx.biometric.BiometricManager
import androidx.fragment.app.FragmentActivity
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
@@ -8,12 +9,23 @@ import eu.kanade.tachiyomi.data.preference.getOrDefault
import uy.kohesive.injekt.injectLazy
import java.util.Date
object BiometricUnlockDelegate {
object SecureActivityDelegate {
private val preferences by injectLazy<PreferencesHelper>()
var locked: Boolean = true
fun onCreate(activity: FragmentActivity) {
preferences.secureScreen().asObservable()
.subscribe {
if (it) {
activity.window.setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE)
} else {
activity.window.clearFlags(WindowManager.LayoutParams.FLAG_SECURE)
}
}
}
fun onResume(activity: FragmentActivity) {
val lockApp = preferences.useBiometricLock().getOrDefault()
if (lockApp && BiometricManager.from(activity).canAuthenticate() == BiometricManager.BIOMETRIC_SUCCESS) {