mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
[Feature/HideExpiredEntries] Apply 'Hide Expired Entries' Setting And Adjust Item Count Accordingly
Signed-off-by: Jihoon Kim <imsesaok@tuta.io>
This commit is contained in:
@@ -106,6 +106,8 @@ class GroupActivity : LockingActivity(),
|
||||
|
||||
private var mIconColor: Int = 0
|
||||
|
||||
private var showExpiredEntries = true
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
@@ -191,6 +193,8 @@ class GroupActivity : LockingActivity(),
|
||||
}
|
||||
})
|
||||
|
||||
showExpiredEntries = PreferencesUtil.showExpiredEntries(this)
|
||||
|
||||
mDatabase?.let { database ->
|
||||
// Search suggestion
|
||||
mSearchSuggestionAdapter = SearchEntryCursorAdapter(this, database)
|
||||
@@ -448,7 +452,9 @@ class GroupActivity : LockingActivity(),
|
||||
private fun refreshNumberOfChildren() {
|
||||
numberChildrenView?.apply {
|
||||
if (PreferencesUtil.showNumberEntries(context)) {
|
||||
text = mCurrentGroup?.getChildEntries(true)?.size?.toString() ?: ""
|
||||
text = mCurrentGroup?.getChildEntries(true)
|
||||
?.filter { !it.isCurrentlyExpires or showExpiredEntries}
|
||||
?.size?.toString() ?: ""
|
||||
visibility = View.VISIBLE
|
||||
} else {
|
||||
visibility = View.GONE
|
||||
|
||||
@@ -66,6 +66,7 @@ class NodeAdapter
|
||||
private var recycleBinBottomSort: Boolean = true
|
||||
private var showUserNames: Boolean = true
|
||||
private var showNumberEntries: Boolean = true
|
||||
private var showExpiredEntries: Boolean = true
|
||||
|
||||
private var actionNodesList = LinkedList<Node>()
|
||||
private var nodeClickCallback: NodeClickCallback? = null
|
||||
@@ -127,6 +128,7 @@ class NodeAdapter
|
||||
this.recycleBinBottomSort = PreferencesUtil.getRecycleBinBottomSort(context)
|
||||
this.showUserNames = PreferencesUtil.showUsernamesListEntries(context)
|
||||
this.showNumberEntries = PreferencesUtil.showNumberEntries(context)
|
||||
this.showExpiredEntries = PreferencesUtil.showExpiredEntries(context)
|
||||
|
||||
// Reinit textSize for all view type
|
||||
calculateViewTypeTextSize.forEachIndexed { index, _ -> calculateViewTypeTextSize[index] = true }
|
||||
@@ -139,7 +141,7 @@ class NodeAdapter
|
||||
this.nodeSortedList.clear()
|
||||
assignPreferences()
|
||||
try {
|
||||
this.nodeSortedList.addAll(group.getChildren())
|
||||
this.nodeSortedList.addAll(group.getChildren().filter { !it.isCurrentlyExpires or showExpiredEntries})
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, "Can't add node elements to the list", e)
|
||||
Toast.makeText(context, "Can't add node elements to the list : " + e.message, Toast.LENGTH_LONG).show()
|
||||
@@ -338,7 +340,10 @@ class NodeAdapter
|
||||
if (subNode.type == Type.GROUP) {
|
||||
if (showNumberEntries) {
|
||||
holder.numberChildren?.apply {
|
||||
text = (subNode as Group).getChildEntries(true).size.toString()
|
||||
text = (subNode as Group)
|
||||
.getChildEntries(true)
|
||||
.filter { !it.isCurrentlyExpires or showExpiredEntries}
|
||||
.size.toString()
|
||||
setTextSize(textSizeUnit, numberChildrenTextSize)
|
||||
visibility = View.VISIBLE
|
||||
}
|
||||
@@ -348,6 +353,7 @@ class NodeAdapter
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return nodeSortedList.size()
|
||||
}
|
||||
|
||||
@@ -57,6 +57,12 @@ object PreferencesUtil {
|
||||
context.resources.getBoolean(R.bool.list_groups_show_number_entries_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))
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the text size in % (1 for 100%)
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user