mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Fix update group
This commit is contained in:
@@ -111,7 +111,7 @@ class EntryEditActivity : LockingHideActivity(),
|
|||||||
// Create a copy to modify
|
// Create a copy to modify
|
||||||
mNewEntry = EntryVersioned(entry).also { newEntry ->
|
mNewEntry = EntryVersioned(entry).also { newEntry ->
|
||||||
// WARNING Remove the parent to keep memory with parcelable
|
// WARNING Remove the parent to keep memory with parcelable
|
||||||
newEntry.parent = null
|
newEntry.removeParent()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -749,11 +749,15 @@ class GroupActivity : LockingActivity(),
|
|||||||
// If update add new elements
|
// If update add new elements
|
||||||
mOldGroupToUpdate?.let { oldGroupToUpdate ->
|
mOldGroupToUpdate?.let { oldGroupToUpdate ->
|
||||||
GroupVersioned(oldGroupToUpdate).let { updateGroup ->
|
GroupVersioned(oldGroupToUpdate).let { updateGroup ->
|
||||||
updateGroup.title = name
|
updateGroup.apply {
|
||||||
// TODO custom icon
|
// WARNING remove parent and children to keep memory
|
||||||
updateGroup.icon = icon
|
removeParent()
|
||||||
|
removeChildren()
|
||||||
|
|
||||||
|
title = name
|
||||||
|
this.icon = icon // TODO custom icon
|
||||||
|
}
|
||||||
|
|
||||||
mListNodesFragment?.removeNode(oldGroupToUpdate)
|
|
||||||
// If group updated save it in the database
|
// If group updated save it in the database
|
||||||
progressDialogThread?.startDatabaseUpdateGroup(
|
progressDialogThread?.startDatabaseUpdateGroup(
|
||||||
oldGroupToUpdate, updateGroup, !mReadOnly)
|
oldGroupToUpdate, updateGroup, !mReadOnly)
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class UpdateEntryRunnable constructor(
|
|||||||
|
|
||||||
override fun nodeAction() {
|
override fun nodeAction() {
|
||||||
// WARNING : Re attribute parent removed in entry edit activity to save memory
|
// WARNING : Re attribute parent removed in entry edit activity to save memory
|
||||||
mNewEntry.parent = mOldEntry.parent
|
mNewEntry.addParentFrom(mOldEntry)
|
||||||
|
|
||||||
// Update entry with new values
|
// Update entry with new values
|
||||||
mOldEntry.updateWith(mNewEntry)
|
mOldEntry.updateWith(mNewEntry)
|
||||||
@@ -46,10 +46,9 @@ class UpdateEntryRunnable constructor(
|
|||||||
|
|
||||||
// Create an entry history (an entry history don't have history)
|
// Create an entry history (an entry history don't have history)
|
||||||
mOldEntry.addEntryToHistory(EntryVersioned(mBackupEntryHistory, copyHistory = false))
|
mOldEntry.addEntryToHistory(EntryVersioned(mBackupEntryHistory, copyHistory = false))
|
||||||
|
|
||||||
database.removeOldestHistory(mOldEntry)
|
database.removeOldestHistory(mOldEntry)
|
||||||
|
|
||||||
// Only change data un index
|
// Only change data in index
|
||||||
database.updateEntry(mOldEntry)
|
database.updateEntry(mOldEntry)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,11 +37,15 @@ class UpdateGroupRunnable constructor(
|
|||||||
private val mBackupGroup: GroupVersioned = GroupVersioned(mOldGroup)
|
private val mBackupGroup: GroupVersioned = GroupVersioned(mOldGroup)
|
||||||
|
|
||||||
override fun nodeAction() {
|
override fun nodeAction() {
|
||||||
|
// WARNING : Re attribute parent and children removed in group activity to save memory
|
||||||
|
mNewGroup.addParentFrom(mOldGroup)
|
||||||
|
mNewGroup.addChildrenFrom(mOldGroup)
|
||||||
|
|
||||||
// Update group with new values
|
// Update group with new values
|
||||||
mOldGroup.updateWith(mNewGroup)
|
mOldGroup.updateWith(mNewGroup)
|
||||||
mOldGroup.touch(modified = true, touchParents = true)
|
mOldGroup.touch(modified = true, touchParents = true)
|
||||||
|
|
||||||
// Only change data un index
|
// Only change data in index
|
||||||
database.updateGroup(mOldGroup)
|
database.updateGroup(mOldGroup)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -114,6 +114,38 @@ class GroupVersioned : NodeVersioned, PwGroupInterface<GroupVersioned, EntryVers
|
|||||||
pwGroupV4?.afterAssignNewParent()
|
pwGroupV4?.afterAssignNewParent()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun addChildrenFrom(group: GroupVersioned) {
|
||||||
|
group.pwGroupV3?.getChildEntries()?.forEach { entryToAdd ->
|
||||||
|
pwGroupV3?.addChildEntry(entryToAdd)
|
||||||
|
}
|
||||||
|
group.pwGroupV3?.getChildGroups()?.forEach { groupToAdd ->
|
||||||
|
pwGroupV3?.addChildGroup(groupToAdd)
|
||||||
|
}
|
||||||
|
|
||||||
|
group.pwGroupV4?.getChildEntries()?.forEach { entryToAdd ->
|
||||||
|
pwGroupV4?.addChildEntry(entryToAdd)
|
||||||
|
}
|
||||||
|
group.pwGroupV4?.getChildGroups()?.forEach { groupToAdd ->
|
||||||
|
pwGroupV4?.addChildGroup(groupToAdd)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun removeChildren() {
|
||||||
|
pwGroupV3?.getChildEntries()?.forEach { entryToRemove ->
|
||||||
|
pwGroupV3?.removeChildEntry(entryToRemove)
|
||||||
|
}
|
||||||
|
pwGroupV3?.getChildGroups()?.forEach { groupToRemove ->
|
||||||
|
pwGroupV3?.removeChildGroup(groupToRemove)
|
||||||
|
}
|
||||||
|
|
||||||
|
pwGroupV4?.getChildEntries()?.forEach { entryToRemove ->
|
||||||
|
pwGroupV4?.removeChildEntry(entryToRemove)
|
||||||
|
}
|
||||||
|
pwGroupV4?.getChildGroups()?.forEach { groupToRemove ->
|
||||||
|
pwGroupV4?.removeChildGroup(groupToRemove)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun touch(modified: Boolean, touchParents: Boolean) {
|
override fun touch(modified: Boolean, touchParents: Boolean) {
|
||||||
pwGroupV3?.touch(modified, touchParents)
|
pwGroupV3?.touch(modified, touchParents)
|
||||||
pwGroupV4?.touch(modified, touchParents)
|
pwGroupV4?.touch(modified, touchParents)
|
||||||
|
|||||||
@@ -14,6 +14,14 @@ interface NodeVersioned: PwNodeInterface<GroupVersioned> {
|
|||||||
}
|
}
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun addParentFrom(node: NodeVersioned) {
|
||||||
|
parent = node.parent
|
||||||
|
}
|
||||||
|
|
||||||
|
fun removeParent() {
|
||||||
|
parent = null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user