Fix fingerprint checkbox behavior
This commit is contained in:
parent
b273fa828b
commit
6158b36c9f
@ -53,7 +53,7 @@ class ChangePasswordActivity : VolumeActionActivity() {
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||
if (volumeDatabase.isVolumeSaved(s.toString())){
|
||||
checkboxRememberPath.isEnabled = false
|
||||
checkboxRememberPath.isChecked = false
|
||||
checkboxRememberPath.isChecked = true
|
||||
binding.editOldPassword.apply {
|
||||
if (volumeDatabase.isHashSaved(s.toString())){
|
||||
text = null
|
||||
|
@ -25,7 +25,7 @@ class CreateActivity : VolumeActionActivity() {
|
||||
binding = ActivityCreateBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
setupLayout()
|
||||
setupFingerprintStuff()
|
||||
setupFingerprintStuff(mayDecrypt = false)
|
||||
binding.editPasswordConfirm.setOnEditorActionListener { _, _, _ ->
|
||||
createVolume()
|
||||
true
|
||||
|
@ -73,10 +73,10 @@ class OpenActivity : VolumeActionActivity() {
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||
if (volumeDatabase.isVolumeSaved(s.toString())){
|
||||
checkboxRememberPath.isEnabled = false
|
||||
checkboxRememberPath.isChecked = false
|
||||
checkboxRememberPath.isChecked = true
|
||||
if (volumeDatabase.isHashSaved(s.toString())){
|
||||
checkboxSavePassword.isEnabled = false
|
||||
checkboxSavePassword.isChecked = false
|
||||
checkboxSavePassword.isChecked = true
|
||||
} else {
|
||||
checkboxSavePassword.isEnabled = true
|
||||
}
|
||||
@ -164,7 +164,7 @@ class OpenActivity : VolumeActionActivity() {
|
||||
override fun doTask(activity: AppCompatActivity) {
|
||||
val password = binding.editPassword.text.toString().toCharArray()
|
||||
var returnedHash: ByteArray? = null
|
||||
if (checkboxSavePassword.isChecked){
|
||||
if (checkboxSavePassword.isChecked && usf_fingerprint) {
|
||||
returnedHash = ByteArray(GocryptfsVolume.KeyLen)
|
||||
}
|
||||
sessionID = GocryptfsVolume.init(currentVolumePath, password, null, returnedHash)
|
||||
|
@ -43,7 +43,7 @@ abstract class VolumeActionActivity : BaseActivity() {
|
||||
onDirectoryPicked(uri)
|
||||
}
|
||||
}
|
||||
private var usf_fingerprint = false
|
||||
protected var usf_fingerprint = false
|
||||
private var biometricCanAuthenticateCode: Int = -1
|
||||
private lateinit var biometricManager: BiometricManager
|
||||
private lateinit var biometricPrompt: BiometricPrompt
|
||||
@ -98,7 +98,7 @@ abstract class VolumeActionActivity : BaseActivity() {
|
||||
checkboxSavePassword.setOnClickListener {
|
||||
if (checkboxSavePassword.isChecked) {
|
||||
if (biometricCanAuthenticateCode == 0) {
|
||||
checkboxRememberPath.isChecked = checkboxRememberPath.isEnabled
|
||||
checkboxRememberPath.isChecked = true
|
||||
} else {
|
||||
checkboxSavePassword.isChecked = false
|
||||
printAuthenticateImpossibleError()
|
||||
@ -151,13 +151,17 @@ abstract class VolumeActionActivity : BaseActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
protected fun setupFingerprintStuff(){
|
||||
protected fun setupFingerprintStuff(mayDecrypt: Boolean = true) {
|
||||
originalHiddenVolumeSectionLayoutParams = hiddenVolumeSection.layoutParams as LinearLayout.LayoutParams
|
||||
originalNormalVolumeSectionLayoutParams = normalVolumeSection.layoutParams as LinearLayout.LayoutParams
|
||||
WidgetUtil.hide(hiddenVolumeSection)
|
||||
volumeDatabase = VolumeDatabase(this)
|
||||
usf_fingerprint = sharedPrefs.getBoolean("usf_fingerprint", false)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && usf_fingerprint) {
|
||||
val marshmallow = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
|
||||
if (!marshmallow || !usf_fingerprint) {
|
||||
WidgetUtil.hideWithPadding(checkboxSavePassword)
|
||||
}
|
||||
if (marshmallow && (mayDecrypt || usf_fingerprint)) {
|
||||
biometricManager = BiometricManager.from(this)
|
||||
biometricCanAuthenticateCode = canAuthenticate()
|
||||
if (biometricCanAuthenticateCode == 0){
|
||||
@ -225,8 +229,6 @@ abstract class VolumeActionActivity : BaseActivity() {
|
||||
}
|
||||
biometricPrompt = BiometricPrompt(this, executor, callback)
|
||||
}
|
||||
} else {
|
||||
WidgetUtil.hideWithPadding(checkboxSavePassword)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user