mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Hide expired entries from quick search when setting is activated #453
This commit is contained in:
@@ -449,7 +449,7 @@ class GroupActivity : LockingActivity(),
|
||||
private fun refreshNumberOfChildren() {
|
||||
numberChildrenView?.apply {
|
||||
if (PreferencesUtil.showNumberEntries(context)) {
|
||||
text = mCurrentGroup?.getChildEntries(*Group.getChildFilters(context))?.size?.toString() ?: ""
|
||||
text = mCurrentGroup?.getChildEntries(*Group.ChildFilter.getDefaults(context))?.size?.toString() ?: ""
|
||||
visibility = View.VISIBLE
|
||||
} else {
|
||||
visibility = View.GONE
|
||||
|
||||
@@ -131,7 +131,7 @@ class NodeAdapter
|
||||
this.showUserNames = PreferencesUtil.showUsernamesListEntries(context)
|
||||
this.showNumberEntries = PreferencesUtil.showNumberEntries(context)
|
||||
|
||||
this.entryFilters = Group.getChildFilters(context)
|
||||
this.entryFilters = Group.ChildFilter.getDefaults(context)
|
||||
|
||||
// Reinit textSize for all view type
|
||||
calculateViewTypeTextSize.forEachIndexed { index, _ -> calculateViewTypeTextSize[index] = true }
|
||||
|
||||
@@ -36,7 +36,8 @@ import com.kunzisoft.keepass.icons.assignDatabaseIcon
|
||||
import com.kunzisoft.keepass.settings.PreferencesUtil
|
||||
import java.util.*
|
||||
|
||||
class SearchEntryCursorAdapter(context: Context, private val database: Database)
|
||||
class SearchEntryCursorAdapter(private val context: Context,
|
||||
private val database: Database)
|
||||
: androidx.cursoradapter.widget.CursorAdapter(context, null, FLAG_REGISTER_CONTENT_OBSERVER) {
|
||||
|
||||
private val cursorInflater: LayoutInflater = context.getSystemService(
|
||||
@@ -109,7 +110,7 @@ class SearchEntryCursorAdapter(context: Context, private val database: Database)
|
||||
}
|
||||
|
||||
override fun runQueryOnBackgroundThread(constraint: CharSequence): Cursor? {
|
||||
return database.searchEntries(constraint.toString())
|
||||
return database.searchEntries(context, constraint.toString())
|
||||
}
|
||||
|
||||
fun getEntryFromPosition(position: Int): Entry? {
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
package com.kunzisoft.keepass.database.element
|
||||
|
||||
import android.content.ContentResolver
|
||||
import android.content.Context
|
||||
import android.content.res.Resources
|
||||
import android.database.Cursor
|
||||
import android.net.Uri
|
||||
@@ -401,7 +402,7 @@ class Database {
|
||||
return mSearchHelper?.search(this, str, max)
|
||||
}
|
||||
|
||||
fun searchEntries(query: String): Cursor? {
|
||||
fun searchEntries(context: Context, query: String): Cursor? {
|
||||
|
||||
var cursorKDB: EntryCursorKDB? = null
|
||||
var cursorKDBX: EntryCursorKDBX? = null
|
||||
@@ -414,7 +415,7 @@ class Database {
|
||||
val searchResult = search(query, SearchHelper.MAX_SEARCH_ENTRY)
|
||||
if (searchResult != null) {
|
||||
// Search in hide entries but not meta-stream
|
||||
for (entry in searchResult.getChildEntries(Group.ChildFilter.META_STREAM)) {
|
||||
for (entry in searchResult.getChildEntries(*Group.ChildFilter.getDefaults(context))) {
|
||||
entry.entryKDB?.let {
|
||||
cursorKDB?.addEntry(it)
|
||||
}
|
||||
|
||||
@@ -79,7 +79,17 @@ class Group : Node, GroupVersionedInterface<Group, Entry> {
|
||||
}
|
||||
|
||||
enum class ChildFilter {
|
||||
META_STREAM, EXPIRED
|
||||
META_STREAM, EXPIRED;
|
||||
|
||||
companion object {
|
||||
fun getDefaults(context: Context): Array<ChildFilter> {
|
||||
return if (PreferencesUtil.showExpiredEntries(context)) {
|
||||
arrayOf(META_STREAM)
|
||||
} else {
|
||||
arrayOf(META_STREAM, EXPIRED)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object CREATOR : Parcelable.Creator<Group> {
|
||||
@@ -90,14 +100,6 @@ class Group : Node, GroupVersionedInterface<Group, Entry> {
|
||||
override fun newArray(size: Int): Array<Group?> {
|
||||
return arrayOfNulls(size)
|
||||
}
|
||||
|
||||
fun getChildFilters(context: Context): Array<ChildFilter> {
|
||||
return if (PreferencesUtil.showExpiredEntries(context)) {
|
||||
arrayOf(ChildFilter.META_STREAM)
|
||||
} else {
|
||||
arrayOf(ChildFilter.META_STREAM, ChildFilter.EXPIRED)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun describeContents(): Int {
|
||||
|
||||
Reference in New Issue
Block a user