From 9659b55bf32b89ba2c4d982fdae1d7a3fc30cc8f Mon Sep 17 00:00:00 2001 From: Dev-ClayP Date: Fri, 4 Jul 2025 01:21:47 -0400 Subject: [PATCH] Update SetOTPDialogFragment.kt Fixed UX bug for button in the way, Added string length check. --- .../activities/dialogs/SetOTPDialogFragment.kt | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/kunzisoft/keepass/activities/dialogs/SetOTPDialogFragment.kt b/app/src/main/java/com/kunzisoft/keepass/activities/dialogs/SetOTPDialogFragment.kt index 167386b81..32bccfc76 100644 --- a/app/src/main/java/com/kunzisoft/keepass/activities/dialogs/SetOTPDialogFragment.kt +++ b/app/src/main/java/com/kunzisoft/keepass/activities/dialogs/SetOTPDialogFragment.kt @@ -224,6 +224,9 @@ class SetOTPDialogFragment : DatabaseDialogFragment() { } otpAlgorithmSpinner?.adapter = otpAlgorithmAdapter + // Ensure that the UX does not prevent user from hiding/unhiding text + otpSecretContainer?.errorIconDrawable = null + // Set the default value of OTP element upgradeType() upgradeTokenType() @@ -309,12 +312,16 @@ class SetOTPDialogFragment : DatabaseDialogFragment() { // Set secret in OtpElement otpSecretTextView?.addTextChangedListener(object: TextWatcher { override fun afterTextChanged(s: Editable?) { - s?.toString()?.let { userString -> - try { - mOtpElement.setBase32Secret(userString.uppercase(Locale.ENGLISH)) + s?.toString()?.let { userString -> + if (userString.length >= 8) { + try { + mOtpElement.setBase32Secret(userString.uppercase(Locale.ENGLISH)) + otpSecretContainer?.error = null + } catch (exception: Exception) { + otpSecretContainer?.error = getString(R.string.error_otp_secret_key) + } + } else { otpSecretContainer?.error = null - } catch (exception: Exception) { - otpSecretContainer?.error = getString(R.string.error_otp_secret_key) } mSecretWellFormed = otpSecretContainer?.error == null }