Installation and Integration
This guide walks you through installing the Maestro core SDK, with no client SDK, and showing its panel and overlays in your Android application.
Prerequisites
Before you begin, make sure you have:
- Android Studio, with Kotlin and Jetpack Compose set up
- Your Maestro
siteId. For directions to obtain yoursiteId, see Hello World. - A GitHub Personal Access Token (PAT) with the
read:packagesscope, for accessing the SDK package
Installation
1. Configure the Maven repository
The SDK is published to GitHub Packages, which requires a token even to read. In settings.gradle.kts, add the
repository:
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/lessthan3/MaestroKit.android")
credentials {
username = "your_github_username"
password = "your_github_personal_access_token"
}
}
}
}
2. Add the SDK dependency
In your app module's build.gradle.kts, add the core artifact and enable core library desugaring, which the SDK
requires:
android {
compileOptions {
isCoreLibraryDesugaringEnabled = true
}
}
dependencies {
implementation("com.lessthan3:uitoolkit:<VERSION>-core")
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.2")
}
Integration
1. Implement the delegate
The SDK calls back into your app through CoreEventDelegate.
trackImpression and trackAction are required; override the others as you need them:
class MyCoreDelegate : CoreEventDelegate {
override fun trackImpression(analytics: Map<String, String>) {
// Forward to your analytics provider
}
override fun trackAction(analytics: Map<String, String>) {
// Forward to your analytics provider
}
override fun shouldShowPanel() {
// A viewer clicked an overlay that targets a panel: show the panel
}
override fun shouldHidePanel() {
// The viewer pressed Back on the panel's tabs: hide the panel
}
}
2. Configure the SDK
Call configure() once at the app level, in your Application class or a root
ViewModel, not in the player screen. It returns the session, a CoreMaestroSDK.Instance:
val sdk = MaestroCoreSDK.configure(
context = applicationContext,
params = CoreSDKParameters(
siteId = "your-site-id",
pageId = "your-page-id",
configBaseUrl = "https://static.gcp.maestro.io",
),
delegate = MyCoreDelegate(),
)
3. Tell the session what the player is doing
sdk.onEventDataUpdated(metadataValues = listOf(newEventId)) // the playing event changed
sdk.onPlayerTimecodeUpdated(absoluteTimeMillis) // the play-head moved
onEventDataUpdated() fetches the panel config for the playing event, and
onPlayerTimecodeUpdated() drives timecoded overlays.
4. Show the panel and overlays
MaestroCorePanel draws the panels the page config carries, one tab each.
MaestroCoreOverlays draws the overlays the session receives, each at the
position its config gives. Draw the panel only while it should be visible, so shouldShowPanel() and
shouldHidePanel() in your delegate can toggle it:
setContent {
Box(modifier = Modifier.fillMaxSize()) {
YourPlayerContent()
if (panelVisible) {
MaestroCorePanel(
sdk = sdk,
modifier = Modifier
.width(300.dp)
.fillMaxHeight()
.align(Alignment.CenterEnd),
)
}
MaestroCoreOverlays(sdk = sdk)
}
}
To check overlays draw without waiting for a real one, call
sdk.debugInterface.triggerTestOverlay().
MaestroHelloWorldPanel draws only a hello world card, to confirm the SDK
is installed and running.
Placing the overlay yourself
If you want to show or hide your own player UI while a Maestro overlay is on screen, follow
sdk.overlays (the current CoreOverlay with its
text and position, or null when there is none) and draw the overlay with
MaestroCoreOverlayView where you place it. Call
sdk.dismissOverlay() to close the current overlay programmatically. Use
MaestroCoreOverlayView or MaestroCoreOverlays, never both:
import com.maestro.uitoolkit.core.MaestroCoreOverlayView
import com.maestro.uitoolkit.core.toAlignment
val overlay by sdk.overlays.collectAsStateWithLifecycle(initialValue = null)
overlay?.let {
Box(Modifier.fillMaxSize(), contentAlignment = it.position?.toAlignment() ?: Alignment.TopEnd) {
MaestroCoreOverlayView(sdk = sdk)
}
}
5. Tear down
When your app no longer shows Maestro content, end the session with detach(), for
example when the root ViewModel that configured it is cleared:
override fun onCleared() {
sdk.detach()
}