fix: OTP token visibility

This commit is contained in:
J-Jamet committed 2026-06-18 20:52:37 +02:00
1 parent ad3b610366
commit 045f1cffd5
1 file changed
+7 -15
@@ -115,6 +115,9 @@ class OtpDisplayView @JvmOverloads constructor(
fun setOtpModel(otpModel: OtpModel?) {
otpModel?.let { model ->
val otpElement = OtpElement(model)
if (this.otpElement?.otpModel != model) {
mRevealed = mShowOTP
}
this.otpElement = otpElement
if (otpElement.token.isNotEmpty()) {
otpProgress.apply {
@@ -133,7 +136,10 @@ class OtpDisplayView @JvmOverloads constructor(
} else {
visibility = GONE
}
} ?: run { visibility = GONE }
} ?: run {
mRevealed = mShowOTP
visibility = GONE
}
setOnClickListener {
copyTokenToClipboard()
@@ -183,11 +189,6 @@ class OtpDisplayView @JvmOverloads constructor(
otpProgress.setProgressColor(color)
}
override fun onDetachedFromWindow() {
super.onDetachedFromWindow()
clearData()
}
override fun setProtection(
isProtected: Boolean,
isRevealedByDefault: Boolean,
@@ -216,15 +217,6 @@ class OtpDisplayView @JvmOverloads constructor(
}
}
/**
* Clear the data and stop any pending updates.
*/
fun clearData() {
otpElement = null
otpProgress.clearData()
visibility = GONE
}
companion object {
private val TAG = OtpDisplayView::class.java.name
}