Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Android Compose + KP2A Autofill #2371

Open
lolo-io opened this issue Jun 30, 2023 · 3 comments · May be fixed by #2590
Open

[BUG] Android Compose + KP2A Autofill #2371

lolo-io opened this issue Jun 30, 2023 · 3 comments · May be fixed by #2590
Labels

Comments

@lolo-io
Copy link

lolo-io commented Jun 30, 2023

Hi, i'm trying to implement autofill in an Android app with Compose.
I am using AutofillType and AutofillNode.

My problem is that when I want to select an entry, it shows all the entries having androidapp://some.package.name in their additional fields, and not only the one having androidapp://my.app.package.

I don't know it it is a question or a bug, because in my memories this used to work.

I created a simple project to test this : https://github.com/lolo-io/DebugAutofill with just an email an password input, and all the code in the MainActivity.

It should work with androidapp://com.lolo.io.debugautofill

Maybe I'm doing something wrong. If you have an Idea let me know.

I test on a Pixel 6a device.

Thank you,


Basically this is how I add autofill support :

private fun Modifier.autofill(
    autofillTypes: List<AutofillType>,
    onFill: ((String) -> Unit),
) = composed {
    val autofill = LocalAutofill.current
    val autofillNode = AutofillNode(onFill = onFill, autofillTypes = autofillTypes)
    LocalAutofillTree.current += autofillNode

    this
        .onGloballyPositioned {
            autofillNode.boundingBox = it.boundsInWindow()
        }
        .onFocusChanged { focusState ->
            autofill?.run {
                if (focusState.isFocused) {
                    requestAutofillForNode(autofillNode)
                } else {
                    cancelAutofillForNode(autofillNode)
                }
            }
        }
}

@GoodSir42
Copy link

I am having the exact same issue. If we can log additional information from the app I am also willing to provide it. I could even contribute a fix, but that might require some bigger setup on my end first after reading the how to build guide 😅

@GoodSir42
Copy link

unfortunately I cannot build the app locally as I "only" have an M1 mac at my disposal right now, but it looks like the app cannot parse the autofill structure:
{ "InputFields": [ { "IdEntry": null, "Hint": null, "ClassName": "android.widget.FrameLayout", "AutofillHints": null, "IsFocused": false, "InputType": 0, "HtmlInfoTag": null, "HtmlInfoTypeAttribute": null }, { "IdEntry": null, "Hint": null, "ClassName": "android.view.ViewGroup", "AutofillHints": null, "IsFocused": true, "InputType": 0, "HtmlInfoTag": null, "HtmlInfoTypeAttribute": null }, { "IdEntry": null, "Hint": null, "ClassName": null, "AutofillHints": [ "username" ], "IsFocused": true, "InputType": 0, "HtmlInfoTag": null, "HtmlInfoTypeAttribute": null }, { "IdEntry": null, "Hint": null, "ClassName": null, "AutofillHints": [ "password" ], "IsFocused": false, "InputType": 0, "HtmlInfoTag": null, "HtmlInfoTypeAttribute": null } ], "PackageId": null, "WebDomain": null }
I'll see if I can reproduce that on my windows laptop later. @PhilippC do you have a hint on where I could add some additional logs that maybe parse the PackageId?

@lolo-io lolo-io changed the title [QUESTION] Android Compose + KP2A Autofill [BUG] Android Compose + KP2A Autofill Apr 15, 2024
@GoodSir42
Copy link

I created a pull request to change the way the package id is determined

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants