Skip to content

Commit

Permalink
fix: biometric login
Browse files Browse the repository at this point in the history
  • Loading branch information
aistra0528 committed Jul 18, 2023
1 parent 8a77aa8 commit e98f8a4
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions app/src/main/kotlin/com/aistra/hail/ui/main/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,24 @@ class MainActivity : AppCompatActivity(), NavController.OnDestinationChangedList
val biometricPrompt = BiometricPrompt(this,
ContextCompat.getMainExecutor(this),
object : BiometricPrompt.AuthenticationCallback() {
private fun unlock() {
binding.root.isVisible = true
binding.appBarMain.toolbar.setBackgroundColor(
MaterialColors.getColor(binding.root, R.attr.colorPrimaryDark)
)
showGuide()
}

override fun onAuthenticationError(errorCode: Int, errString: CharSequence) {
super.onAuthenticationError(errorCode, errString)
HUI.showToast(errString)
finishAndRemoveTask()
if (errorCode == BiometricPrompt.ERROR_NO_BIOMETRICS) unlock()
else finishAndRemoveTask()
}

override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) {
super.onAuthenticationSucceeded(result)
binding.root.isVisible = true
binding.appBarMain.toolbar.setBackgroundColor(
MaterialColors.getColor(binding.root, R.attr.colorPrimaryDark)
)
showGuide()
unlock()
}
})
val promptInfo =
Expand Down

0 comments on commit e98f8a4

Please sign in to comment.