recycler bin title

This commit is contained in:
GianpaMX committed 2022-10-26 16:37:08 +01:00
1 parent 9e0b6fa800
commit 2206184bcb
8 files changed
+18 -17

No files matched your search

@@ -30,6 +30,7 @@ import com.kunzisoft.keepass.hardware.HardwareKey
class DeleteNodesRunnable(context: Context,
database: Database,
private val mNodesToDelete: List<Node>,
private val recyclerBinTitle: String,
save: Boolean,
afterActionNodesFinish: AfterActionNodesFinish,
challengeResponseRetriever: (HardwareKey, ByteArray?) -> ByteArray)
@@ -54,7 +55,7 @@ class DeleteNodesRunnable(context: Context,
// Remove Node from parent
mCanRecycle = database.canRecycle(groupToDelete)
if (mCanRecycle) {
database.recycle(groupToDelete, context.resources)
database.recycle(groupToDelete, recyclerBinTitle)
groupToDelete.setPreviousParentGroup(mOldParent)
groupToDelete.touch(modified = true, touchParents = true)
} else {
@@ -68,7 +69,7 @@ class DeleteNodesRunnable(context: Context,
// Remove Node from parent
mCanRecycle = database.canRecycle(entryToDelete)
if (mCanRecycle) {
database.recycle(entryToDelete, context.resources)
database.recycle(entryToDelete, recyclerBinTitle)
entryToDelete.setPreviousParentGroup(mOldParent)
entryToDelete.touch(modified = true, touchParents = true)
} else {
@@ -466,10 +466,10 @@ class Database(private val iconPackChooser: InterfaceIconPackChooser) {
// Backup is always enabled in KDB database
get() = mDatabaseKDB != null || mDatabaseKDBX?.isRecycleBinEnabled ?: false
fun enableRecycleBin(enable: Boolean, resources: Resources) {
fun enableRecycleBin(enable: Boolean, recyclerBinTitle: String) {
mDatabaseKDBX?.isRecycleBinEnabled = enable
if (enable) {
ensureRecycleBinExists(resources)
ensureRecycleBinExists(recyclerBinTitle)
} else {
mDatabaseKDBX?.removeRecycleBin()
}
@@ -1221,9 +1221,9 @@ class Database(private val iconPackChooser: InterfaceIconPackChooser) {
})
}
fun ensureRecycleBinExists(resources: Resources) {
fun ensureRecycleBinExists(recyclerBinTitle: String) {
mDatabaseKDB?.ensureBackupExists()
mDatabaseKDBX?.ensureRecycleBinExists(resources)
mDatabaseKDBX?.ensureRecycleBinExists(recyclerBinTitle)
}
fun canRecycle(entry: Entry): Boolean {
@@ -1248,8 +1248,8 @@ class Database(private val iconPackChooser: InterfaceIconPackChooser) {
return canRecycle ?: false
}
fun recycle(entry: Entry, resources: Resources) {
ensureRecycleBinExists(resources)
fun recycle(entry: Entry, recyclerBinTitle: String) {
ensureRecycleBinExists(recyclerBinTitle)
entry.parent?.let { parent ->
removeEntryFrom(entry, parent)
}
@@ -1259,8 +1259,8 @@ class Database(private val iconPackChooser: InterfaceIconPackChooser) {
entry.afterAssignNewParent()
}
fun recycle(group: Group, resources: Resources) {
ensureRecycleBinExists(resources)
fun recycle(group: Group, recyclerBinTitle: String) {
ensureRecycleBinExists(recyclerBinTitle)
group.parent?.let { parent ->
removeGroupFrom(group, parent)
}
@@ -753,15 +753,15 @@ class DatabaseKDBX : DatabaseVersioned<UUID, UUID, GroupKDBX, EntryKDBX> {
* Ensure that the recycle bin tree exists, if enabled and create it
* if it doesn't exist
*/
fun ensureRecycleBinExists(resources: Resources) {
fun ensureRecycleBinExists(recyclerBinTitle: String) {
if (recycleBin == null) {
// Create recycle bin only if a group with a valid name don't already exists
val firstGroupWithValidName = getGroupIndexes().firstOrNull {
it.title == resources.getString(R.string.recycle_bin)
it.title == recyclerBinTitle
}
val recycleBinGroup = if (firstGroupWithValidName == null) {
val newRecycleBinGroup = createGroup().apply {
title = resources.getString(R.string.recycle_bin)
title = recyclerBinTitle
icon.standard = getStandardIcon(IconImageStandard.TRASH_ID)
enableAutoType = false
enableSearching = false