Add Type to Wifi

This commit is contained in:
J-Jamet committed 2021-07-07 21:55:11 +02:00
1 parent 1578ea7590
commit db4d76502e
5 files changed
+13 -2

No files matched your search

@@ -100,7 +100,7 @@ class TemplateAttributeOption() : Parcelable {
return mOptions[LIST_ITEMS]?.split(LIST_ITEMS_SEPARATOR) ?: listOf()
}
fun setListItems(items: List<String>) {
fun setListItems(vararg items: String) {
mOptions[LIST_ITEMS] = items.joinToString(LIST_ITEMS_SEPARATOR)
}
@@ -39,6 +39,13 @@ class TemplateBuilder {
private val emailAddressAttribute = TemplateAttribute(TemplateField.LABEL_EMAIL_ADDRESS, TemplateAttributeType.TEXT)
private val passwordAttribute = TemplateAttribute(TemplateField.LABEL_PASSWORD, TemplateAttributeType.TEXT, true)
private val ssidAttribute = TemplateAttribute(TemplateField.LABEL_SSID, TemplateAttributeType.TEXT)
private val wirelessTypeAttribute = TemplateAttribute(
TemplateField.LABEL_TYPE,
TemplateAttributeType.LIST,
false,
TemplateAttributeOption().apply{
setListItems("WPA3", "WPA2", "WPA", "WEP")
})
private val tokenAttribute = TemplateAttribute(TemplateField.LABEL_TOKEN, TemplateAttributeType.TEXT)
private val publicKeyAttribute = TemplateAttribute(TemplateField.LABEL_PUBLIC_KEY, TemplateAttributeType.TEXT)
private val privateKeyAttribute = TemplateAttribute(TemplateField.LABEL_PRIVATE_KEY, TemplateAttributeType.TEXT, true)
@@ -68,6 +75,7 @@ class TemplateBuilder {
val mainSection = TemplateSection(mutableListOf<TemplateAttribute>().apply {
add(ssidAttribute)
add(passwordAttribute)
add(wirelessTypeAttribute)
})
sections.add(mainSection)
return Template(
@@ -206,7 +206,7 @@ class TemplateEngineCompatible(database: DatabaseKDBX): TemplateEngine(database)
try {
// Default attribute option is items of the list
val items = defaultOption.split(",")
attribute.options.setListItems(items)
attribute.options.setListItems(*items.toTypedArray())
} catch (e: Exception) {
Log.e(TAG, "Unable to transform default list option", e)
}
@@ -29,6 +29,7 @@ object TemplateField {
const val LABEL_EMAIL_ADDRESS = "Email address"
const val LABEL_WIRELESS = "Wifi"
const val LABEL_SSID = "SSID"
const val LABEL_TYPE = "Type"
const val LABEL_CRYPTOCURRENCY = "Cryptocurrency wallet"
const val LABEL_TOKEN = "Token"
const val LABEL_PUBLIC_KEY = "Public key"
@@ -82,6 +83,7 @@ object TemplateField {
LABEL_EMAIL_ADDRESS.equals(name, true) -> context.getString(R.string.email_address)
LABEL_WIRELESS.equals(name, true) -> context.getString(R.string.wireless)
LABEL_SSID.equals(name, true) -> context.getString(R.string.ssid)
LABEL_TYPE.equals(name, true) -> context.getString(R.string.type)
LABEL_CRYPTOCURRENCY.equals(name, true) -> context.getString(R.string.cryptocurrency)
LABEL_TOKEN.equals(name, true) -> context.getString(R.string.token)
LABEL_PUBLIC_KEY.equals(name, true) -> context.getString(R.string.public_key)