Open ianthetechie opened 1 year ago
@haysmike #2 is the one where the major questions are!
Additional information, you can create the MapLibreMap as an XML component and it can be converted to the bitmap too. :D Flitmeister said they will create a repo with a sample app, but they have no timeline for this yet though.
Flitsmeister posted their example under MIT license https://github.com/flitsmeister/MapLibre-Android-Auto-Sample. We can absolutely go this path, but I still think it's worth further exploration into the Compose view as map surface.
That'd allow us to much more effectively adapt our Android Auto map with content driven by our compose work. Using the filtsmiester sample, we'd have to do what Mapbox does where we have to recreate bitmaps of all the components like speed limit signs, the route polyline, etc.
Some updates for discussion:
We must provide our own custom Map "surface" behind the CarApp Template(s). Unlike CarPlay on iOS where UIKit is supported for this layer, Android only seems to offer
android.graphics.Canvas
to draw this layer. Which from research typically results in an FPS constrained bitmap generation process. Where a Handler draws a bitmap on the canvas on the surface at a high rate. There are several avenues to go on this:ComposeView
. The issues with this approach are leveraging theLifecycle
,SavedStateRegistry
andWindow
. All of which don't seem to exist as Compose expects in the CarContext/Screen. I've done several passes of this and may well be close on one of them, but it's a lot of crashing for things like null lifecycle,Window
issues etc. This seems like an ideal solution, but it may well require someone with deep android platform and Compose knowledge (Aka someone building core Android Compose 😆).MapView
into the Flitsmeister surface renderer. The idea being that the compose view in the Android application context (even if not visible) could essentially be running the stateful map, which is then injected into the surface as a pre-configured MaplibreMap to render as a bitmap. Janky, probably has tons of issues, but might be a way to get our rendering of symbols, without having to reconstruct it. Last note here, this may actually be a good excuse to totally re-think the MapView in the compose playground to get us one step closer to BSD-3 or MIT on that library.