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)
|
return this.iconsManager.getIcon(iconUuid)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun containsCustomIcons(): Boolean {
|
|
||||||
return this.iconsManager.containsAnyCustomIcon()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun putCustomData(label: String, value: String) {
|
fun putCustomData(label: String, value: String) {
|
||||||
this.customData[label] = value
|
this.customData[label] = value
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,10 +69,6 @@ class IconsManager {
|
|||||||
return listIcons
|
return listIcons
|
||||||
}
|
}
|
||||||
|
|
||||||
fun containsAnyCustomIcon(): Boolean {
|
|
||||||
return !customCache.isEmpty()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun removeCustomIcon(iconUuid: UUID) {
|
fun removeCustomIcon(iconUuid: UUID) {
|
||||||
val binary = customCache[iconUuid]
|
val binary = customCache[iconUuid]
|
||||||
customCache.remove(iconUuid)
|
customCache.remove(iconUuid)
|
||||||
|
|||||||
@@ -697,11 +697,14 @@ class DatabaseOutputKDBX(private val mDatabaseKDBX: DatabaseKDBX,
|
|||||||
|
|
||||||
@Throws(IllegalArgumentException::class, IllegalStateException::class, IOException::class)
|
@Throws(IllegalArgumentException::class, IllegalStateException::class, IOException::class)
|
||||||
private fun writeCustomIconList() {
|
private fun writeCustomIconList() {
|
||||||
if (!mDatabaseKDBX.containsCustomIcons()) return
|
var firstElement = true
|
||||||
|
|
||||||
xml.startTag(null, DatabaseKDBXXML.ElemCustomIcons)
|
|
||||||
|
|
||||||
mDatabaseKDBX.iconsManager.doForEachCustomIconWithoutBinaryDuplication { iconCustom ->
|
mDatabaseKDBX.iconsManager.doForEachCustomIconWithoutBinaryDuplication { iconCustom ->
|
||||||
|
// Write the parent tag
|
||||||
|
if (firstElement) {
|
||||||
|
xml.startTag(null, DatabaseKDBXXML.ElemCustomIcons)
|
||||||
|
firstElement = false
|
||||||
|
}
|
||||||
|
|
||||||
xml.startTag(null, DatabaseKDBXXML.ElemCustomIconItem)
|
xml.startTag(null, DatabaseKDBXXML.ElemCustomIconItem)
|
||||||
|
|
||||||
writeUuid(DatabaseKDBXXML.ElemCustomIconItemID, iconCustom.uuid)
|
writeUuid(DatabaseKDBXXML.ElemCustomIconItemID, iconCustom.uuid)
|
||||||
@@ -716,7 +719,10 @@ class DatabaseOutputKDBX(private val mDatabaseKDBX: DatabaseKDBX,
|
|||||||
xml.endTag(null, DatabaseKDBXXML.ElemCustomIconItem)
|
xml.endTag(null, DatabaseKDBXXML.ElemCustomIconItem)
|
||||||
}
|
}
|
||||||
|
|
||||||
xml.endTag(null, DatabaseKDBXXML.ElemCustomIcons)
|
// Close the parent tag
|
||||||
|
if (!firstElement) {
|
||||||
|
xml.endTag(null, DatabaseKDBXXML.ElemCustomIcons)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun safeXmlString(text: String): String {
|
private fun safeXmlString(text: String): String {
|
||||||
|
|||||||
Reference in New Issue
Block a user