fix: Unprotect with User Verification #2283

This commit is contained in:
J-Jamet
2025-12-02 20:25:44 +01:00
parent 2bbb40e513
commit b394a99e40
10 changed files with 94 additions and 24 deletions

View File

@@ -42,7 +42,8 @@ import com.kunzisoft.keepass.utils.AppUtil.openExternalApp
open class TextFieldView @JvmOverloads constructor(context: Context,
attrs: AttributeSet? = null,
defStyle: Int = 0)
: RelativeLayout(context, attrs, defStyle), GenericTextFieldView {
: RelativeLayout(context, attrs, defStyle),
GenericTextFieldView, ProtectedFieldView {
protected var labelViewId = ViewCompat.generateViewId()
private var valueViewId = ViewCompat.generateViewId()
@@ -204,17 +205,30 @@ open class TextFieldView @JvmOverloads constructor(context: Context,
}
}
fun setProtection(protection: Boolean) {
override fun setProtection(protection: Boolean, onUnprotectClickListener: OnClickListener?) {
showButton.isVisible = protection
showButton.isSelected = true
showButton.setOnClickListener {
showButton.isSelected = !showButton.isSelected
changeProtectedValueParameters()
onUnprotectClickListener?.onClick(this@TextFieldView)
}
changeProtectedValueParameters()
invalidate()
}
override fun isCurrentlyProtected(): Boolean {
return showButton.isSelected
}
override fun protect() {
showButton.isSelected = !showButton.isSelected
changeProtectedValueParameters()
}
override fun unprotect() {
showButton.isSelected = !showButton.isSelected
changeProtectedValueParameters()
}
protected fun changeProtectedValueParameters() {
valueView.apply {
if (showButton.isVisible) {