Encountered Inter-op issues between AndroidView an...
# compose
n
Encountered Inter-op issues between AndroidView and Compose elements wrt to Keyboard navigation. While navigating elements using external bluetooth keyboard, only compose elements gets highlighted where as Compose elements internally using AndroidView never responds. Is this a known limitation ?
z
Focus search should work with views too. Which version of compose and android have you observed this with?
n
Using latest
Compose BOM 2022.10.00
targetSdk
and
compileSdk
set to 33 Adding the simple code snippet if it helps
Copy code
@Composable
fun KeyboardNavigationDemo() {
    Row(
        modifier = Modifier
            .fillMaxWidth()
            .padding(PaddingValues(start = 16.dp)),
        horizontalArrangement = Arrangement.SpaceBetween,
        verticalAlignment = Alignment.CenterVertically
    ) {

        AndroidView(
            modifier = Modifier.focusable(),
            factory = {
                MaterialButton(it)
            },
            update = {
                it.text = "View Button"
                it.isAllCaps = false
            }
        )

        Text(
            modifier = Modifier
                .wrapContentWidth(),
            text = "Google"
        )

        Button(
            onClick = { }) {
            Text(
                modifier = Modifier
                    .wrapContentWidth(),
                text = "Compose Button"
            )
        }

    }
}
z
What happens if you remove the focusable modifier from AndroidView?
n
The focus skips the AndroidView altogether, Adding the video with focusable removed on AndroidView
With focusable modifier on AndroidView,
Modifier.onFocusChanged
gets called with right state of
FocusState
but the state of the AndroidView stays the same w/o highlight and W/o Keyboard focusing the AndroidView element
z
That sounds like a regression I think, pretty sure that used to work. Please file a bug ( @Ralston Da Silva this should work, right?)
n
Had verified the behaviour in earlier versions as well but similar result
Copy code
Compose UI : 1.1.1
compileSdk : 32
Will file a bug, thanks @Zach Klippenstein (he/him) [MOD]
z
Can you reproduce on 1.3? A lot has changed with focus since 1.1
n
Yes, Can reproduce. Used Compose BOM 2022.10.00 uses Compose UI 1.3.0. Raised an issue.
z
Can you link it here?
@Ralston Da Silva, Kind request, is it indeed a regression? or never supported? or wrong usage? Could you shed some light on it please.
r
Hi Nagaraj, yes, this is a known interop issue. Thanks for filing the bug.
n
HI @Ralston Da Silva, apologies for tagging directly, Checked with latest updates
Copy code
compose_ui_version = '1.5.0-beta03'
kotlin_version = '1.8.22'
kotlin_compiler_ext_version = '1.4.8'
Issue still persists. If possible can you share the plan or priorities with which Compose team is approaching this bug.
Bug associated for this case which is reported at https://issuetracker.google.com/issues/255628260