mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Fix multiline
This commit is contained in:
@@ -120,7 +120,7 @@ class Template : Parcelable {
|
||||
val mainSection = TemplateSection(ArrayList<TemplateAttribute>().apply {
|
||||
add(TemplateAttribute(LABEL_USERNAME, TemplateAttributeType.INLINE))
|
||||
add(TemplateAttribute(LABEL_PASSWORD,
|
||||
TemplateAttributeType.INLINE,
|
||||
TemplateAttributeType.SMALL_MULTILINE,
|
||||
true,
|
||||
"",
|
||||
TemplateAttributeAction.PASSWORD_GENERATION)
|
||||
|
||||
@@ -20,6 +20,7 @@ package com.kunzisoft.keepass.database.element.template
|
||||
|
||||
enum class TemplateAttributeType {
|
||||
INLINE,
|
||||
SMALL_MULTILINE,
|
||||
MULTILINE,
|
||||
DATE,
|
||||
TIME,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.kunzisoft.keepass.view
|
||||
|
||||
import android.content.Context
|
||||
import android.text.InputType
|
||||
import android.text.method.PasswordTransformationMethod
|
||||
import android.util.AttributeSet
|
||||
import android.util.TypedValue
|
||||
@@ -123,11 +124,19 @@ class EntryEditFieldView @JvmOverloads constructor(context: Context,
|
||||
fun setType(valueType: TextType) {
|
||||
when (valueType) {
|
||||
TextType.NORMAL -> {
|
||||
valueView.inputType = valueView.inputType or EditorInfo.TYPE_TEXT_VARIATION_NORMAL
|
||||
valueView.inputType = valueView.inputType or
|
||||
InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_NORMAL
|
||||
valueView.maxLines = 1
|
||||
}
|
||||
TextType.SMALL_MULTI_LINE -> {
|
||||
valueView.inputType = valueView.inputType or
|
||||
InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_MULTI_LINE
|
||||
valueView.maxEms = 3
|
||||
valueView.maxLines = 3
|
||||
}
|
||||
TextType.MULTI_LINE -> {
|
||||
valueView.inputType = valueView.inputType or EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE
|
||||
valueView.inputType = valueView.inputType or
|
||||
InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_MULTI_LINE
|
||||
valueView.maxEms = 40
|
||||
valueView.maxLines = 40
|
||||
}
|
||||
@@ -137,7 +146,7 @@ class EntryEditFieldView @JvmOverloads constructor(context: Context,
|
||||
fun setProtection(protection: Boolean, hiddenProtectedValue: Boolean) {
|
||||
if (protection) {
|
||||
labelView.endIconMode = TextInputLayout.END_ICON_PASSWORD_TOGGLE
|
||||
valueView.inputType = valueView.inputType or EditorInfo.TYPE_TEXT_VARIATION_PASSWORD
|
||||
valueView.inputType = valueView.inputType or InputType.TYPE_TEXT_VARIATION_PASSWORD
|
||||
labelView.editText?.transformationMethod = if (hiddenProtectedValue)
|
||||
PasswordTransformationMethod.getInstance()
|
||||
else
|
||||
@@ -155,6 +164,6 @@ class EntryEditFieldView @JvmOverloads constructor(context: Context,
|
||||
}
|
||||
|
||||
enum class TextType {
|
||||
NORMAL, MULTI_LINE
|
||||
NORMAL, SMALL_MULTI_LINE, MULTI_LINE
|
||||
}
|
||||
}
|
||||
@@ -153,7 +153,7 @@ class TemplateView @JvmOverloads constructor(context: Context,
|
||||
private fun buildViewForCustomField(field: Field): View? {
|
||||
val customFieldTemplateAttribute = TemplateAttribute(
|
||||
field.name,
|
||||
TemplateAttributeType.INLINE,
|
||||
TemplateAttributeType.MULTILINE,
|
||||
field.protectedValue.isProtected,
|
||||
field.protectedValue.stringValue,
|
||||
TemplateAttributeAction.CUSTOM_EDITION)
|
||||
@@ -166,6 +166,7 @@ class TemplateView @JvmOverloads constructor(context: Context,
|
||||
// Build main view depending on type
|
||||
val itemView: View? = when (templateAttribute.type) {
|
||||
TemplateAttributeType.INLINE,
|
||||
TemplateAttributeType.SMALL_MULTILINE,
|
||||
TemplateAttributeType.MULTILINE -> {
|
||||
buildLinearTextView(templateAttribute, field)
|
||||
}
|
||||
@@ -197,6 +198,7 @@ class TemplateView @JvmOverloads constructor(context: Context,
|
||||
label = TemplateField.getLocalizedName(context, field.name)
|
||||
setProtection(field.protectedValue.isProtected, mHideProtectedValue)
|
||||
setType(when (templateAttribute.type) {
|
||||
TemplateAttributeType.SMALL_MULTILINE -> EntryEditFieldView.TextType.SMALL_MULTI_LINE
|
||||
TemplateAttributeType.MULTILINE -> EntryEditFieldView.TextType.MULTI_LINE
|
||||
else -> EntryEditFieldView.TextType.NORMAL
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user