Jesse Hendrickson
07/16/2024, 5:05 PMBasicTextField
(formerly BasicTextField2
) and the contentReceiver()
Modifier in Compose 1.7-beta05 on a Samsung, API 34 device (Samsung SM-F926U1). It works great on my Pixel 6 (API 34). I'm worried that it may not work on more Samsungs, though I don't currently have one to test on.
Issue: The `ReceiveContentListener`'s onReceive
is never called when selecting in a GIF (or any type of image) from the Samsung Keyboard. Thus the "Can't enter this content here." toast shows. Our prior implementation, with AppCompatEditText
wrapped in an AndroidView
and overriding onCreateInputConnection
works on this device in question.
I'm migrating from a wrapped EditText/AndroidView combo to full compose to solve a separate ANR issue with focus requesting, and this is understandably a blocker, because we don't want our users to lose Image insertion in the chat experience.Jesse Hendrickson
07/16/2024, 5:05 PMBasicTextField(
state = state,
enabled = enabled,
keyboardOptions = KeyboardOptions(
capitalization = KeyboardCapitalization.Sentences,
keyboardType = KeyboardType.Text,
),
modifier = Modifier
.fillMaxWidth()
.contentReceiver { transferableContent ->
if (!transferableContent.hasMediaType(MediaType.Image)) {
return@contentReceiver transferableContent
}
transferableContent.consume {
it.uri?.let { uri ->
onMediaSelected(uri)
true
} ?: false
}
}
.focusRequester(focusRequester),
)
Jesse Hendrickson
07/16/2024, 5:07 PMHalil Ozercan
07/16/2024, 7:18 PMJesse Hendrickson
07/16/2024, 7:19 PMJesse Hendrickson
07/16/2024, 7:44 PMHalil Ozercan
07/16/2024, 11:59 PM*/*
as accepted mime type for the input connection. This was previously a non-documented behavior on Android platform and should have been avoided by apps. Gboard works fine in this situation but Samsung keyboard doesn't like it. If we simply expand the mime types list to */*, image/*
, then gifs work.Halil Ozercan
07/17/2024, 12:01 AMcontentReceiver
API we presented this choice (configuring accepted mime types) to developers but ultimately decided to scrap it since it had almost no use other than hinting at the IME. Apparently it can still be useful.Jesse Hendrickson
07/17/2024, 12:05 AM