mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Better XML writing for custom icons
This commit is contained in:
@@ -322,10 +322,6 @@ class DatabaseKDBX : DatabaseVersioned<UUID, UUID, GroupKDBX, EntryKDBX> {
|
||||
return this.iconsManager.getIcon(iconUuid)
|
||||
}
|
||||
|
||||
fun containsCustomIcons(): Boolean {
|
||||
return this.iconsManager.containsAnyCustomIcon()
|
||||
}
|
||||
|
||||
fun putCustomData(label: String, value: String) {
|
||||
this.customData[label] = value
|
||||
}
|
||||
|
||||
@@ -69,10 +69,6 @@ class IconsManager {
|
||||
return listIcons
|
||||
}
|
||||
|
||||
fun containsAnyCustomIcon(): Boolean {
|
||||
return !customCache.isEmpty()
|
||||
}
|
||||
|
||||
fun removeCustomIcon(iconUuid: UUID) {
|
||||
val binary = customCache[iconUuid]
|
||||
customCache.remove(iconUuid)
|
||||
|
||||
@@ -697,11 +697,14 @@ class DatabaseOutputKDBX(private val mDatabaseKDBX: DatabaseKDBX,
|
||||
|
||||
@Throws(IllegalArgumentException::class, IllegalStateException::class, IOException::class)
|
||||
private fun writeCustomIconList() {
|
||||
if (!mDatabaseKDBX.containsCustomIcons()) return
|
||||
|
||||
xml.startTag(null, DatabaseKDBXXML.ElemCustomIcons)
|
||||
|
||||
var firstElement = true
|
||||
mDatabaseKDBX.iconsManager.doForEachCustomIconWithoutBinaryDuplication { iconCustom ->
|
||||
// Write the parent tag
|
||||
if (firstElement) {
|
||||
xml.startTag(null, DatabaseKDBXXML.ElemCustomIcons)
|
||||
firstElement = false
|
||||
}
|
||||
|
||||
xml.startTag(null, DatabaseKDBXXML.ElemCustomIconItem)
|
||||
|
||||
writeUuid(DatabaseKDBXXML.ElemCustomIconItemID, iconCustom.uuid)
|
||||
@@ -716,8 +719,11 @@ class DatabaseOutputKDBX(private val mDatabaseKDBX: DatabaseKDBX,
|
||||
xml.endTag(null, DatabaseKDBXXML.ElemCustomIconItem)
|
||||
}
|
||||
|
||||
// Close the parent tag
|
||||
if (!firstElement) {
|
||||
xml.endTag(null, DatabaseKDBXXML.ElemCustomIcons)
|
||||
}
|
||||
}
|
||||
|
||||
private fun safeXmlString(text: String): String {
|
||||
if (text.isEmpty()) {
|
||||
|
||||
Reference in New Issue
Block a user