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
|
// TODO in real time
|
||||||
// Assign title
|
// Assign title
|
||||||
if (group?.isVirtual == true) {
|
if (group?.isVirtual == true) {
|
||||||
searchNumbers?.text = group.numberOfChildEntries.toString()
|
searchNumbers?.text = SearchHelper.showNumberOfSearchResults(group.numberOfChildEntries)
|
||||||
toolbarBreadcrumb?.navigationIcon = null
|
toolbarBreadcrumb?.navigationIcon = null
|
||||||
} else {
|
} else {
|
||||||
// Add breadcrumb
|
// Add breadcrumb
|
||||||
@@ -1043,7 +1043,7 @@ class GroupActivity : DatabaseLockActivity(),
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun loadSearchGroup(query: String?) {
|
private fun loadSearchGroup(query: String?) {
|
||||||
if (query != null && query.isNotEmpty()) {
|
if (query != null) {
|
||||||
mGroupViewModel.loadGroupFromSearch(
|
mGroupViewModel.loadGroupFromSearch(
|
||||||
mDatabase,
|
mDatabase,
|
||||||
query,
|
query,
|
||||||
|
|||||||
@@ -91,6 +91,17 @@ class SearchHelper {
|
|||||||
companion object {
|
companion object {
|
||||||
const val MAX_SEARCH_ENTRY = 100
|
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]
|
* 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,
|
fun searchInEntry(entry: Entry,
|
||||||
searchParameters: SearchParameters): Boolean {
|
searchParameters: SearchParameters): Boolean {
|
||||||
val searchQuery = searchParameters.searchQuery
|
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())
|
if (searchQuery.isEmpty())
|
||||||
return false
|
return true
|
||||||
|
|
||||||
// Search all strings in the KDBX entry
|
// Search all strings in the KDBX entry
|
||||||
if (searchParameters.searchInTitles) {
|
if (searchParameters.searchInTitles) {
|
||||||
|
|||||||
Reference in New Issue
Block a user