mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-04-05 13:57:36 +03:00
Fix search in recycle bin #613
This commit is contained in:
parent
77ae3a4623
commit
4279825caa
9 changed files with 39 additions and 23 deletions
|
@ -1,5 +1,6 @@
|
||||||
KeePassDX(2.8)
|
KeePassDX(2.8)
|
||||||
* Fix TOTP period (> 60s)
|
* Fix TOTP period (> 60s)
|
||||||
|
* Fix searching in recycle bin
|
||||||
|
|
||||||
KeePassDX(2.7)
|
KeePassDX(2.7)
|
||||||
* Add blocklists for autofill
|
* Add blocklists for autofill
|
||||||
|
|
|
@ -75,7 +75,10 @@ import com.kunzisoft.keepass.notifications.DatabaseTaskNotificationService.Compa
|
||||||
import com.kunzisoft.keepass.settings.PreferencesUtil
|
import com.kunzisoft.keepass.settings.PreferencesUtil
|
||||||
import com.kunzisoft.keepass.timeout.TimeoutHelper
|
import com.kunzisoft.keepass.timeout.TimeoutHelper
|
||||||
import com.kunzisoft.keepass.utils.MenuUtil
|
import com.kunzisoft.keepass.utils.MenuUtil
|
||||||
import com.kunzisoft.keepass.view.*
|
import com.kunzisoft.keepass.view.AddNodeButtonView
|
||||||
|
import com.kunzisoft.keepass.view.ToolbarAction
|
||||||
|
import com.kunzisoft.keepass.view.asError
|
||||||
|
import com.kunzisoft.keepass.view.showActionError
|
||||||
|
|
||||||
class GroupActivity : LockingActivity(),
|
class GroupActivity : LockingActivity(),
|
||||||
GroupEditDialogFragment.EditGroupListener,
|
GroupEditDialogFragment.EditGroupListener,
|
||||||
|
@ -389,7 +392,8 @@ class GroupActivity : LockingActivity(),
|
||||||
// If it's a search
|
// If it's a search
|
||||||
if (Intent.ACTION_SEARCH == intent.action) {
|
if (Intent.ACTION_SEARCH == intent.action) {
|
||||||
val searchString = intent.getStringExtra(SearchManager.QUERY)?.trim { it <= ' ' } ?: ""
|
val searchString = intent.getStringExtra(SearchManager.QUERY)?.trim { it <= ' ' } ?: ""
|
||||||
return mDatabase?.createVirtualGroupFromSearch(searchString)
|
return mDatabase?.createVirtualGroupFromSearch(searchString,
|
||||||
|
PreferencesUtil.omitBackup(this))
|
||||||
}
|
}
|
||||||
// else a real group
|
// else a real group
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -46,7 +46,8 @@ class SearchEntryCursorAdapter(private val context: Context,
|
||||||
|
|
||||||
private val cursorInflater: LayoutInflater? = context.getSystemService(
|
private val cursorInflater: LayoutInflater? = context.getSystemService(
|
||||||
Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater?
|
Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater?
|
||||||
private var displayUsername: Boolean = false
|
private var mDisplayUsername: Boolean = false
|
||||||
|
private var mOmitBackup: Boolean = true
|
||||||
private val iconColor: Int
|
private val iconColor: Int
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
@ -59,7 +60,8 @@ class SearchEntryCursorAdapter(private val context: Context,
|
||||||
}
|
}
|
||||||
|
|
||||||
fun reInit(context: Context) {
|
fun reInit(context: Context) {
|
||||||
this.displayUsername = PreferencesUtil.showUsernamesListEntries(context)
|
this.mDisplayUsername = PreferencesUtil.showUsernamesListEntries(context)
|
||||||
|
this.mOmitBackup = PreferencesUtil.omitBackup(context)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun newView(context: Context, cursor: Cursor, parent: ViewGroup): View {
|
override fun newView(context: Context, cursor: Cursor, parent: ViewGroup): View {
|
||||||
|
@ -93,7 +95,7 @@ class SearchEntryCursorAdapter(private val context: Context,
|
||||||
// Assign subtitle
|
// Assign subtitle
|
||||||
viewHolder.textViewSubTitle?.apply {
|
viewHolder.textViewSubTitle?.apply {
|
||||||
val entryUsername = currentEntry.username
|
val entryUsername = currentEntry.username
|
||||||
text = if (displayUsername && entryUsername.isNotEmpty()) {
|
text = if (mDisplayUsername && entryUsername.isNotEmpty()) {
|
||||||
String.format("(%s)", entryUsername)
|
String.format("(%s)", entryUsername)
|
||||||
} else {
|
} else {
|
||||||
""
|
""
|
||||||
|
@ -129,7 +131,9 @@ class SearchEntryCursorAdapter(private val context: Context,
|
||||||
if (database.type == DatabaseKDBX.TYPE)
|
if (database.type == DatabaseKDBX.TYPE)
|
||||||
cursorKDBX = EntryCursorKDBX()
|
cursorKDBX = EntryCursorKDBX()
|
||||||
|
|
||||||
val searchGroup = database.createVirtualGroupFromSearch(query, SearchHelper.MAX_SEARCH_ENTRY)
|
val searchGroup = database.createVirtualGroupFromSearch(query,
|
||||||
|
mOmitBackup,
|
||||||
|
SearchHelper.MAX_SEARCH_ENTRY)
|
||||||
if (searchGroup != null) {
|
if (searchGroup != null) {
|
||||||
// Search in hide entries but not meta-stream
|
// Search in hide entries but not meta-stream
|
||||||
for (entry in searchGroup.getFilteredChildEntries(Group.ChildFilter.getDefaults(context))) {
|
for (entry in searchGroup.getFilteredChildEntries(Group.ChildFilter.getDefaults(context))) {
|
||||||
|
|
|
@ -39,7 +39,6 @@ class LoadDatabaseRunnable(private val context: Context,
|
||||||
private val mKey: Uri?,
|
private val mKey: Uri?,
|
||||||
private val mReadonly: Boolean,
|
private val mReadonly: Boolean,
|
||||||
private val mCipherEntity: CipherDatabaseEntity?,
|
private val mCipherEntity: CipherDatabaseEntity?,
|
||||||
private val mOmitBackup: Boolean,
|
|
||||||
private val mFixDuplicateUUID: Boolean,
|
private val mFixDuplicateUUID: Boolean,
|
||||||
private val progressTaskUpdater: ProgressTaskUpdater?,
|
private val progressTaskUpdater: ProgressTaskUpdater?,
|
||||||
private val mDuplicateUuidAction: ((Result) -> Unit)?)
|
private val mDuplicateUuidAction: ((Result) -> Unit)?)
|
||||||
|
@ -58,7 +57,6 @@ class LoadDatabaseRunnable(private val context: Context,
|
||||||
mReadonly,
|
mReadonly,
|
||||||
context.contentResolver,
|
context.contentResolver,
|
||||||
cacheDirectory,
|
cacheDirectory,
|
||||||
mOmitBackup,
|
|
||||||
mFixDuplicateUUID,
|
mFixDuplicateUUID,
|
||||||
progressTaskUpdater)
|
progressTaskUpdater)
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,6 @@ import com.kunzisoft.keepass.database.file.output.DatabaseOutputKDBX
|
||||||
import com.kunzisoft.keepass.database.search.SearchHelper
|
import com.kunzisoft.keepass.database.search.SearchHelper
|
||||||
import com.kunzisoft.keepass.database.search.SearchParameters
|
import com.kunzisoft.keepass.database.search.SearchParameters
|
||||||
import com.kunzisoft.keepass.icons.IconDrawableFactory
|
import com.kunzisoft.keepass.icons.IconDrawableFactory
|
||||||
import com.kunzisoft.keepass.model.SearchInfo
|
|
||||||
import com.kunzisoft.keepass.stream.readBytes4ToUInt
|
import com.kunzisoft.keepass.stream.readBytes4ToUInt
|
||||||
import com.kunzisoft.keepass.tasks.ProgressTaskUpdater
|
import com.kunzisoft.keepass.tasks.ProgressTaskUpdater
|
||||||
import com.kunzisoft.keepass.utils.SingletonHolder
|
import com.kunzisoft.keepass.utils.SingletonHolder
|
||||||
|
@ -316,7 +315,6 @@ class Database {
|
||||||
readOnly: Boolean,
|
readOnly: Boolean,
|
||||||
contentResolver: ContentResolver,
|
contentResolver: ContentResolver,
|
||||||
cacheDirectory: File,
|
cacheDirectory: File,
|
||||||
omitBackup: Boolean,
|
|
||||||
fixDuplicateUUID: Boolean,
|
fixDuplicateUUID: Boolean,
|
||||||
progressTaskUpdater: ProgressTaskUpdater?) {
|
progressTaskUpdater: ProgressTaskUpdater?) {
|
||||||
|
|
||||||
|
@ -378,7 +376,7 @@ class Database {
|
||||||
else -> throw SignatureDatabaseException()
|
else -> throw SignatureDatabaseException()
|
||||||
}
|
}
|
||||||
|
|
||||||
this.mSearchHelper = SearchHelper(omitBackup)
|
this.mSearchHelper = SearchHelper()
|
||||||
loaded = true
|
loaded = true
|
||||||
|
|
||||||
} catch (e: LoadDatabaseException) {
|
} catch (e: LoadDatabaseException) {
|
||||||
|
@ -393,20 +391,24 @@ class Database {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isGroupSearchable(group: Group, isOmitBackup: Boolean): Boolean {
|
fun isGroupSearchable(group: Group, omitBackup: Boolean): Boolean {
|
||||||
return mDatabaseKDB?.isGroupSearchable(group.groupKDB, isOmitBackup) ?:
|
return mDatabaseKDB?.isGroupSearchable(group.groupKDB, omitBackup) ?:
|
||||||
mDatabaseKDBX?.isGroupSearchable(group.groupKDBX, isOmitBackup) ?:
|
mDatabaseKDBX?.isGroupSearchable(group.groupKDBX, omitBackup) ?:
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
fun createVirtualGroupFromSearch(searchQuery: String,
|
fun createVirtualGroupFromSearch(searchQuery: String,
|
||||||
|
omitBackup: Boolean,
|
||||||
max: Int = Integer.MAX_VALUE): Group? {
|
max: Int = Integer.MAX_VALUE): Group? {
|
||||||
return mSearchHelper?.createVirtualGroupWithSearchResult(this, searchQuery, SearchParameters(), max)
|
return mSearchHelper?.createVirtualGroupWithSearchResult(this,
|
||||||
|
searchQuery, SearchParameters(), omitBackup, max)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun createVirtualGroupFromSearchInfo(searchInfoString: String,
|
fun createVirtualGroupFromSearchInfo(searchInfoString: String,
|
||||||
|
omitBackup: Boolean,
|
||||||
max: Int = Integer.MAX_VALUE): Group? {
|
max: Int = Integer.MAX_VALUE): Group? {
|
||||||
return mSearchHelper?.createVirtualGroupWithSearchResult(this, searchInfoString, SearchParameters().apply {
|
return mSearchHelper?.createVirtualGroupWithSearchResult(this,
|
||||||
|
searchInfoString, SearchParameters().apply {
|
||||||
searchInTitles = false
|
searchInTitles = false
|
||||||
searchInUserNames = false
|
searchInUserNames = false
|
||||||
searchInPasswords = false
|
searchInPasswords = false
|
||||||
|
@ -416,7 +418,7 @@ class Database {
|
||||||
searchInUUIDs = false
|
searchInUUIDs = false
|
||||||
searchInTags = false
|
searchInTags = false
|
||||||
ignoreCase = true
|
ignoreCase = true
|
||||||
}, max)
|
}, omitBackup, max)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Throws(DatabaseOutputException::class)
|
@Throws(DatabaseOutputException::class)
|
||||||
|
|
|
@ -32,7 +32,7 @@ import com.kunzisoft.keepass.model.getSearchString
|
||||||
import com.kunzisoft.keepass.settings.PreferencesUtil
|
import com.kunzisoft.keepass.settings.PreferencesUtil
|
||||||
import com.kunzisoft.keepass.timeout.TimeoutHelper
|
import com.kunzisoft.keepass.timeout.TimeoutHelper
|
||||||
|
|
||||||
class SearchHelper(private val isOmitBackup: Boolean) {
|
class SearchHelper {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val MAX_SEARCH_ENTRY = 6
|
const val MAX_SEARCH_ENTRY = 6
|
||||||
|
@ -54,6 +54,7 @@ class SearchHelper(private val isOmitBackup: Boolean) {
|
||||||
// If search provide results
|
// If search provide results
|
||||||
database.createVirtualGroupFromSearchInfo(
|
database.createVirtualGroupFromSearchInfo(
|
||||||
searchInfo.getSearchString(context),
|
searchInfo.getSearchString(context),
|
||||||
|
PreferencesUtil.omitBackup(context),
|
||||||
MAX_SEARCH_ENTRY
|
MAX_SEARCH_ENTRY
|
||||||
)?.let { searchGroup ->
|
)?.let { searchGroup ->
|
||||||
if (searchGroup.getNumberOfChildEntries() > 0) {
|
if (searchGroup.getNumberOfChildEntries() > 0) {
|
||||||
|
@ -77,6 +78,7 @@ class SearchHelper(private val isOmitBackup: Boolean) {
|
||||||
fun createVirtualGroupWithSearchResult(database: Database,
|
fun createVirtualGroupWithSearchResult(database: Database,
|
||||||
searchQuery: String,
|
searchQuery: String,
|
||||||
searchParameters: SearchParameters,
|
searchParameters: SearchParameters,
|
||||||
|
omitBackup: Boolean,
|
||||||
max: Int): Group? {
|
max: Int): Group? {
|
||||||
|
|
||||||
val searchGroup = database.createGroup()
|
val searchGroup = database.createGroup()
|
||||||
|
@ -101,7 +103,7 @@ class SearchHelper(private val isOmitBackup: Boolean) {
|
||||||
override fun operate(node: Group): Boolean {
|
override fun operate(node: Group): Boolean {
|
||||||
return when {
|
return when {
|
||||||
incrementEntry >= max -> false
|
incrementEntry >= max -> false
|
||||||
database.isGroupSearchable(node, isOmitBackup) -> true
|
database.isGroupSearchable(node, omitBackup) -> true
|
||||||
else -> false
|
else -> false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,19 +21,23 @@ package com.kunzisoft.keepass.notifications
|
||||||
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.*
|
import android.os.AsyncTask
|
||||||
|
import android.os.Binder
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.os.IBinder
|
||||||
import com.kunzisoft.keepass.R
|
import com.kunzisoft.keepass.R
|
||||||
import com.kunzisoft.keepass.app.database.CipherDatabaseEntity
|
import com.kunzisoft.keepass.app.database.CipherDatabaseEntity
|
||||||
import com.kunzisoft.keepass.database.action.*
|
import com.kunzisoft.keepass.database.action.*
|
||||||
import com.kunzisoft.keepass.database.action.history.DeleteEntryHistoryDatabaseRunnable
|
import com.kunzisoft.keepass.database.action.history.DeleteEntryHistoryDatabaseRunnable
|
||||||
import com.kunzisoft.keepass.database.action.history.RestoreEntryHistoryDatabaseRunnable
|
import com.kunzisoft.keepass.database.action.history.RestoreEntryHistoryDatabaseRunnable
|
||||||
import com.kunzisoft.keepass.database.action.node.*
|
import com.kunzisoft.keepass.database.action.node.*
|
||||||
import com.kunzisoft.keepass.database.element.*
|
import com.kunzisoft.keepass.database.element.Database
|
||||||
|
import com.kunzisoft.keepass.database.element.Entry
|
||||||
|
import com.kunzisoft.keepass.database.element.Group
|
||||||
import com.kunzisoft.keepass.database.element.database.CompressionAlgorithm
|
import com.kunzisoft.keepass.database.element.database.CompressionAlgorithm
|
||||||
import com.kunzisoft.keepass.database.element.node.Node
|
import com.kunzisoft.keepass.database.element.node.Node
|
||||||
import com.kunzisoft.keepass.database.element.node.NodeId
|
import com.kunzisoft.keepass.database.element.node.NodeId
|
||||||
import com.kunzisoft.keepass.database.element.node.Type
|
import com.kunzisoft.keepass.database.element.node.Type
|
||||||
import com.kunzisoft.keepass.settings.PreferencesUtil
|
|
||||||
import com.kunzisoft.keepass.tasks.ActionRunnable
|
import com.kunzisoft.keepass.tasks.ActionRunnable
|
||||||
import com.kunzisoft.keepass.tasks.ProgressTaskUpdater
|
import com.kunzisoft.keepass.tasks.ProgressTaskUpdater
|
||||||
import com.kunzisoft.keepass.utils.DATABASE_START_TASK_ACTION
|
import com.kunzisoft.keepass.utils.DATABASE_START_TASK_ACTION
|
||||||
|
@ -256,7 +260,6 @@ class DatabaseTaskNotificationService : NotificationService(), ProgressTaskUpdat
|
||||||
keyFileUri,
|
keyFileUri,
|
||||||
readOnly,
|
readOnly,
|
||||||
cipherEntity,
|
cipherEntity,
|
||||||
PreferencesUtil.omitBackup(this),
|
|
||||||
intent.getBooleanExtra(FIX_DUPLICATE_UUID_KEY, false),
|
intent.getBooleanExtra(FIX_DUPLICATE_UUID_KEY, false),
|
||||||
this
|
this
|
||||||
) { result ->
|
) { result ->
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
* Fix TOTP period (> 60s)
|
* Fix TOTP period (> 60s)
|
||||||
|
* Fix searching in recycle bin
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
* Correction de la période pour le TOTP (> 60s)
|
* Correction de la période pour le TOTP (> 60s)
|
||||||
|
* Correction de la recherche dans la corbeille
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue