Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Snippets Groups Projects
Commit a3be470b authored by cketti's avatar cketti
Browse files

Allow unmasking when the original password was removed/replaced

parent ba9d9cd6
Branches
Tags
1 merge request!111690-Update to upstream v6.305
...@@ -12,6 +12,7 @@ import androidx.biometric.BiometricManager.Authenticators.BIOMETRIC_WEAK ...@@ -12,6 +12,7 @@ import androidx.biometric.BiometricManager.Authenticators.BIOMETRIC_WEAK
import androidx.biometric.BiometricManager.Authenticators.DEVICE_CREDENTIAL import androidx.biometric.BiometricManager.Authenticators.DEVICE_CREDENTIAL
import androidx.biometric.BiometricPrompt import androidx.biometric.BiometricPrompt
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.core.widget.doOnTextChanged
import androidx.fragment.app.FragmentActivity import androidx.fragment.app.FragmentActivity
import androidx.lifecycle.DefaultLifecycleObserver import androidx.lifecycle.DefaultLifecycleObserver
import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.LifecycleOwner
...@@ -69,9 +70,16 @@ fun TextInputLayout.configureAuthenticatedPasswordToggle( ...@@ -69,9 +70,16 @@ fun TextInputLayout.configureAuthenticatedPasswordToggle(
val editText = this.editText ?: error("TextInputLayout.editText == null") val editText = this.editText ?: error("TextInputLayout.editText == null")
editText.doOnTextChanged { text, _, before, count ->
// Check if the password field is empty or if all of the previous text was replaced
if (text != null && before > 0 && (text.isEmpty() || text.length - count == 0)) {
viewModel.isNewPassword = true
}
}
setEndIconOnClickListener { setEndIconOnClickListener {
if (editText.isPasswordHidden) { if (editText.isPasswordHidden) {
if (viewModel.isAuthenticated) { if (viewModel.isShowPasswordAllowed) {
activity.setSecure(true) activity.setSecure(true)
editText.showPassword() editText.showPassword()
} else { } else {
...@@ -102,6 +110,10 @@ private fun FragmentActivity.setSecure(secure: Boolean) { ...@@ -102,6 +110,10 @@ private fun FragmentActivity.setSecure(secure: Boolean) {
@SuppressLint("StaticFieldLeak") @SuppressLint("StaticFieldLeak")
class AuthenticatedPasswordToggleViewModel : ViewModel() { class AuthenticatedPasswordToggleViewModel : ViewModel() {
val isShowPasswordAllowed: Boolean
get() = isAuthenticated || isNewPassword
var isNewPassword = false
var isAuthenticated = false var isAuthenticated = false
var textInputLayout: TextInputLayout? = null var textInputLayout: TextInputLayout? = null
var activity: FragmentActivity? = null var activity: FragmentActivity? = null
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment