mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Fix autofill auto search
This commit is contained in:
@@ -33,6 +33,8 @@ import android.widget.RemoteViews
|
||||
import androidx.annotation.RequiresApi
|
||||
import com.kunzisoft.keepass.R
|
||||
import com.kunzisoft.keepass.activities.helpers.EntrySelectionHelper
|
||||
import com.kunzisoft.keepass.database.element.Database
|
||||
import com.kunzisoft.keepass.database.search.SearchHelper
|
||||
import com.kunzisoft.keepass.model.EntryInfo
|
||||
import com.kunzisoft.keepass.model.SearchInfo
|
||||
|
||||
@@ -125,6 +127,32 @@ object AutofillHelper {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method to perform actions if item is found or not after an auto search in [database]
|
||||
*/
|
||||
fun checkAutoSearchInfo(activity: Activity,
|
||||
database: Database,
|
||||
searchInfo: SearchInfo?,
|
||||
onItemFound: () -> Unit,
|
||||
onItemNotFound: () -> Unit) {
|
||||
var searchWithoutUI = false
|
||||
if (searchInfo != null) {
|
||||
// If search provide results
|
||||
database.createVirtualGroupFromSearch(searchInfo, SearchHelper.MAX_SEARCH_ENTRY)?.let { searchGroup ->
|
||||
if (searchGroup.getNumberOfChildEntries() > 0) {
|
||||
// Build response with the entry selected
|
||||
buildResponse(activity,
|
||||
searchGroup.getChildEntriesInfo(database))
|
||||
searchWithoutUI = true
|
||||
onItemFound.invoke()
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!searchWithoutUI) {
|
||||
onItemNotFound.invoke()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method to start an activity with an Autofill for result
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user