Add number of entries in node view

This commit is contained in:
J-Jamet
2019-08-18 14:43:05 +02:00
parent f605d36adf
commit 639c6dc4ac
9 changed files with 64 additions and 2 deletions

View File

@@ -52,7 +52,8 @@ class NodeAdapter
private var ascendingSort: Boolean = true
private var groupsBeforeSort: Boolean = true
private var recycleBinBottomSort: Boolean = true
private var showUserNames: Boolean = false
private var showUserNames: Boolean = true
private var showNumberEntries: Boolean = true
private var nodeClickCallback: NodeClickCallback? = null
private var nodeMenuListener: NodeMenuListener? = null
@@ -129,6 +130,7 @@ class NodeAdapter
this.groupsBeforeSort = PreferencesUtil.getGroupsBeforeSort(context)
this.recycleBinBottomSort = PreferencesUtil.getRecycleBinBottomSort(context)
this.showUserNames = PreferencesUtil.showUsernamesListEntries(context)
this.showNumberEntries = PreferencesUtil.showNumberEntries(context)
}
/**
@@ -239,7 +241,14 @@ class NodeAdapter
holder.text.textSize = textSize
holder.subText.textSize = subtextSize
if (subNode.type == Type.GROUP) {
holder.numberChildren?.text = (subNode as GroupVersioned).getChildEntries().size.toString()
if (showNumberEntries) {
holder.numberChildren?.apply {
text = (subNode as GroupVersioned).getChildEntries().size.toString()
visibility = View.VISIBLE
}
} else {
holder.numberChildren?.visibility = View.GONE
}
}
}

View File

@@ -40,6 +40,12 @@ object PreferencesUtil {
context.resources.getBoolean(R.bool.list_entries_show_username_default))
}
fun showNumberEntries(context: Context): Boolean {
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
return prefs.getBoolean(context.getString(R.string.list_groups_show_number_entries_key),
context.resources.getBoolean(R.bool.list_groups_show_number_entries_default))
}
/**
* Retrieve the text size in SP, verify the integrity of the size stored in preference
*/

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<corners android:radius="25dp" />
<padding
android:left="4dp"
android:right="4dp"
android:top="1dp"
android:bottom="1dp"/>
<solid android:color="@color/orange"/>
</shape>
</item>
</layer-list>

View File

@@ -20,6 +20,7 @@
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/node_container"
android:layout_width="match_parent"
android:layout_height="wrap_content">
@@ -61,6 +62,7 @@
android:id="@+id/node_text"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
tools:text="Node Title"
android:lines="1"
android:singleLine="true"
style="@style/KeepassDXStyle.TextAppearance.Default" /> <!-- style override -->
@@ -69,6 +71,7 @@
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginTop="-4dp"
tools:text="Node SubTitle"
android:lines="1"
android:singleLine="true"
style="@style/KeepassDXStyle.TextAppearance.Secondary" /> <!-- style override -->

View File

@@ -20,6 +20,7 @@
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/node_container"
android:layout_width="match_parent"
android:layout_height="wrap_content">
@@ -57,6 +58,17 @@
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/group_arrow"
android:layout_toEndOf="@+id/group_arrow" />
<TextView
android:id="@+id/node_child_numbers"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="3"
android:layout_marginEnd="-18dp"
android:layout_marginRight="-18dp"
style="@style/KeepassDXStyle.TextAppearance.Info"
android:layout_toLeftOf="@+id/node_icon"
android:layout_toStartOf="@+id/node_icon"
android:layout_alignTop="@+id/node_icon" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -73,6 +85,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
tools:text="Node Title"
android:lines="1"
android:singleLine="true"
style="@style/KeepassDXStyle.TextAppearance.Title" /> <!-- style override -->
@@ -81,6 +94,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
tools:text="Node SubTitle"
android:layout_marginTop="-4dp"
android:lines="1"
android:singleLine="true"

View File

@@ -132,6 +132,8 @@
<string name="setting_icon_pack_choose_key" translatable="false">setting_icon_pack_choose_key</string>
<string name="list_entries_show_username_key" translatable="false">list_entries_show_username_key</string>
<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="list_size_key" translatable="false">list_size</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>

View File

@@ -113,6 +113,8 @@
<string name="length">Length</string>
<string name="list_entries_show_username_title">Show usernames</string>
<string name="list_entries_show_username_summary">Show 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">Show 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="loading_database">Loading database…</string>

View File

@@ -270,6 +270,13 @@
<item name="android:textColor">?attr/colorAccent</item>
</style>
<style name="KeepassDXStyle.TextAppearance.Info" parent="KeepassDXStyle.TextAppearance">
<item name="android:textSize">8sp</item>
<item name="android:textColor">@color/colorTextInverse</item>
<item name="android:background">@drawable/background_text_info</item>
<item name="backgroundTint">?attr/colorAccent</item>
</style>
<!-- Button Style -->
<style name="KeepassDXStyle.v21.Button" parent="Base.TextAppearance.AppCompat.Button">
<item name="android:gravity">center</item>

View File

@@ -44,6 +44,11 @@
android:title="@string/list_entries_show_username_title"
android:summary="@string/list_entries_show_username_summary"
android:defaultValue="@bool/list_entries_show_username_default"/>
<SwitchPreference
android:key="@string/list_groups_show_number_entries_key"
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"/>
<ListPreference
android:key="@string/list_size_key"
android:title="@string/list_size_title"