diff --git a/app/src/main/java/com/kunzisoft/keepass/autofill/AutofillHelper.kt b/app/src/main/java/com/kunzisoft/keepass/autofill/AutofillHelper.kt index 997671a3f..0556d4db5 100644 --- a/app/src/main/java/com/kunzisoft/keepass/autofill/AutofillHelper.kt +++ b/app/src/main/java/com/kunzisoft/keepass/autofill/AutofillHelper.kt @@ -351,28 +351,27 @@ object AutofillHelper { } val manualSelectionView = RemoteViews(context.packageName, R.layout.item_autofill_entry) manualSelectionView.setTextViewText(R.id.autofill_entry_text, context.getString(R.string.autofill_manual_selection_prompt)) - // manualSelectionView.setImageViewResource(R.id.autofill_entry_icon, R.mipmap.ic_launcher_round) val pendingIntent = AutofillLauncherActivity.getPendingIntentForSelection(context, searchInfo, inlineSuggestionsRequest) - val builder = Dataset.Builder(manualSelectionView) + parseResult.allAutofillIds().let { autofillIds -> + autofillIds.forEach { id -> + val builder = Dataset.Builder(manualSelectionView) - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { - inlineSuggestionsRequest?.let { - val inlinePresentationSpec = inlineSuggestionsRequest.inlinePresentationSpecs[0] - val inlinePresentation = buildInlinePresentationForManualSelection(context, inlinePresentationSpec, pendingIntent) - inlinePresentation?.let { - builder.setInlinePresentation(it) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + inlineSuggestionsRequest?.let { + val inlinePresentationSpec = inlineSuggestionsRequest.inlinePresentationSpecs[0] + val inlinePresentation = buildInlinePresentationForManualSelection(context, inlinePresentationSpec, pendingIntent) + inlinePresentation?.let { + builder.setInlinePresentation(it) + } + } } + builder.setValue(id, AutofillValue.forText("dummy")) + builder.setAuthentication(pendingIntent.intentSender) + responseBuilder.addDataset(builder.build()) } } - - // enable manual selection only for the form field that has focus - parseResult.focusedId?.let { autofillId -> - builder.setValue(autofillId, AutofillValue.forText("dummy")) - builder.setAuthentication(pendingIntent.intentSender) - responseBuilder.addDataset(builder.build()) - } } return try { @@ -413,7 +412,6 @@ object AutofillHelper { } else { buildResponse(activity, database, entriesInfo, result, null) } - response.apply { } val mReplyIntent = Intent() Log.d(activity.javaClass.name, "Successed Autofill auth.") mReplyIntent.putExtra( diff --git a/app/src/main/java/com/kunzisoft/keepass/autofill/StructureParser.kt b/app/src/main/java/com/kunzisoft/keepass/autofill/StructureParser.kt index fd52a2e4c..e3422fe29 100644 --- a/app/src/main/java/com/kunzisoft/keepass/autofill/StructureParser.kt +++ b/app/src/main/java/com/kunzisoft/keepass/autofill/StructureParser.kt @@ -44,7 +44,6 @@ class StructureParser(private val structure: AssistStructure) { fun parse(saveValue: Boolean = false): Result? { try { result = Result() - result?.focusedId = getFocusedID() result?.apply { allowSaveValues = saveValue usernameIdCandidate = null @@ -75,35 +74,6 @@ class StructureParser(private val structure: AssistStructure) { } } - /* - * Note: SDK >= Q provides this method... - * fillContext.getFocusedId() - */ - private fun getFocusedID(): AutofillId? { - for (i in 0 until structure.windowNodeCount) { - val windowNode = structure.getWindowNodeAt(i) - val autofillId = traverse(windowNode.rootViewNode) - if (autofillId != null) { - return autofillId - } - } - return null - } - - private fun traverse(node: AssistStructure.ViewNode): AutofillId? { - if (node.visibility == View.VISIBLE && node.autofillHints != null) { - return node.autofillId - } else { - for (i in 0 until node.childCount) { - val autoFillId = traverse(node.getChildAt(i)) - if (autoFillId != null) { - return autoFillId - } - } - } - return null - } - private fun parseViewNode(node: AssistStructure.ViewNode): Boolean { // remember this if (node.className == "android.webkit.WebView") { @@ -447,9 +417,6 @@ class StructureParser(private val structure: AssistStructure) { var creditCardExpirationMonthOptions: Array? = null var creditCardExpirationDayOptions: Array? = null - // the AutofillId of the view that triggered autofill. - var focusedId: AutofillId? = null - var usernameId: AutofillId? = null set(value) { if (field == null)