Add section name

This commit is contained in:
J-Jamet
2021-07-05 16:59:48 +02:00
parent 120e1893bd
commit b8aea1f97a
5 changed files with 16 additions and 5 deletions

View File

@@ -140,7 +140,7 @@ class TemplateBuilder {
add(holderAttribute)
add(bicAttribute)
add(ibanAttribute)
})
}, TemplateField.LABEL_ACCOUNT)
sections.add(mainSection)
sections.add(ibanSection)
return Template(

View File

@@ -92,7 +92,11 @@ abstract class TemplateEngine(private val mDatabase: DatabaseKDBX) {
section.attributes.forEach { attribute ->
if (index > 0) {
// Label is not important with section => [Section_X]: Divider
putField("$PREFIX_DECODED_TEMPLATE$SECTION_DECODED_TEMPLATE_PREFIX${index-1}$SUFFIX_DECODED_TEMPLATE",
val sectionName = if (section.name.isEmpty())
"$SECTION_DECODED_TEMPLATE_PREFIX${index-1}"
else
section.name
putField("$PREFIX_DECODED_TEMPLATE$sectionName$SUFFIX_DECODED_TEMPLATE",
ProtectedString(false, TemplateAttributeType.DIVIDER.label))
}

View File

@@ -34,6 +34,7 @@ object TemplateField {
const val LABEL_PUBLIC_KEY = "Public key"
const val LABEL_PRIVATE_KEY = "Private key"
const val LABEL_SEED = "Seed"
const val LABEL_ACCOUNT = "Account"
const val LABEL_BANK = "Bank"
const val LABEL_BIC = "BIC"
const val LABEL_IBAN = "IBAN"
@@ -86,6 +87,7 @@ object TemplateField {
LABEL_PUBLIC_KEY.equals(name, true) -> context.getString(R.string.public_key)
LABEL_PRIVATE_KEY.equals(name, true) -> context.getString(R.string.private_key)
LABEL_SEED.equals(name, true) -> context.getString(R.string.seed)
LABEL_ACCOUNT.equals(name, true) -> context.getString(R.string.account)
LABEL_BANK.equals(name, true) -> context.getString(R.string.bank)
LABEL_BIC.equals(name, true) -> context.getString(R.string.bank_identifier_code)
LABEL_IBAN.equals(name, true) -> context.getString(R.string.international_bank_account_number)

View File

@@ -5,19 +5,23 @@ import android.os.Parcelable
class TemplateSection: Parcelable {
var name: String = ""
var attributes: List<TemplateAttribute> = ArrayList()
private set
constructor(attributes: List<TemplateAttribute>) {
constructor(attributes: List<TemplateAttribute>, name: String = "") {
this.name = name
this.attributes = attributes
}
constructor(parcel: Parcel) {
parcel.readList(attributes, TemplateAttribute::class.java.classLoader)
this.name = parcel.readString() ?: name
parcel.readList(this.attributes, TemplateAttribute::class.java.classLoader)
}
override fun writeToParcel(parcel: Parcel, flags: Int) {
parcel.writeList(attributes)
parcel.writeString(this.name)
parcel.writeList(this.attributes)
}
override fun describeContents(): Int {

View File

@@ -118,6 +118,7 @@
<string name="public_key">Public key</string>
<string name="private_key">Private key</string>
<string name="seed">Seed</string>
<string name="account">Account</string>
<string name="bank">Bank</string>
<string name="bank_name">Bank name</string>
<string name="bank_identifier_code">SWIFT / BIC</string>