mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-04-04 21:37:37 +03:00
feat: Number of children #421
This commit is contained in:
parent
0312b504a9
commit
9fb4754430
12 changed files with 72 additions and 38 deletions
|
@ -2,6 +2,7 @@ KeePassDX(4.1.0)
|
|||
* Upgrade to API 34 (Android 14) #1730
|
||||
* Generate keyfile #1290
|
||||
* Hide template group #1894
|
||||
* Group count sum recursively #421
|
||||
* Small fixes #1711 #1831 #1780 #1821 #1863
|
||||
|
||||
KeePassDX(4.0.8)
|
||||
|
|
|
@ -115,7 +115,7 @@ class BreadcrumbAdapter(val context: Context, val database: Database?)
|
|||
|
||||
holder.groupNumbersView?.apply {
|
||||
if (mShowNumberEntries) {
|
||||
text = group.getNumberOfChildEntries {
|
||||
text = group.getNumberOfChildEntries(mNodeFilter.recursiveNumberOfEntries) {
|
||||
mNodeFilter.getFilter(node)
|
||||
}.toString()
|
||||
visibility = View.VISIBLE
|
||||
|
|
|
@ -11,6 +11,8 @@ class NodeFilter(
|
|||
context: Context,
|
||||
var database: Database? = null
|
||||
) {
|
||||
var recursiveNumberOfEntries = PreferencesUtil.recursiveNumberEntries(context)
|
||||
private set
|
||||
private var showExpired = PreferencesUtil.showExpiredEntries(context)
|
||||
private var showTemplate = PreferencesUtil.showTemplates(context)
|
||||
|
||||
|
@ -18,9 +20,6 @@ class NodeFilter(
|
|||
return (when (node) {
|
||||
is Entry -> {
|
||||
node.entryKDB?.isMetaStream() != true
|
||||
&& (showTemplate || database?.templatesGroup?.let {
|
||||
template -> node.isContainedIn(template)
|
||||
} != true)
|
||||
}
|
||||
is Group -> {
|
||||
showTemplate || database?.templatesGroup != node
|
||||
|
|
|
@ -474,7 +474,9 @@ class NodesAdapter (
|
|||
if (mShowNumberEntries) {
|
||||
holder.numberChildren?.apply {
|
||||
text = (subNode as Group)
|
||||
.getNumberOfChildEntries { mNodeFilter.getFilter(subNode) }
|
||||
.getNumberOfChildEntries(mNodeFilter.recursiveNumberOfEntries) {
|
||||
mNodeFilter.getFilter(subNode)
|
||||
}
|
||||
.toString()
|
||||
setTextSize(mTextSizeUnit, mNumberChildrenTextDefaultDimension, mPrefSizeMultiplier)
|
||||
visibility = View.VISIBLE
|
||||
|
|
|
@ -483,13 +483,15 @@ class NestedAppSettingsFragment : NestedSettingsFragment() {
|
|||
getString(R.string.setting_style_brightness_key),
|
||||
getString(R.string.setting_icon_pack_choose_key),
|
||||
getString(R.string.show_entry_colors_key),
|
||||
getString(R.string.hide_expired_entries_key),
|
||||
getString(R.string.hide_templates_key),
|
||||
getString(R.string.list_entries_show_username_key),
|
||||
getString(R.string.list_groups_show_number_entries_key),
|
||||
getString(R.string.recursive_number_entries_key),
|
||||
getString(R.string.show_otp_token_key),
|
||||
getString(R.string.show_uuid_key),
|
||||
getString(R.string.list_size_key),
|
||||
getString(R.string.monospace_font_fields_enable_key),
|
||||
getString(R.string.hide_expired_entries_key),
|
||||
getString(R.string.enable_education_screens_key),
|
||||
getString(R.string.reset_education_screens_key) -> {
|
||||
DATABASE_PREFERENCE_CHANGED = true
|
||||
|
|
|
@ -120,6 +120,18 @@ object PreferencesUtil {
|
|||
context.resources.getBoolean(R.bool.show_entry_colors_default))
|
||||
}
|
||||
|
||||
fun showExpiredEntries(context: Context): Boolean {
|
||||
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
return ! prefs.getBoolean(context.getString(R.string.hide_expired_entries_key),
|
||||
context.resources.getBoolean(R.bool.hide_expired_entries_default))
|
||||
}
|
||||
|
||||
fun showTemplates(context: Context): Boolean {
|
||||
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
return ! prefs.getBoolean(context.getString(R.string.hide_templates_key),
|
||||
context.resources.getBoolean(R.bool.hide_templates_default))
|
||||
}
|
||||
|
||||
fun hideProtectedValue(context: Context): Boolean {
|
||||
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
return prefs.getBoolean(context.getString(R.string.hide_password_key),
|
||||
|
@ -144,6 +156,12 @@ object PreferencesUtil {
|
|||
context.resources.getBoolean(R.bool.list_groups_show_number_entries_default))
|
||||
}
|
||||
|
||||
fun recursiveNumberEntries(context: Context): Boolean {
|
||||
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
return prefs.getBoolean(context.getString(R.string.recursive_number_entries_key),
|
||||
context.resources.getBoolean(R.bool.recursive_number_entries_default))
|
||||
}
|
||||
|
||||
fun showOTPToken(context: Context): Boolean {
|
||||
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
return prefs.getBoolean(context.getString(R.string.show_otp_token_key),
|
||||
|
@ -156,18 +174,6 @@ object PreferencesUtil {
|
|||
context.resources.getBoolean(R.bool.show_uuid_default))
|
||||
}
|
||||
|
||||
fun showExpiredEntries(context: Context): Boolean {
|
||||
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
return ! prefs.getBoolean(context.getString(R.string.hide_expired_entries_key),
|
||||
context.resources.getBoolean(R.bool.hide_expired_entries_default))
|
||||
}
|
||||
|
||||
fun showTemplates(context: Context): Boolean {
|
||||
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
return ! prefs.getBoolean(context.getString(R.string.hide_templates_key),
|
||||
context.resources.getBoolean(R.bool.hide_templates_default))
|
||||
}
|
||||
|
||||
fun getStyle(context: Context): String {
|
||||
val defaultStyleString = Stylish.defaultStyle(context)
|
||||
val styleString = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
|
@ -847,15 +853,17 @@ object PreferencesUtil {
|
|||
context.getString(R.string.setting_style_brightness_key) -> editor.putString(name, value)
|
||||
context.getString(R.string.setting_icon_pack_choose_key) -> editor.putString(name, value)
|
||||
context.getString(R.string.show_entry_colors_key) -> editor.putBoolean(name, value.toBoolean())
|
||||
context.getString(R.string.hide_expired_entries_key) -> editor.putBoolean(name, value.toBoolean())
|
||||
context.getString(R.string.hide_templates_key) -> editor.putBoolean(name, value.toBoolean())
|
||||
context.getString(R.string.hide_password_key) -> editor.putBoolean(name, value.toBoolean())
|
||||
context.getString(R.string.colorize_password_key) -> editor.putBoolean(name, value.toBoolean())
|
||||
context.getString(R.string.list_entries_show_username_key) -> editor.putBoolean(name, value.toBoolean())
|
||||
context.getString(R.string.list_groups_show_number_entries_key) -> editor.putBoolean(name, value.toBoolean())
|
||||
context.getString(R.string.recursive_number_entries_key) -> editor.putBoolean(name, value.toBoolean())
|
||||
context.getString(R.string.show_otp_token_key) -> editor.putBoolean(name, value.toBoolean())
|
||||
context.getString(R.string.show_uuid_key) -> editor.putBoolean(name, value.toBoolean())
|
||||
context.getString(R.string.list_size_key) -> editor.putString(name, value)
|
||||
context.getString(R.string.monospace_font_fields_enable_key) -> editor.putBoolean(name, value.toBoolean())
|
||||
context.getString(R.string.hide_expired_entries_key) -> editor.putBoolean(name, value.toBoolean())
|
||||
context.getString(R.string.enable_education_screens_key) -> editor.putBoolean(name, value.toBoolean())
|
||||
|
||||
context.getString(R.string.password_generator_length_key) -> editor.putInt(name, value.toInt())
|
||||
|
|
|
@ -186,6 +186,10 @@
|
|||
<string name="setting_icon_pack_choose_key" translatable="false">setting_icon_pack_choose_key</string>
|
||||
<string name="show_entry_colors_key" translatable="false">show_entry_colors_key</string>
|
||||
<bool name="show_entry_colors_default" translatable="false">true</bool>
|
||||
<string name="hide_expired_entries_key" translatable="false">hide_expired_entries_key</string>
|
||||
<bool name="hide_expired_entries_default" translatable="false">false</bool>
|
||||
<string name="hide_templates_key" translatable="false">hide_templates_key</string>
|
||||
<bool name="hide_templates_default" translatable="false">true</bool>
|
||||
<string name="hide_password_key" translatable="false">hide_password_key</string>
|
||||
<bool name="hide_password_default" translatable="false">true</bool>
|
||||
<string name="colorize_password_key" translatable="false">colorize_password_key</string>
|
||||
|
@ -194,6 +198,8 @@
|
|||
<bool name="list_entries_show_username_default" translatable="false">true</bool>
|
||||
<string name="list_groups_show_number_entries_key" translatable="false">list_groups_show_number_entries_key</string>
|
||||
<bool name="list_groups_show_number_entries_default" translatable="false">true</bool>
|
||||
<string name="recursive_number_entries_key" translatable="false">recursive_number_entries_key</string>
|
||||
<bool name="recursive_number_entries_default" translatable="false">true</bool>
|
||||
<string name="show_otp_token_key" translatable="false">show_otp_token_key</string>
|
||||
<bool name="show_otp_token_default" translatable="false">true</bool>
|
||||
<string name="show_uuid_key" translatable="false">show_uuid_key</string>
|
||||
|
@ -201,10 +207,6 @@
|
|||
<string name="list_size_key" translatable="false">list_size_key</string>
|
||||
<string name="monospace_font_fields_enable_key" translatable="false">monospace_font_extra_fields_enable_key</string>
|
||||
<bool name="monospace_font_fields_enable_default" translatable="false">true</bool>
|
||||
<string name="hide_expired_entries_key" translatable="false">hide_expired_entries_key</string>
|
||||
<bool name="hide_expired_entries_default" translatable="false">false</bool>
|
||||
<string name="hide_templates_key" translatable="false">hide_templates_key</string>
|
||||
<bool name="hide_templates_default" translatable="false">true</bool>
|
||||
<string name="enable_education_screens_key" translatable="false">enable_education_screens_key</string>
|
||||
<bool name="enable_education_screens_default" translatable="false">true</bool>
|
||||
<string name="reset_education_screens_key" translatable="false">relaunch_education_screens_key</string>
|
||||
|
|
|
@ -232,6 +232,7 @@
|
|||
<string name="invalid_db_sig">Could not recognize the database format.</string>
|
||||
<string name="keyfile_is_empty">The keyfile is empty.</string>
|
||||
<string name="length">Length</string>
|
||||
<string name="nodes">Nodes</string>
|
||||
<string name="hide_password_title">Hide passwords</string>
|
||||
<string name="hide_password_summary">Mask passwords (***) by default</string>
|
||||
<string name="colorize_password_title">Colorize passwords</string>
|
||||
|
@ -239,11 +240,13 @@
|
|||
<string name="list_entries_show_username_title">Show usernames</string>
|
||||
<string name="list_entries_show_username_summary">Displays usernames in entry lists</string>
|
||||
<string name="list_groups_show_number_entries_title">Show number of entries</string>
|
||||
<string name="list_groups_show_number_entries_summary">Displays the number of entries in a group</string>
|
||||
<string name="recursive_number_entries_title">Recursive number of entries</string>
|
||||
<string name="recursive_number_entries_summary">Recursively calculates the number of entries in a group</string>
|
||||
<string name="show_otp_token_title">Show OTP Token</string>
|
||||
<string name="show_otp_token_summary">Displays OTP tokens in the list of entries</string>
|
||||
<string name="show_uuid_title">Show UUID</string>
|
||||
<string name="show_uuid_summary">Displays the UUID linked to an entry or a group</string>
|
||||
<string name="list_groups_show_number_entries_summary">Displays the number of entries in a group</string>
|
||||
<string name="list_size_title">Size of list items</string>
|
||||
<string name="list_size_summary">Text size in the element list</string>
|
||||
<string name="creating_database">Creating database…</string>
|
||||
|
|
|
@ -48,6 +48,22 @@
|
|||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="@string/nodes">
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:key="@string/hide_expired_entries_key"
|
||||
android:title="@string/hide_expired_entries_title"
|
||||
android:summary="@string/hide_expired_entries_summary"
|
||||
android:defaultValue="@bool/hide_expired_entries_default"/>
|
||||
<SwitchPreferenceCompat
|
||||
android:key="@string/hide_templates_key"
|
||||
android:title="@string/hide_templates_title"
|
||||
android:summary="@string/hide_templates_summary"
|
||||
android:defaultValue="@bool/hide_templates_default"/>
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="@string/password">
|
||||
|
||||
|
@ -77,6 +93,12 @@
|
|||
android:title="@string/list_groups_show_number_entries_title"
|
||||
android:summary="@string/list_groups_show_number_entries_summary"
|
||||
android:defaultValue="@bool/list_groups_show_number_entries_default"/>
|
||||
<SwitchPreferenceCompat
|
||||
android:key="@string/recursive_number_entries_key"
|
||||
android:dependency="@string/list_groups_show_number_entries_key"
|
||||
android:title="@string/recursive_number_entries_title"
|
||||
android:summary="@string/recursive_number_entries_summary"
|
||||
android:defaultValue="@bool/recursive_number_entries_default"/>
|
||||
<SwitchPreferenceCompat
|
||||
android:key="@string/show_otp_token_key"
|
||||
android:title="@string/show_otp_token_title"
|
||||
|
@ -106,16 +128,6 @@
|
|||
<PreferenceCategory
|
||||
android:title="@string/other">
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:key="@string/hide_expired_entries_key"
|
||||
android:title="@string/hide_expired_entries_title"
|
||||
android:summary="@string/hide_expired_entries_summary"
|
||||
android:defaultValue="@bool/hide_expired_entries_default"/>
|
||||
<SwitchPreferenceCompat
|
||||
android:key="@string/hide_templates_key"
|
||||
android:title="@string/hide_templates_title"
|
||||
android:summary="@string/hide_templates_summary"
|
||||
android:defaultValue="@bool/hide_templates_default"/>
|
||||
<SwitchPreferenceCompat
|
||||
android:key="@string/enable_education_screens_key"
|
||||
android:title="@string/enable_education_screens_title"
|
||||
|
|
|
@ -295,19 +295,19 @@ class Group : Node, GroupVersionedInterface<Group, Entry> {
|
|||
*/
|
||||
private fun getNumberOfChildEntriesInGroups(filter: (Node) -> Boolean): Int {
|
||||
var counter = 0
|
||||
getChildGroups().forEach { childGroup ->
|
||||
getChildGroups().filter(filter).forEach { childGroup ->
|
||||
counter += childGroup.getNumberOfChildEntriesInGroups(filter)
|
||||
}
|
||||
return getChildEntries().filter(filter).size + counter
|
||||
}
|
||||
|
||||
fun getNumberOfChildEntries(
|
||||
directChildren: Boolean = true,
|
||||
recursive: Boolean = false,
|
||||
filter: (Node) -> Boolean = { true }
|
||||
): Int {
|
||||
numberOfChildEntries = getChildEntries().filter(filter).size
|
||||
recursiveNumberOfChildEntries = getNumberOfChildEntriesInGroups(filter)
|
||||
return if (directChildren) numberOfChildEntries else recursiveNumberOfChildEntries
|
||||
return if (recursive) recursiveNumberOfChildEntries else numberOfChildEntries
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
* Upgrade to API 34 (Android 14) #1730
|
||||
* Generate keyfile #1290
|
||||
* Hide template group #1894
|
||||
* Group count sum recursively #421
|
||||
* Small fixes #1711 #1831 #1780 #1821 #1863
|
|
@ -1 +1,5 @@
|
|||
* Mise à jour vers API 34 (Android 14)
|
||||
* Génération de fichier de clé #1290
|
||||
* Cacher les groupes de modèles #1894
|
||||
* Somme de comptage de groupes de manière récursive #421
|
||||
* Petites corrections #1711 #1831 #1780 #1821 #1863
|
Loading…
Add table
Add a link
Reference in a new issue