mirror of
https://github.com/Corewala/Buran
synced 2025-01-03 05:34:28 +00:00
combined createBiometricPrompt function versions
This commit is contained in:
parent
815c6bdccf
commit
c2cedab881
3 changed files with 8 additions and 14 deletions
|
@ -26,19 +26,13 @@ class BuranBiometricManager {
|
||||||
private lateinit var biometricPrompt: BiometricPrompt
|
private lateinit var biometricPrompt: BiometricPrompt
|
||||||
private lateinit var promptInfo: BiometricPrompt.PromptInfo
|
private lateinit var promptInfo: BiometricPrompt.PromptInfo
|
||||||
|
|
||||||
fun createBiometricPrompt(context: Context, fragment: Fragment, callback: BiometricPrompt.AuthenticationCallback){
|
fun createBiometricPrompt(context: Context, fragment: Fragment?, activity: FragmentActivity?, callback: BiometricPrompt.AuthenticationCallback){
|
||||||
val executor = ContextCompat.getMainExecutor(context)
|
val executor = ContextCompat.getMainExecutor(context)
|
||||||
biometricPrompt = BiometricPrompt(fragment, executor, callback)
|
if(fragment != null){
|
||||||
promptInfo = BiometricPrompt.PromptInfo.Builder()
|
biometricPrompt = BiometricPrompt(fragment, executor, callback)
|
||||||
.setConfirmationRequired(false)
|
}else if(activity != null){
|
||||||
.setTitle(context.getString(R.string.confirm_your_identity))
|
biometricPrompt = BiometricPrompt(activity, executor, callback)
|
||||||
.setSubtitle(context.getString(R.string.use_biometric_unlock))
|
}
|
||||||
.setNegativeButtonText(context.getString(R.string.cancel).toUpperCase())
|
|
||||||
.build()
|
|
||||||
}
|
|
||||||
fun createBiometricPrompt(context: Context, activity: FragmentActivity, callback: BiometricPrompt.AuthenticationCallback){
|
|
||||||
val executor = ContextCompat.getMainExecutor(context)
|
|
||||||
biometricPrompt = BiometricPrompt(activity, executor, callback)
|
|
||||||
promptInfo = BiometricPrompt.PromptInfo.Builder()
|
promptInfo = BiometricPrompt.PromptInfo.Builder()
|
||||||
.setConfirmationRequired(false)
|
.setConfirmationRequired(false)
|
||||||
.setTitle(context.getString(R.string.confirm_your_identity))
|
.setTitle(context.getString(R.string.confirm_your_identity))
|
||||||
|
|
|
@ -600,7 +600,7 @@ class GemActivity : AppCompatActivity() {
|
||||||
)!!
|
)!!
|
||||||
)
|
)
|
||||||
|
|
||||||
biometricManager.createBiometricPrompt(this, this, callback)
|
biometricManager.createBiometricPrompt(this, null, this, callback)
|
||||||
biometricManager.authenticateToDecryptData(initializationVector)
|
biometricManager.authenticateToDecryptData(initializationVector)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -343,7 +343,7 @@ class SettingsFragment: PreferenceFragmentCompat(), Preference.OnPreferenceChang
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
biometricManager.createBiometricPrompt(requireContext(), this, callback)
|
biometricManager.createBiometricPrompt(requireContext(), this, null, callback)
|
||||||
|
|
||||||
if(newValue as Boolean){
|
if(newValue as Boolean){
|
||||||
biometricManager.authenticateToEncryptData()
|
biometricManager.authenticateToEncryptData()
|
||||||
|
|
Loading…
Reference in a new issue