Refactor out interceptSecurityOrReturn
This commit is contained in:
1 parent
19295e1d30
commit
8ea6417ea6
2 files changed
+13
-8
No files matched your search
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.hippo.ehviewer.ui
|
||||
|
||||
import android.content.Intent
|
||||
import android.content.res.Resources.Theme
|
||||
import android.os.Bundle
|
||||
import androidx.annotation.StyleRes
|
||||
@@ -48,13 +47,7 @@ abstract class EhActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
val lockedResumeTime = System.currentTimeMillis() / 1000
|
||||
val lockedDelayTime = lockedResumeTime - locked_last_leave_time
|
||||
if (lockedDelayTime < Settings.securityDelay * 60) {
|
||||
locked = false
|
||||
} else if (Settings.security && isAuthenticationSupported() && locked) {
|
||||
startActivity(Intent(this, SecurityActivity::class.java))
|
||||
}
|
||||
interceptSecurityOrReturn()
|
||||
super.onResume()
|
||||
window.setSecureScreen(Settings.enabledSecurity)
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package com.hippo.ehviewer.ui
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.biometric.BiometricManager
|
||||
import androidx.biometric.BiometricManager.Authenticators.DEVICE_CREDENTIAL
|
||||
@@ -30,6 +31,7 @@ import androidx.fragment.app.FragmentActivity
|
||||
import androidx.lifecycle.DefaultLifecycleObserver
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import com.hippo.ehviewer.R
|
||||
import com.hippo.ehviewer.Settings
|
||||
|
||||
fun Context.isAuthenticationSupported(): Boolean {
|
||||
val authenticators = BiometricManager.Authenticators.BIOMETRIC_WEAK or DEVICE_CREDENTIAL
|
||||
@@ -120,3 +122,13 @@ val lockObserver = object : DefaultLifecycleObserver {
|
||||
locked = true
|
||||
}
|
||||
}
|
||||
|
||||
fun Context.interceptSecurityOrReturn() {
|
||||
val lockedResumeTime = System.currentTimeMillis() / 1000
|
||||
val lockedDelayTime = lockedResumeTime - locked_last_leave_time
|
||||
if (lockedDelayTime < Settings.securityDelay * 60) {
|
||||
locked = false
|
||||
} else if (Settings.security && isAuthenticationSupported() && locked) {
|
||||
startActivity(Intent(this, SecurityActivity::class.java))
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user