diff --git a/app/src/main/java/sushi/hardcore/droidfs/ChangePasswordActivity.kt b/app/src/main/java/sushi/hardcore/droidfs/ChangePasswordActivity.kt index d307638..9ab884d 100644 --- a/app/src/main/java/sushi/hardcore/droidfs/ChangePasswordActivity.kt +++ b/app/src/main/java/sushi/hardcore/droidfs/ChangePasswordActivity.kt @@ -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 diff --git a/app/src/main/java/sushi/hardcore/droidfs/CreateActivity.kt b/app/src/main/java/sushi/hardcore/droidfs/CreateActivity.kt index fe366bf..afa4f80 100644 --- a/app/src/main/java/sushi/hardcore/droidfs/CreateActivity.kt +++ b/app/src/main/java/sushi/hardcore/droidfs/CreateActivity.kt @@ -25,7 +25,7 @@ class CreateActivity : VolumeActionActivity() { binding = ActivityCreateBinding.inflate(layoutInflater) setContentView(binding.root) setupLayout() - setupFingerprintStuff() + setupFingerprintStuff(mayDecrypt = false) binding.editPasswordConfirm.setOnEditorActionListener { _, _, _ -> createVolume() true diff --git a/app/src/main/java/sushi/hardcore/droidfs/OpenActivity.kt b/app/src/main/java/sushi/hardcore/droidfs/OpenActivity.kt index 4e95275..7c7b415 100644 --- a/app/src/main/java/sushi/hardcore/droidfs/OpenActivity.kt +++ b/app/src/main/java/sushi/hardcore/droidfs/OpenActivity.kt @@ -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) diff --git a/app/src/main/java/sushi/hardcore/droidfs/VolumeActionActivity.kt b/app/src/main/java/sushi/hardcore/droidfs/VolumeActionActivity.kt index 2d7161a..bd4aac4 100644 --- a/app/src/main/java/sushi/hardcore/droidfs/VolumeActionActivity.kt +++ b/app/src/main/java/sushi/hardcore/droidfs/VolumeActionActivity.kt @@ -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) } }