mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Fix search empty string
This commit is contained in:
@@ -606,7 +606,7 @@ class GroupActivity : DatabaseLockActivity(),
|
||||
// TODO in real time
|
||||
// Assign title
|
||||
if (group?.isVirtual == true) {
|
||||
searchNumbers?.text = group.numberOfChildEntries.toString()
|
||||
searchNumbers?.text = SearchHelper.showNumberOfSearchResults(group.numberOfChildEntries)
|
||||
toolbarBreadcrumb?.navigationIcon = null
|
||||
} else {
|
||||
// Add breadcrumb
|
||||
@@ -1043,7 +1043,7 @@ class GroupActivity : DatabaseLockActivity(),
|
||||
}
|
||||
|
||||
private fun loadSearchGroup(query: String?) {
|
||||
if (query != null && query.isNotEmpty()) {
|
||||
if (query != null) {
|
||||
mGroupViewModel.loadGroupFromSearch(
|
||||
mDatabase,
|
||||
query,
|
||||
|
||||
@@ -91,6 +91,17 @@ class SearchHelper {
|
||||
companion object {
|
||||
const val MAX_SEARCH_ENTRY = 100
|
||||
|
||||
/**
|
||||
* Method to show the number of search results with max results
|
||||
*/
|
||||
fun showNumberOfSearchResults(number: Int): String {
|
||||
return if (number >= MAX_SEARCH_ENTRY) {
|
||||
(MAX_SEARCH_ENTRY-1).toString() + "+"
|
||||
} else {
|
||||
number.toString()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method to perform actions if item is found or not after an auto search in [database]
|
||||
*/
|
||||
@@ -133,9 +144,9 @@ class SearchHelper {
|
||||
fun searchInEntry(entry: Entry,
|
||||
searchParameters: SearchParameters): Boolean {
|
||||
val searchQuery = searchParameters.searchQuery
|
||||
// Entry don't contains string if the search string is empty
|
||||
// Entry contains string if the search string is empty
|
||||
if (searchQuery.isEmpty())
|
||||
return false
|
||||
return true
|
||||
|
||||
// Search all strings in the KDBX entry
|
||||
if (searchParameters.searchInTitles) {
|
||||
|
||||
Reference in New Issue
Block a user