diff --git a/app/src/main/java/com/kunzisoft/keepass/adapters/BreadcrumbAdapter.kt b/app/src/main/java/com/kunzisoft/keepass/adapters/BreadcrumbAdapter.kt index 5e39ebf00..6b0dafb2b 100644 --- a/app/src/main/java/com/kunzisoft/keepass/adapters/BreadcrumbAdapter.kt +++ b/app/src/main/java/com/kunzisoft/keepass/adapters/BreadcrumbAdapter.kt @@ -117,7 +117,7 @@ class BreadcrumbAdapter(val context: Context) PreferencesUtil.showExpiredEntries(context) ) ) - text = group.numberOfChildEntries.toString() + text = group.recursiveNumberOfChildEntries.toString() visibility = View.VISIBLE } else { visibility = View.GONE diff --git a/app/src/main/java/com/kunzisoft/keepass/adapters/NodesAdapter.kt b/app/src/main/java/com/kunzisoft/keepass/adapters/NodesAdapter.kt index e5638cd37..fc47ca14f 100644 --- a/app/src/main/java/com/kunzisoft/keepass/adapters/NodesAdapter.kt +++ b/app/src/main/java/com/kunzisoft/keepass/adapters/NodesAdapter.kt @@ -197,6 +197,7 @@ class NodesAdapter ( && oldItem.containsAttachment() == newItem.containsAttachment() } else if (oldItem is Group && newItem is Group) { typeContentTheSame = oldItem.numberOfChildEntries == newItem.numberOfChildEntries + && oldItem.recursiveNumberOfChildEntries == newItem.recursiveNumberOfChildEntries && oldItem.notes == newItem.notes } return typeContentTheSame @@ -472,7 +473,7 @@ class NodesAdapter ( if (mShowNumberEntries) { holder.numberChildren?.apply { text = (subNode as Group) - .numberOfChildEntries + .recursiveNumberOfChildEntries .toString() setTextSize(mTextSizeUnit, mNumberChildrenTextDefaultDimension, mPrefSizeMultiplier) visibility = View.VISIBLE diff --git a/database/src/main/java/com/kunzisoft/keepass/database/element/Group.kt b/database/src/main/java/com/kunzisoft/keepass/database/element/Group.kt index 5d38dd9ff..f1ce2d1b1 100644 --- a/database/src/main/java/com/kunzisoft/keepass/database/element/Group.kt +++ b/database/src/main/java/com/kunzisoft/keepass/database/element/Group.kt @@ -46,6 +46,7 @@ class Group : Node, GroupVersionedInterface { var isVirtual = false var numberOfChildEntries: Int = 0 + var recursiveNumberOfChildEntries: Int = 0 /** * Use this constructor to copy a Group @@ -332,6 +333,18 @@ class Group : Node, GroupVersionedInterface { fun refreshNumberOfChildEntries(filters: Array = emptyArray()) { this.numberOfChildEntries = getFilteredChildEntries(filters).size + this.recursiveNumberOfChildEntries = getFilteredChildEntriesInGroups(filters) + } + + /** + * @return the cumulative number of entries in the current group and its children + */ + private fun getFilteredChildEntriesInGroups(filters: Array): Int { + var counter = 0 + getChildGroups().forEach { childGroup -> + counter += childGroup.getFilteredChildEntriesInGroups(filters) + } + return getFilteredChildEntries(filters).size + counter } /**