mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Fix custom fields hidden
This commit is contained in:
@@ -208,7 +208,6 @@ class EntryActivity : LockingHideActivity() {
|
||||
}
|
||||
|
||||
entryContentsView?.assignURL(entry.url)
|
||||
entryContentsView?.setHiddenPasswordStyle(!mShowPassword)
|
||||
entryContentsView?.assignComment(entry.notes)
|
||||
|
||||
// Assign custom fields
|
||||
@@ -237,6 +236,7 @@ class EntryActivity : LockingHideActivity() {
|
||||
}
|
||||
}
|
||||
}
|
||||
entryContentsView?.setHiddenPasswordStyle(!mShowPassword)
|
||||
|
||||
// Assign dates
|
||||
entry.creationTime.date?.let {
|
||||
|
||||
@@ -161,8 +161,9 @@ class EntryContentsView @JvmOverloads constructor(context: Context,
|
||||
extrasView.let {
|
||||
for (i in 0 until it.childCount) {
|
||||
val childCustomView = it.getChildAt(i)
|
||||
if (childCustomView is EntryCustomFieldProtected)
|
||||
return true
|
||||
if (childCustomView is EntryCustomField)
|
||||
if (childCustomView.isProtected)
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
@@ -178,7 +179,7 @@ class EntryContentsView @JvmOverloads constructor(context: Context,
|
||||
extrasView.let {
|
||||
for (i in 0 until it.childCount) {
|
||||
val childCustomView = it.getChildAt(i)
|
||||
if (childCustomView is EntryCustomFieldProtected)
|
||||
if (childCustomView is EntryCustomField)
|
||||
childCustomView.setHiddenPasswordStyle(hiddenStyle)
|
||||
}
|
||||
}
|
||||
@@ -212,14 +213,10 @@ class EntryContentsView @JvmOverloads constructor(context: Context,
|
||||
enableActionButton: Boolean,
|
||||
onActionClickListener: OnClickListener?) {
|
||||
|
||||
val entryCustomField: EntryCustomField =
|
||||
if (value.isProtected)
|
||||
EntryCustomFieldProtected(context, attrs, defStyle)
|
||||
else
|
||||
EntryCustomField(context, attrs, defStyle)
|
||||
val entryCustomField = EntryCustomField(context, attrs, defStyle)
|
||||
entryCustomField.apply {
|
||||
assignLabel(title)
|
||||
assignValue(value.toString())
|
||||
setLabel(title)
|
||||
setValue(value.toString(), value.isProtected)
|
||||
enableActionButton(enableActionButton)
|
||||
assignActionButtonClickListener(onActionClickListener)
|
||||
applyFontVisibility(fontInVisibility)
|
||||
|
||||
@@ -21,6 +21,7 @@ package com.kunzisoft.keepass.view
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.text.method.PasswordTransformationMethod
|
||||
import androidx.core.content.ContextCompat
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
@@ -35,8 +36,9 @@ open class EntryCustomField @JvmOverloads constructor(context: Context,
|
||||
: LinearLayout(context, attrs, defStyle) {
|
||||
|
||||
private val labelView: TextView
|
||||
protected val valueView: TextView
|
||||
private val valueView: TextView
|
||||
private val actionImageView: ImageView
|
||||
var isProtected = false
|
||||
|
||||
private val colorAccent: Int
|
||||
|
||||
@@ -60,12 +62,21 @@ open class EntryCustomField @JvmOverloads constructor(context: Context,
|
||||
valueView.applyFontVisibility()
|
||||
}
|
||||
|
||||
fun assignLabel(label: String?) {
|
||||
fun setLabel(label: String?) {
|
||||
labelView.text = label ?: ""
|
||||
}
|
||||
|
||||
fun assignValue(value: String?) {
|
||||
fun setValue(value: String?, isProtected: Boolean = false) {
|
||||
valueView.text = value ?: ""
|
||||
this.isProtected = isProtected
|
||||
}
|
||||
|
||||
fun setHiddenPasswordStyle(hiddenStyle: Boolean) {
|
||||
if (isProtected && hiddenStyle) {
|
||||
valueView.transformationMethod = PasswordTransformationMethod.getInstance()
|
||||
} else {
|
||||
valueView.transformationMethod = null
|
||||
}
|
||||
}
|
||||
|
||||
fun enableActionButton(enable: Boolean) {
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 Jeremy Jamet / Kunzisoft.
|
||||
*
|
||||
* This file is part of KeePass DX.
|
||||
*
|
||||
* KeePass DX is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* KeePass DX is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with KeePass DX. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.kunzisoft.keepass.view
|
||||
|
||||
import android.content.Context
|
||||
import android.text.method.PasswordTransformationMethod
|
||||
import android.util.AttributeSet
|
||||
|
||||
class EntryCustomFieldProtected @JvmOverloads constructor(context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyle: Int = 0)
|
||||
: EntryCustomField(context, attrs, defStyle) {
|
||||
|
||||
fun setValue(value: String?, isProtected: Boolean) {
|
||||
if (value != null) {
|
||||
valueView.text = value
|
||||
setHiddenPasswordStyle(isProtected)
|
||||
}
|
||||
}
|
||||
|
||||
fun setHiddenPasswordStyle(hiddenStyle: Boolean) {
|
||||
if (!hiddenStyle) {
|
||||
valueView.transformationMethod = null
|
||||
} else {
|
||||
valueView.transformationMethod = PasswordTransformationMethod.getInstance()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user